-
attachMovie clip with an array
I am using an attachMovie command to put images from my library on a movieclip that I have animated. But now I want it so the movie that is attached is random. Lets say it picks from 3 different movies from my library, and then attaches one to the movie clip in my timeline.
on the movie itself i have a standard attachmovie command.
onClipEvent (load) {
this.float.blank.attachMovie("myArray[randomNumber]", "newcamera", 0);
}
Then on the begining of _root I have:
myArray = new Array("product1", "product2", "product3");
randomNumber = Math.ceil(Math.random()*myArray.length);
randomNumber = Math.floor(Math.random()*myArray.length);
//products 1-3 are the linkage names of my movie clips from the library.
Uh, now why doesn't it work. Am I way off base with this whole array thing?
Any working code to attach random movie clip from the library would be VERY much appretiated. Feel free to post an exmaple FLA for myself and others.
-
Senior Mender
this.float.blank.attachMovie("product" + (Random(2) + 1), "newcamera", 0);
-
Senior Mender
With your code the problem is the first argument of attachmovie is not a string.
But its very complicated for nothing.. In programation the less line you use the better it is..
onClipEvent (load) {
this.float.blank.attachMovie(myArray[randomNumber], "newcamera", 0);
}
Then on the begining of _root I have:
myArray = new Array("product1", "product2", "product3");
randomNumber = Math.ceil(Math.random()*myArray.length);
randomNumber = Math.floor(Math.random()*myArray.length);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|