jhaddington
10-23-2008, 11:58 AM
Hi Guys,
Im reasonably new to AS3 and Im having a slight problem with some syntax of my for loop.
I basically have 5 pictures of scales in different positions so that on a slider it looks to be moving up and down. In order to ensure the movement is smooth I want to load the pictures beforehand, and to minimise code, I have put it in a for loop. The problem I'm having is concatinating the variable "photo" with the "i" of the for loop (see code below). Could anyone point me in the right direction?
In addition to this how would I then call the variable name in the add child below?
Just ask anything that doesn't make sense. :D
Thanks
CODE
for(var i:uint = 0;i>5;i++)
{
var photoi:Loader = new Loader();
photoi.load(new URLRequest("/scales/scale_"+i+".jpg"));
}
function changeHandlerscale(event:SliderEvent):void {
addChild(photoi);
photo.x = 201.9;
photo.y = 131.5;
}
Im reasonably new to AS3 and Im having a slight problem with some syntax of my for loop.
I basically have 5 pictures of scales in different positions so that on a slider it looks to be moving up and down. In order to ensure the movement is smooth I want to load the pictures beforehand, and to minimise code, I have put it in a for loop. The problem I'm having is concatinating the variable "photo" with the "i" of the for loop (see code below). Could anyone point me in the right direction?
In addition to this how would I then call the variable name in the add child below?
Just ask anything that doesn't make sense. :D
Thanks
CODE
for(var i:uint = 0;i>5;i++)
{
var photoi:Loader = new Loader();
photoi.load(new URLRequest("/scales/scale_"+i+".jpg"));
}
function changeHandlerscale(event:SliderEvent):void {
addChild(photoi);
photo.x = 201.9;
photo.y = 131.5;
}