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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script needed: random picture on random place by click

Status
Not open for further replies.

Elfie

Technical User
Jan 12, 2004
1
NL
I have a small question about a script I'm trying to find. I don't have a lot of experience with Flash, but I have to do this thing for school for which I need this script for my website.
I need a script which does the following: When you click on a button (or just on any place if the first is not possible) with you mouse, there appears a random picture (one out of ten or something) on a random place in a field (so not the whole page).
I hope you understand what I mean. I don't know the script, I only know that it's supposed to exist :) Does anybody know this script or where I can find such a script?

Thanks for helping me!

Elfie
 
If you are planning to use Flash you might try it this way.

Create a clip (yourClip) on the main timeline. Drag your new clip to the main timline and make the instance name also (yourClip).

in the first frame of the main timeline add this script:

//Create Random Number where 5+1 is the number of images (0 counts)
_root.dieroll = random(5);

//Creates function for loading images
_global.myLoader = function (imageNumber) {
loadMovie("yourImage"+imageNumber+".jpg", _root.yourClip);
//move movie to random x and y location
_root.yourClip._x = random(200);
_root.yourClip._y = random(300);
}


On your buttons your code should be something like:

on(release){
_global.myLoader(_root.dieroll);
}


Two things to note:

The random() action was deprecated in favor of the math.Random() action but I have not been able to acheive the same results using math.Random.

Also your image names in this example should be something link "myImage1.jpg".

I hope that gives you enough to start with.





Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top