• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 570
  • Last Modified:

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

0
420_dragon
Asked:
420_dragon
  • 2
1 Solution
 
Eaddy BarnesITCommented:
so basically your trying to load the gif into each sprite as they are created?
and then use them as buttons?
0
 
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.

thanks
0
 
Eaddy BarnesITCommented:
you can use the image loaded as a button directly and disregard the sprite.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now