PDA

View Full Version : actionscript syntax...


hoolagon
01-15-2007, 01:08 PM
Hello,

I have 6 movie clips named root.singers_mc.image1 to root.singers_mc.image6

Can anyone tell me why this doesnt work...



var numberOfSingers:Number = 6

for (i = 1; i<=numberOfSingers; i++) {
_root.singers_mc["image"+i].onRelease = function(){
myMCL.loadClip["images/singers/image"+i+".jpg"], "container_mc";
trace(["images/singers/image"+i+".jpg"]);
}
}

Outputs: images/singers/image6.jpg regarldess of which movieclip is clicked!

I imagine ive got the syntax wrong, but ive tried lots of variations and i cant do it.

Julian

CyanBlue
01-15-2007, 01:47 PM
Howdy and Welcome... :)

You have to specify that 'i' value for each button like this...
var numberOfSingers:Number = 6;

for (i = 1; i <= numberOfSingers; i++)
{
_root.singers_mc["image" + i].id = i;
_root.singers_mc["image" + i].onRelease = function()
{
myMCL.loadClip["images/singers/image" + this.id + ".jpg"], "container_mc";
trace(["images/singers/image" + this.id + ".jpg"]);
};
}

hoolagon
01-15-2007, 06:03 PM
Thanks for your swift reply.

The trace command is now giving the correct output:
Output images/singers/image/image1.jpg , images/singers/image/image2.jpg, images/singers/image/image3.jpg etc.

However its still not working as the image is not displayed.

I dont think the following line works properly. Do you know what i need to do to it to get it working?

myMCL.loadClip["images/singers/image" + this.id + ".jpg"], "container_mc";

Thanks in advance,

Julian

CyanBlue
01-15-2007, 06:15 PM
If you copied that line from somewhere else, you are missing whole lot more script in there...
You might want to check on the MovieClipLoader.loadClip from the Flash manual... It's got the sample code that you can utilize as well...

hoolagon
01-15-2007, 06:25 PM
Ive worked it out... its

myMCL.loadClip("images/image" + this.id + ".jpg", "container_mc");

Thanks!

CyanBlue
01-15-2007, 06:38 PM
Cool... :)