Actionscript 3 Problem setting Instance Name of a Sprite


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 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; = "video" + boxIndex++;
function loadComplete(evt:Event):void
trace("Image has loaded.");
startY += box.height + boxSpacing;
box.addEventListener(MouseEvent.MOUSE_UP, boxOnRelease);
function boxOnRelease(evt:MouseEvent):void
var videoName:String = "video/" + + ".flv";

Open in new window

Who is Participating?
Eaddy BarnesConnect With a Mentor ITCommented:
you can use the image loaded as a button directly and disregard the sprite.

Eaddy BarnesITCommented:
so basically your trying to load the gif into each sprite as they are created?
and then use them as buttons?
420_dragonAuthor Commented:
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.