Hi I have an assignment to create a random array to store pictures. Each time that you click on one of the buttons in the header a new picture will appear. I know how to set up an array, and i also know how to setup up a random array. From what i understand an array is for data, so how do i store a picture in it. I don't know if this is making any sense, but my instructor isn't helping much either. Just a push in the right direction could help out a bunch. thanks
Random arrays
Collapse
X
-
Tags: None
-
what version of actionscript are you using?Originally posted by hollywoood69Hi I have an assignment to create a random array to store pictures. Each time that you click on one of the buttons in the header a new picture will appear. I know how to set up an array, and i also know how to setup up a random array. From what i understand an array is for data, so how do i store a picture in it. I don't know if this is making any sense, but my instructor isn't helping much either. Just a push in the right direction could help out a bunch. thanks
nomad -
Originally posted by nomadwhat version of actionscript are you using?
nomad
I am using actionscript 2.0 for now. My nex set of classes i will be using as3Comment
-
I have a similar problem.
I want to load movies randomly. I made the script, but it doesn't seem to work.
This is what I have:
A short explanation. All my movies are external FLV but I recall them in different movies on my main timeline. So for every FLV I have a separate movie. (the reason why I do so is because I added different cue points to the different FLV's, but that's not of any importance in this thread).Code:moviename = ["imovie1", "imovie2", "imovie3", "imovie4"]; function randomise() { _root.ilogo.play(); i = moviename.length; k = Math.floor(Math.random()*i); moviename[k].play(); trace(moviename[k]); }
So I made an array with the instances of the different movies.
Then I randomly pick a number.
By using moviename[k] I'm displaying value k out of array moviename.
However it doesn't seem to work.
I put the trace in to check if he is actually getting the value out of the array and that is the case. So I can see him randomly picking a number but when I try to play it, he won't do it.
So the problem lies in the line: moviename[k].play();
However when I put an instance name in place of moviename[k] it does play it. Probably I'm forgetting something but I don't know what. If someone can help me, please do!
I'm using AS 2.0Comment
-
hollywoood69:
Don't store pictures in the array, just store a reference to pictures. e.g
var pics:Array = ["pic1.jpg", "pic2.jpg", ...];
//btn is the btn you click on
btn.onPress = function()
{
//mc is the movieclip that holds your pictures
mc.loadMovie(pi cs[Math.random() * pics.length]);
}
_______
Cainnech:
remove inverted commas, i.e:
moviename = [imovie1, imovie2, imovie3, imovie4];Comment
Comment