Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

randomly entering different images into a movie clip 2

Status
Not open for further replies.

Kirderf

Technical User
Oct 4, 2000
183
US
Hi Folks,
I am searching for a way to randomly enter a graphic into a movie clip.
My movie clip is that of a garage door.
Every time the user clicks a button, the garage door opens.

Inside the door I want to randomly have a new image. There, within the movie clip, in the next to last layer, is where I will put the random selected image. Is there some way to do this using action scripting? I have no idea where to start.

I have poured through my books to try to find a similar instance, but to no avail.

Please help a poor brother who is searching for the light.

-Kirderf
 
hie
have a look at
faq250-756 item 5

or may be load that pictures like swf's in levelX or in some mc instead of goin to some random frame..

play around Victor
 

I have tried to have the first frame of the movie(which is triggered to play on rollover of a button) to randomly send the playhead to a different position each time the movie is triggered. (that would be one way to accomplish this, right?)
Where is a good place to go to learn these nuances of action scripting?
I cant seem to get the code right to do this.
I am trying to put this code within the movie clip.I would hope this is the place to put it.
I am having trouble with both writing the code and where to place it.

Has anyone heard of this, I hope I am explaining it well, because I really could get more done if I could just get past this point.
 
that faq # 5 that was posted above is a goto random fla..that should be the exact way that you do it..plug the codes in your script where they are needed and you should be good..
e.gif


carlsatterwhite@endangeredgraphics.com
 
but the faq #5 works for a random placement on the main timeline, not inside an instance of a movie . How would the scripting be different for that scenario and still be controlled from a button on the main timeline?

I am trying to make a garage door open when you mouse over a button. Within the garage door I want to randomly place different items like a guy and a car, and a car on a lift...etc...changing the inside of the garage each time the button is rolled over and the door opens.

I cant seem to figure how I would change the scripting to work for this instance.

Am I making this too hard? Somebody slap me.
 
target the mc from the main timeline with either the telltarget, or with command..
e.gif


carlsatterwhite@endangeredgraphics.com
 

I was able to use a variation of the code(from #5) in the beginning of my movie clip.
Q=number(random(4)+3)
Gotoandplay Q
*(my first frames had a stop action attached so the door would stay closed until the button was pressed. The second frame was where I put my code, so the +3 gave me a random jump to frames 3-6)

I had to make 4 versions of the door opening
and label the start of each one. Then I popped 4 different versions of the garage contents into the movieclip. in the first few frames I put goto(labelx)commands.
I know this is probably the cumbersome way to get around this one, but it works. Thanks for the tips guys!!!!

I will try to use the tell target and command methods later. This would probably clean it up a lot. I am understanding this action scripting much better. That is definitely worth a few sleepless nights.
I'd gladly pay you on Thursday
for a hamburger today!
 
If you want to do this with only one version of the door opening you could try something like this...

1) Have a movieClip, say 10 frames long, which has a different image on each frame. Put a stop action on the first frame.

2) Put this on the stage on the layer underneath your garage door clip. Give it the instance name "images" or whatever.

3) On the button which opens the door add the following script....

on(release){

//create a random number between 1 and 10

randomFrame=math.random()*9+1;

//use this number as a frame target

_root.images.gotoAndStop(randomFrame);

//then your "opendoor" actions....

}



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top