PDA

View Full Version : loadMovie randomly on mouseDown



mariam
April 16th, 2003, 03:09 AM
What i'd like to happen. but don't have enough actionscript knowhow.
I have a series of small movies. i have made an interface with buttons. when the user presses a button one of the movies will be selected randomly and loaded into the main movie. that's it.
Please help.
best
m

blah-de-blah
April 16th, 2003, 03:39 AM
An idea would be to generate a random number and depending on the number, using 'if' statements to see which movie loads...

upuaut
April 16th, 2003, 04:13 AM
Well.. there's supposed to be a "switch" method that will accomplish this, but I have no clue how to use it so I'm not going to go into it. There are a number of ways of accomplishing this effect though. I would do it this way:

on the main timeline in one of the first frames place an array constructor like so:

aMovieNames = new Array();
aMovieNames[0]="firstMovie.swf";
aMovieNames[1]="secondMovie.swf";
aMovieNames[2]="thirdMovie.swf";
aMovieNames[3]="fourthMovie.swf";

then on the button all you would need is this

on(release){
n=Math.round(Math.random()*_root.aMovieNames.lengt h);
_root.mainMovie.loadMovie(aMovieNames[n]);
}

given that the instance name of the movie clip which you are loading these into is called "mainMovie"

mariam
April 16th, 2003, 07:50 PM
thanks Blah-de-blah and david for such a quick reply.
i just woke up, so i haven't tried your solution yet. but will try it now
thanks
m

mariam
April 16th, 2003, 08:42 PM
Well i tried David's code and i worked!! thanks david
but now I have a new weird problem. when the movie loads it seems to load half way down the page, so that you can only see a quarter of the content. it seems to have something to do with the registration of the page? only guessing.
i've checked the alignment of all objects etc. but not sure where page alignment would be? help.m