Link to home
Start Free TrialLog in
Avatar of 420_dragon
420_dragon

asked on

Actionscript 3 Problem setting Instance Name of a Sprite

Hey,

I am having trouble setting the instance name of my Sprites that get created through a for loop. What I am doing is loading an external gif into a 16 Sprites that gets created in a foor loop...but it seems like it ignores my box.name parameter setter. Please help.


var rows:int = 16;
var boxSpacing:int = 1;
var boxWidth:Number = 65
var boxHeight:Number = 48
var startX:Number = boxSpacing;
var startY:Number = boxSpacing;
var boxIndex:int = 1;
 
 
for(var i:int = 1; i <= rows; i++){
 
var imgLoader:Loader = new Loader();
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
imgLoader.load(new URLRequest("people/adam.gif"));
 
var box:Sprite = new Sprite();
 
box.x = startX;
box.y = startY;
box.buttonMode = true;
box.alpha = .5;
 
box.name = "video" + boxIndex++;
 
 
function loadComplete(evt:Event):void
{
trace("Image has loaded.");
}
 
 
thumb_con.addChild(box);
 
 
startY += box.height + boxSpacing;
 
box.addEventListener(MouseEvent.MOUSE_UP, boxOnRelease);
 
}
 
 
function boxOnRelease(evt:MouseEvent):void
{
var videoName:String = "video/" + evt.target.name + ".flv";
trace(videoName);
}

Open in new window

Avatar of Eaddy Barnes
Eaddy Barnes
Flag of United States of America image

so basically your trying to load the gif into each sprite as they are created?
and then use them as buttons?
Avatar of 420_dragon
420_dragon

ASKER

Well yes. Also I am eventually going to use xml to load different images into each gif...but right now..Im just trying to figure out a way to get this to work.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Eaddy Barnes
Eaddy Barnes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial