Groups | Blog | Home
all groups > flash (macromedia) > october 2005 >

flash (macromedia) : Cell Renderer ???


C-Rock
10/26/2005 11:43:28 PM
class ImageRenderer extends MovieClip
{
private var image_mc:MovieClip;
private var imageID:Number;
function ImageRenderer ()
{
this.createEmptyMovieClip ("image_mc", 100);
image_mc._xscale = 17;
image_mc._yscale = 17;
image_mc._x = 3;
image_mc._y = 2;
}
function setValue (suggested:String, item:Object, selected:String):Void
{
if (item.LN == undefined)
{
this.image_mc.unloadMovie ();
this.imageID = undefined;
}
if (item != undefined && (this.imageID != item.LN || image_mc.getBytesLoaded
() == 0))
{
this.image_mc.loadMovie ("images/0" + item.LN + "_00.jpg");
this.imageID = item.LN;
}
}
}

how would I ammend this code so it goes to a standard image like no photo or
something if the image is not in the folder? I'm getting errors and blank
spaces on the datagrid now if there is not picture. I would like it to just
show the image "00000_00.jpg"

thanks!!!
Bentley Wolfe MM
10/27/2005 10:43:51 AM

[quoted text, click to view]

Don't use loadMovie. Use the MovieClipLoader class and use it's events
to determine if the file was found or not...

-- Regards,

Bentley Wolfe
Senior Escalation Engineer, Flash
C-Rock
10/27/2005 1:31:33 PM
C-Rock
10/27/2005 9:23:04 PM
Bentley Wolfe MM
10/28/2005 9:48:10 AM
[quoted text, click to view]

My friend, if you're brave enough to dive into the CellRenderer (which
honestly is one of the trickiest bits of Flash...) then it'll be easy to
learn about moviecliploader.

Here's the livedocs link:
http://livedocs.macromedia.com/flash/8/main/00002538.html
-- Regards,

Bentley Wolfe
Senior Escalation Engineer, Flash
Macromedia
C-Rock
10/28/2005 6:03:05 PM
First I wanted to say thank-you for your help. I really appreciated. This is so
pretty advanced stuff I'm doing or at least it seems that way. I have tried to
implement your code for a few hours now that you suggested. I just can't get it
to work. Could you take a look at it and point me to the right direction?
Thank-you

class ImageRenderer extends MovieClip {
private var imageID:Number;
private var image_mc:MovieClip;
function ImageRenderer() {
this.createEmptyMovieClip("image_mc", 100);
image_mc._xscale = 60;
image_mc._yscale = 60;
image_mc._x = 11;
image_mc._y = -37;
}
function setValue(suggested:String, item:Object, selected:String):Void {
if (item.id == undefined) {
this.image_mc.unloadMovie();
this.imageID = undefined;
//trace(imageID);
}
if (item != undefined && (this.imageID != item.id ||
image_mc.getBytesLoaded() == 0)) {
var myMCL = new MovieClipLoader();
myMCL.onLoadStart = function(targetMC) {
//trace("The movieclip "+targetMC+" has started loading");
};
myMCL.onLoadComplete = function(targetMC) {

trace("comepleted " +imageID);
};
myMCL.onLoadError = function(targetMC, errorCode) {
trace("ERRORCODE:"+errorCode);
trace(targetMC+"Failed to load its content");
myMCL.loadClip("Images/AAA.jpg", image_mc);
};
myMCL.loadClip("Images/"+item.id+".jpg", image_mc);
this.imageID = item.id;
//trace(imageID);
}
}
}
AddThis Social Bookmark Button