Random Variables
hiya!
i was wondering is its possible to do random variables?
like, if a had 2 variables, min = 10 and max = 15,
then what i wanna do is make an event that randomly chooses a value between the numerical values of min and max, (10 - 15)
any ideas?
thnx a bunch!!
FlashKit > Flash Help > Flash Newbies
Posted on: 02-14-2005, 04:32 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Random Variables
I am doing a weather report example for a virtual wap phone.
I have three dynamic text boxs which will show the weather in three citys.
My problem is that I want to randomly call 4 different txt files with the 3 variables for the dynamic text boxes but with obviously different reports, so that every time you go in it will be different.
Can you loadVariables, but from a random txt file?
Or can you call a random variable from a txt file?
If you could help, that would be super!
Random Variables
Hello,
I am looking for a simple method to randomly display pictures that will be stored on different servers.
I would like to assign variables (A, B, C, etc...) to parts of the address where the pictures are located.
For example:
A could be assigned to
http://www.domain.com
B to second part
/pictures
C to filename
/SET100012.jpg
This way servers can be different but hold the same structure with a common directory pictures. I just have it randomly select A1 or A2 if I want 1 common B section.
Also, I want to be able to randomize C section which are the individual pictures.
Any help on this would be appreciated.
Random Variables
I am using Flash MX and wanted to make a game like "whack a mole", except im going to be using pictures of my relatives instead (they dont know it yet!). I made buttons out of their faces so that when you click them, the faces change and make a sound. I was wondering how to make the buttons appear randomly on a 4x3 stage. I know OOP but action scripting has confused me so far. Thanks.
-Matthew Walsh
walshms@cs.slu.edu
Random With Variables Mc - Help Please
random with variables mc - help please
okay, what i have is a choose section that sits at the top of the page. in the choose movieclip i have three instances of a background movie clip.
now within the background movieclip there is 9 frames. each frame has an image mc in it and a stop command, except the first frame-this has nothing in it other than a command to goto and play a random frame within the background mc timeline.
now what i need to happen is to make sure that if one of the instances of the background mc is on frame (we'll say 3) then the other two instances of the background mc are not on frame 3. they all need to be different from each other.
help please. this should be an easy set up of variables but my brain is not functioning right today.
for those of you that have no idea what i am talking about, here is a test file.
http://www.levelthirteen.com/test.html
click on the "choose" button several times. you see the three mcs that change. sometimes they are the same image, and that is what i don't want to happen. i want them to be different from each other every time.
thanks everyone
[Edited by levelthirteen on 09-20-2002 at 04:05 PM]
Variables And Random
Hi!
This is the code, i wont to make line 1 ( the box ) to
random number 1-9 and the second row 9-19 and the third
19-29 and so on, how to make that? now there is no order where
the numbers apair.
Question 2, how do you make random numbers for example
100 and 500 and 1000, its for a lotteryticket with values
that to be displayed randomly
Check example for the first question
http://m1.271.telia.com/~u27103713/
Thanks!
Help With Random Variables
i need a code to tell 13 targets(instance names 1-13),
using a random # (out of 24), to go to and play the frame
within the movie clip that corresponds with that random #.
so far so good:
on (release) {
for (i=1; i<=13; i++) {
tellTarget (i) {
rune = Math.ceil(Math.random()*24);
gotoAndPlay (rune);
}
}
}
}
but now i also need to test to make sure that random # hasn't already
been picked. i am at my wits end. no matter what i do i get repeats.
i have also tried this with a while loop but the player crashes when i do that. see attached pictures for more info.
help!!!!!!!!!!!!!!!!
randym
Random Variables?
Hi
I'm trying to create a simple game using Flash5 on XP professional - I haven't used flash for years and was never an expert:
The user can type in up to 10 names.
Click a button.
The names are displayed equidistant around a circle.
A movie plays and one of the 10 names is displayed at the end - it is picked randomly. It will either be displayed in the centre of the circle, or i may use a rotating pointer which stops on one of the names.
I'm afraid I haven't got very far with this. So far all I've managed to do is create 10 fields, input names, click a button, and display the names.
Can anyone help me do the following:
1 how do i get flash to recognise how many names have been input?
2 is it possible to tab between text boxes rather than having to click in each separately?
3 how can i get flash to work out angles between each name displayed around a circle - ie if there are 2 names, then they will be placed at 180degree intervals, 3 names = 120degree etc.
4 how can i get flash to randomly pick one of the input names?
I've tried looking at flash help, and action scripting reference but i don't know where to start.
Thanks in advance
Random Variables Not The Same
i'm kinda new, so please be nice to me!!
i have 9 variables that contain random values. how would i go about making sure none of the variables are the same or equal one another? i know i could write a ton of "if" statements, but theres gotta be a better way. maybe a "for" loop? anyway to go about this would be greatly appreciated.
Thanks,
Gena
Random Variables
How do I make it so when I press a button a variable textblock goes down a random number between 10 and 20.
Variables/random/repeating?
i need to be able to call a text file with x-amount (probably about 100) of variables in like:
&variable1=blahblahblah
&variable2=yacketyschmakety
etc etc
No probs so far... then what I need to do is to be able to use these variable by chosing five or six at random and tranfering them to named buttons with out any of them repeating...
Is this possible, am i wasting my time?
Yours in dire need of assistance
The Bombadier
Can Random Numbers = Variables?
this is what i hav at the beginning of my script
Math.randomRange = function(min, max) {
return Math.floor(Math.random()*(max+1-min))+min;
};
than later i declare this variable
var A = trace(Math.randomRange(15, 20));
m i doing this rite? how do u make variables equal a different number ever time u use it, and still set a minimum and maximum limit? what is the easiest way to do this?
Choose Random Variables
I want to know an easy way for flash to randomly select variables from a pre-existing list. For example randomly select x,y, or z? Any ideas please (for Flash 5)
Random Variables Not Working..
Okay what i'm trying to do is create a fly that hovers a bit, flies to another location, hovers a bit, flies to another location etc..
But theres some weird stuff happening i dont really understand..
heres the code i've written for now (located in the first frame of the root layer)
Code:
//all variables here
var angle=0;
var speed=0;
var movevar=0;
var setHalt=0;
var waitTime=50;
//animation:
function slide(angle,speed)
{
//make angle a radial number
angle = (Math.PI/180)*angle;
//use angle to set x speed:
var xSpeed = Math.cos(angle)*speed;
//use angle to set y speed:
var ySpeed = Math.sin(angle)*speed;
this.fly._x = this.fly._x + xSpeed;
this.fly._y = this.fly._y - ySpeed;
}
// this function adds to the angle
function rotate(angleVar)
{
angle = angle+angleVar;
}
function accelerate(accVar)
{
speed = speed+(accVar);
}
//important functions:
function wait()
{
waitTime=waitTime-1
if (waitTime==0)
{
setHalt=0;
//set to random
angle=Math.random()*360;
if(this.fly._y>550)
{
angle=225 + Math.random()*90;
}
if(this.fly._y<50)
{
angle=45 + Math.random()*90;
}
waitTime=30+Math.random()*30;
//end random
}
}
function moveStop()
{
if (movevar<11)
{
accelerate(0.5);
movevar = movevar +1;
}
if (movevar>10 && movevar <30)
{
movevar = movevar +1;
}
if (movevar==30)
{
speed=0;
movevar = 0;
setHalt=1;
}
}
//////////////////////////////////
// enterframe events: //
//////////////////////////////////
this.onEnterFrame = function()
{
if (setHalt==0)
{
moveStop();
}
if (setHalt==1)
{
wait();
}
slide(angle,speed);
}
but i'm having problems in the function wait()
this is working:
Code:
angle=Math.random()*360;
but these things dont:
this is supposed to make the fly turn back when it moves to far up or down the screen, and set the time it's hovering to a random number.
Code:
if(this.fly._y>550)
{
angle=225 + Math.random()*90;
}
if(this.fly._y<50)
{
angle=45 + Math.random()*90;
}
waitTime=30+Math.random()*30;
however, if i just set waitTime to 50 or so (not a random number), it works :S
i traced waitTime=30+Math.random()*30; and that just gives me a number, but i really have no idea why it makes the fly stop.
Anyone care for helping me out with this one?
[F8] Trouble With Variables And Random
Okay, here goes!
i am trying to create a variable that will give a random number between 1 and 5
in a movieclip on my timeline , i have 5 frames, each holding an image.
i want a random number to display a random image, i.e if the number is 1, it should go to frame 1, if its 2, it should go to frame 2.
I tried declaring the variable on the main timeline (in reality, i am working in another whole movieclip here, but my project contains so many areas that i am keeping it within this one movieclip)
using: _global.combination1==(Math.random()*5);
and including this code in the timeline of the 5 images movieclip
if(_global.combination1=1)
{gotoAndPlay(1);
}
if(_global.combination1=2)
{gotoAndPlay(2);
}
if(_global.combination1=3)
{gotoAndPlay(3);
}
if(_global.combination1=4)
{gotoAndPlay(4);
}
if(_global.combination1=5)
{gotoAndPlay(5);
}
i have tried global and local variables, but nothing seems to work!
Random Non Repeating Variables
OK I'm somewhat descent at Actionscript, but I'm brand new to arrays. I know very little about them. It seems at the moment I'm going to have to make use of them.
Here's what I'm doing:
I'm creating a flash game in which you are a UFO flying over a group of cows and you have to abduct them. It's a top view game so I have the grass moving from top to bottom and I have a movie with 5 cows and theres a controller in the _root movie that creates a random variable:
_root.cows = random(5);
Now everytime the controller movie gets to a certain frame, that frame tells the cow movie to play a certain cow (Moving from top to bottom) based on the current variable.
What's happening is when there is a repeat, the cow disapears and jumps back to the top. Seeing how there's only 5 cows you can tell this happens a lot.
Now I've researched this a bit and found that I can create an array of random numbers and splice each one as I've used it. I've tried this, copied different codes and I can't get it to work.
I'm probably placing it wrong or something, but being a man who is used to his variables, maybe I'm doing something the wrong way. Please explain, if anyone can, how I can do this....and if possible explain as if talking to a third grader. thanks
Random Variables [renamed]
I've been working on a deal or no deal game (my first game) and I'm stuck. I just need a script to make 22 variables that are randomly equal to numbers 1 - 22, so I get a result like this:
box01 = side09;
box02 = side12;
box03 = side19;
...
...
box22 = side04;
thanks
EDIT: I should probably clarify that all 22 numbers need to be different.
DuplicateMovieClip - Random Variables
It seems like the random variables in my duplicated movieclips are all the same, any way to change this?
To explain a bit more in detail: I got a movieclip with a few random variables and actions and I duplicate this movieclip and want the duplicate to have different random variables than the first one, but it gets identical ones.
Need To Create 12 Random Non-repeat Variables?
I need to create 12 random numbers (non-repeating) that I can call on one at a time as variables. (Ex. variables a1 thru a12 would be random numbers 1 thru 12). I want to use these later to tell an 12 MC instances to go to one of 12 frame labels and non of them be on the same label.
I've tried it a couple different ways and have come very close but each method has a different bug in it. Can anyone help?
Neo
Variables/Random Number Problems
Hey,
Im making a script which draws a comment from a text file and displays it in a dynamic text box, randomly...
n = random(6);
loadText = new LoadVars();
loadText.load("data.txt");
loadText.onLoad = function() {
comments.text = this.n;
};
so basically i define the variable n as a random number between 0 and 5, then in the data.txt file i have:
0=comment 0
1=comment 1
2=comment 2
3=comment 3
4=comment 4
5=comment 5
If i dont use the variable in this.n and use a different value it seems to work...(comments.text is the instance name of the dynamic text box)
thanks for any help
-Ross
[CS3] Placing An MC On Stage With Random Variables...
Hello, I have a MC in my library with linkage set up called "mc1" that I'd like to have "x" number of instances placed on the stage (where "x" would be a variable I could change). I'd like to have each instance be placed at a random place on the stage, also with a random rotation value, and also a random scale size from 50%-100%...
...Can anyone help me out with this? Thanks so much!!!
Random Numbers Into Variables With Loop?
hi some help on this would be greatly appreciated.
i have this code to generate 3 random numbers yeah.. and i want to pass them into var1 var 2 and var3. how do i do it?
n = 3;
for (r= 0; r < cards.length && n > 0; ++r){
if (random(cards.length-r) < n){
n--;
please help.
Scenes Based On Random Variables
I'm trying to build a program where specific scenes are played depending on a randomly generated number. So far the number is generated, but the movie doesn't play the right scene.
This is the code I have now;
var score:Number;
score = random(100)
if (score >= 95) {
gotoAndPlay("Scene 3", 1);
}
else if (score >= 80) {
gotoAndPlay("scene 4", 1)
}
else if (score >= 65) {
gotoAndPlay("scene 5", 1)
}
else if (score >= 50) {
gotoAndPlay("scene 6", 1)
}
else if (score >= 25) {
gotoAndPlay("scene 7", 1)
}
else if (score >= 0) {
gotoAndPlay("scene 8", 1)
}
Load Variables From Random Text File In Set? HELP
I need to be able to_ Load variables from random text file in a given a set._ I am using the newest flash version (fx, mx??) on Mac OS X
heres what I was emailed
"needs:_
1. we'd like this game to load numbers dynamically from a given range
of numbers rather than from a textfile._ If all the numeric variables
loaded randomly from say a range of 1 to 10 for level 1 then how can
you program to make the answer for the game?_
2. , we have to devise a
way to keep track of the number of times a user chooses the bucket and
make the bucket work that many times._ So if you click 30 times
really fast on the bucket, it will probably only work 2 or 3 times as
it has to play an animation after a click._ The bucket becomes
inactive while in animation so how do we tell it to keep working
based on clicks?_
3._ keeping track of correct answers._ So this may be a way off but
we need to keep track of the wins by a user when they enter into the game._ keep track of these wins over the course of the whole game, or based on each user. "
can anyone help me or give me code for how to do any of this? I am rather lost and don't know where to begin- please help! I am still a beginner and would love some step by step how to's thank you!
Passing Random Variables To Called Functions
I'm just getting back into Flash and AS2.0, while totally awesome, has been quite a challenge to learn for someone who dropped out of the industry around Flash 5.
Anyhow, here's my problem. I'm trying to make a menu whose elements randomly scroll up and down the y axis +/- 5-25 or so pixels (estimating that on visual needs), with some Math.random at the fringes.
I'll paste the code I have so far below. My issue is that I want EACH different menu instance that calls the function, or that the function is applied to, to be able to enter a unique random # that alters its movement. In short, I want each to move randomly from each other. It seems, no matter how I try to pass an argument to the function, that the function always operates the same on each menu item, so they move in sync.
I'm sure I'm missing something here, and I'm feeling very green about all this. Any and all help would be appreciated!
Here's the code with nothing being passed to it. I've tried to pass it different variables for each instance, but they all still behave generically. Is there a better way to do this?
mover = function() {
startY = this._y;
this.onEnterFrame = function() {
speed = (Math.random())/2;
myY = this._y;
if (myY <= startY + (Math.random()*5)) {
myToggle = 0;
}else if (myY >= startY + (Math.random()*145)+10) {
myToggle = 1;
}
if (myToggle == 0) {
this._y += speed;
}else if (myToggle == 1) {
this._y -= speed;
}
};
};
myToggle = 0;
mover.call(_root.menuBar_mc.aboutBtn_mc);
mover.call(_root.menuBar_mc.artistsBtn_mc);
mover.call(_root.menuBar_mc.releasesBtn_mc);
mover.call(_root.menuBar_mc.eventsBtn_mc);
mover.call(_root.menuBar_mc.linksBtn_mc);
stop();
Selecting A Random Variable From A List Of Variables
Hello
Im using loadVars to gather variables from a txt file.
The variables are as such - a1, a2, a3 ,a4, ...
Id like to know if its possible/how to pick one of those variables randomly.
I tried constructing the variable name with random operations but it wont acknowledge the result as a variable, it will think its a string.
Random Variables -- Easy Question You, But Driving Me Crazy.
Simple: I'm trying to create a button that plays (not loads) one of several MCs at random. Let's say I have 4 MCs with instance names MC0, MC1, etc. I would think I would do as follows:
on (press){
set ("randNumber", random (4);
_root.MC&"random".gotoAndPlay(2);
}
Besides not working, the code does seem instinctually bad to me, but it must be close. Thanks in advance.
Loading Flash Variables From Text File And Using In Random
In flash 5 I loaded variables from a text file and i can display them in dynamic text fields. (varibles are integers), but I can't do math with them or use in the Random() function. Flash recognises their values as 0. Does any one know how I could do this, thanks.
Random Integer, & Creating & Destroying Data In Variables
Ok, so this is what I have,
RandomHex(c)
generates a random Hex code from 0-F
showing as 0xHexCodeHere
Question 1: I need to destroy the circle after about 4 seconds.. Im not sure how to do that, is there any destroy variable? or can I do
Your_Var = NULL or null;
Question 2: how do I do a random int?
var int_x:Number = Math.random(0,20);
?? to generate random number from 0 - 20?
my function
CreateCircle() should create a circle
And my function move_circles(orb1, orb2, orb3, orb4, orb5)
should call it when Rad[1] is 0 (at the very center point of itself)
this is my code (it doesnt work)
Code:
//main
var main:MovieClip = this.createEmptyMovieClip("main", this.getNextHighestDepth());
main.lineStyle(0, 0x000000, 100);
_global.i = 0;
//orb 1
var orb = Array()
var code = Array()
code[0] = 0xFF0000;
code[1] = 0x00FF00;
code[2] = 0x0000FF;
code[3] = 0xFA0CE3;
code[4] = 0xCCCCCC;
var CircleRadius:Number = 10;
var int_n = 5;
_global.c = int_n;
var int_extra = 1;
var count_down = int_n+1
for (var i:Number=0; i<int_n; i++)
{
orb[i] = new MovieClip();
orb[i] = main.createEmptyMovieClip("orb"+i, main.getNextHighestDepth());
orb[i].lineStyle(count_down*10, code[i], 100);
orb[i]._x = 600;
orb[i]._y = 400;
orb[i].moveTo(CircleRadius, 0);
count_down -= 1
}
for (var i:Number = 0; i<361; i++)
{
var Radius = i*Math.PI/180;
var X = Math.cos(Radius)*(CircleRadius);
var Y = Math.sin(Radius)*(CircleRadius);
var X2:Number = Math.cos(Radius)*(3);
var Y2:Number = Math.sin(Radius)*(3);
for (var n:Number = 0; n<int_n; n++)
{
orb[n].lineTo(X, Y);
}
}
function RandomHex(c)
{
new_code=Array()
for (var i:Number = 0; i<10; i++)
{
new_code[i] = i;
}
new_code[10] = "A";
new_code[11] = "B";
new_code[12] = "C";
new_code[13] = "D";
new_code[14] = "E";
new_code[15] = "F";
c = Math.random(0,15)
}
function CreateCircle()
{
code[_global.c] = "0x"+RandomHex(code[_global.c]);
orb[_global.c] = main.createEmptyMovieClip("orb"+_global.c, main.getNextHighestDepth());
orb[_global.c].lineStyle(5, 0x000000, 100);
orb[_global.c]._x = 600;
orb[_global.c]._y = 400;
orb[_global.c].moveTo(3, 0);
_global.c += 1;
}
function move_circles(orb1, orb2, orb3, orb4, orb5)
{
_global.i += 1;
if (_global.i > 361)
{
_global.i = 0;
}
var Radius = Array();
var Rad = Array();
var X = Array();
var Y = Array();
var orb = Array();
orb[0] = orb1;
orb[1] = orb2;
orb[2] = orb3;
orb[3] = orb4;
orb[4] = orb5;
for (var i:Number = 0; i<5; i++)
{
Radius[i] = (i+1)*10;
Rad[i] = _global.i*Math.PI/5;
X[i] = Math.cos(Rad[i])*(Radius[i]);
Y[i] = Math.sin(Rad[i])*(Radius[i]);
orb[i]._x += X[i];
orb[i]._y += Y[i];
if (Rad[i] = 0)
{
CreateCircle();
}
}
}
setInterval(move_circles, 100, orb[0], orb[1], orb[2], orb[3], orb[4]);
Photogallery Issues - Preloading Movie With Random Image And Variables
hej,
ive been searching everywhere, but coulnd find it,
id like to preload movie loaded into a target MC, but this preloaded movie loads yet additional content, which is random image (an image of a variable size, and the size of the image will be passed on to flash in variables from php script) and a set of variables,
and Im totaly lost, as when i try to load it, the getBytesTotal will be only of the movie size to preload, it will not add up the image to the total size nor, which is obvious, the variables,
how to go around it for my movie not to start playing without all the variables and image having been loaded,
ok,
down to my second question
the whole thing is Im trying to build a photogallery,
after a person hits "PHOTOGRAPHY" link, the list of photogalleries is loaded and displayed into a targetet movieclip, each link to the photogallery would be generally a duplicated MovieClip, which would have a button and variable text inside of it,
what Im thinking of is when the photogalleries variables are loaded into the movie, I dont want the links-duplicated movieclips to appear just all together, but one at a framerate,
each of the links-duplicated movieclips would have a little tween, going from alpha 80 to 100 and than back again to 60, to make a wave-like appearence of the available photogalleries...
hmm.. I hope you understood, what I meant )
so my problem with the second question is, where do I put the
for(i... loop, to make the duplicate movies appear in the manner I described above?
I wrote:
onMovieClip(load) {
//set the i variable
i=1;
}
onMovieClip(enterFrame) {
duplicateMovieClip("blabla", "blabla"+i, i);
// no worries about the rest
i++;
if(i == number_of_photogalleries) {
stop();
}
}
but it somehow didnt want to work...
basicaly, what I want to achive is similar to:
reverence.rayoflight.net
and days of the month appearing on the calendar,
I also recommend to check it out, its a great databasedriven flashsite,
thanks a lot for any help,
Random Random Random Timer... Problems
Heyy guys. I know you guys know this stuff backwards & forwards so maybe you can help.
This is a 2 part problem. Part 1 is Im trying to create a timer that functions at random intervals, the function in this case is playing a MC of a car driving on a freeway in 1 to 10 second intervals to give the feeling of, well, randomness. (I've attatched the .fla file if that'll help).
So it works, but not quite as it will generate intervals only twice before it repeats the second interval over and over. So the car will 'drive' in say, 7 seconds the first time and then it will drive in 3 seconds, then again in 3, and in 3 and in 3 seconds. Ive tested it so much I know its not coinsidence.
Here's the code Im using (located in the freeway MC):
var interval:Number = random(10)+1;
function someCodeToRun() {
_root.freeway.diffcars.drive01.gotoAndPlay(2);
}
setInterval(this, "someCodeToRun", interval*1000);
Part 2 is I also wanted the cars to be different colors, which is why there is a diffcars MC with different frames of cars, but now Im not even sure I was headed in the right direction with that.
Ultimately Id love to have different colored cars driving on the freeway at different intervals. Can anyone figure this out?
PLEASE HELP - URGENT Load Random Swfs From Individual Random Sets
I have two target mcs I would like to load different random swfs into
I have eight folders (a-h), each with 12 swfs (001-012)
I need to load a random swf (001-012) from a random folder (a-h) into the "card1" mc
I have figured out how to specify which one I want:
loadMovie("a/a001.swf","card1")
stop();
however, I need it randomized....
then, I need to load another random swf into my "card2" mc (001-012) from another random folder (a-h, ...except for the folder from which the first swf was loaded)
can somebody please help??????
Random Movie Clips To Play For Random Amount Of Time
hi,
i am loading external movieclips randomly into 4 seperate emptymovies, i now need a way to get these random clips that i am loading to play for a random amount of time and then load the next clip.
i need some help with the code...
how do i get the clips to loop, then assign each a random number and have flash check if the random num is = to current frame...if it is, have that clip stop and a new one load?
i have no idea how to write the code for this
any help would be great
thanks
this is what i was given so far..but don't know what to do with it.
Code:
var rnd = Math.round(Math.random(mc._totalframes));
mc.onEnterFrame = function() {
this._currentframe >= this._parent.rnd ? unloadMovie(this) : null;
}
Script Needed: Random Picture On Random Place By Click
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
Help: Multipule Random Positioned Duplicate Random Movie
Does anyone know a way that i can produce a button that when rolled over will duplicate x amount of movies each with random _x and _y positions? Basically i have a movieclip that will
gotoandPlay(math.Round((math.Random()*10)+1)
which randomises that frame that is played. This instance will then do some form of tweening and then gotoandPlay(1) again. I need a script that will then keep generating more duplicate movie clips whilst a button is moused over. i tried the following
on(mouseover){
i = 0;
rand_num = math.Round((math.Random()*29)+1);
while(i<20) {
duplicateMovieClip(_root.movie, "movie"+i,i);
setProperty("movie"+i, _x, _root.movie._x+(rand_num*5);
setProperty("movie"+i, _y, _root.movie._y+(rand_num*5);
i++
}
}
where movie = movieclip name
but this seems to generate all the clips on top of each other @ different depths. I want movies that are all in different positions. Can you help?
Random Movieclip @ A Random Partly Defined Position
Ok I´ve searched this forum to death but i didn´t REALLY
find the answer to my question! I think it can´t be that
difficult but i´m new to action-script and so i gotta hope
u´ll know the answer :
I´ve got an movie. (uh yeah ^^) in this movie there are
many movieclips that contain animations. now i want these
mcs to appear randomly @ a random position of a few defined
positions.
I really got NO idea how to do this !*prayinforyahelp*
ok thx 8]
Detecting Which Random AttachMovie Loaded From Random Array
I'm building a Freecell type card game. I've got an array that loads all of the cards (actually, the linkage names for each card loaded from the library with attachMovie). I randomize the array before I "deal the cards" onto the stage.
Here's a little code snipet where "deal" starts off equaling 0 and "cardDeck" is the value from my array (for example, c5 equals 5 of Clubs):
Code:
if (deal<52) {
_root.createEmptyMovieClip("card"+deal, deal);
_root["card" + deal].attachMovie(cardDeck[deal],cardDeck[deal],deal);
deal++
}
There's more, of course. My problem is - How can I detect which card loaded into which movie? For example, I know I have a movie called _root.card6 at the bottom of the first column, how can I know what card is loaded into _root.card6?
Movieclip Showen In Random Places At Random Time
How can I make my movieclip appeare in diffirent places at diffirent time? And the movie clip is this flying mobilephones(you can see it in swf http://www.hot.ee/at03/flying-mobs.swf).
Thanx in advance!
Random Rotation To Equal Random Movement Direstion?
k i finally got it so that my things randomly move around the screen and have walls etc etc.. anyways now i wanna know how to make it so that my randomly moving ship will rotate to face there direction if you want i can post the code i am using for random movement and thanks in advance
Load Random Swfs From Two Differnet Random Sources
I am in the process of creating a VS Card game in Flash. It is basically a game where you can choose either one card or another, each randomly pulled from one of the eight different sets. The first card (or swf) can be pulled from any of the 8 sets (out of a total of 12 cards in each set))..and will load into a targetMC, and the second must be pulled randomly from any of the 8 sets except from the folder where the first card was chosen and load onto the second targetMC.
after the winning card is chosen, it will display winning animation (and send data off to a dynamic bargraph program), and then the main movie will reload two random cards from differnt sets.
can anybody help me on how to set this up??
Random Pics In Grid With Random SetInvertval Or Similar
Ok I think my subject makes sense perhaps a link to an example to a site I'm "inspired" by will make more sense http://www.stevenlippman.com/ So I'd love to make a front page like this one anyone like to point me in the right direction?
Random Motion Along Specified Paths At Random Intervals?
I am working on a site right now and I have a collaged background image with a faded ciruit board looking series of intersecting lines.
I would like to create a subtle gradated sphere to simulate a signal travelling along the cicuits. However, I would like several instances of the signal (or pulse) to take different routes and begin and end randomly.
Is there a way to set-up possible routes with a motion guide and then tell objects to randomly choose those routes at random intervals???
Need Code For Random Scenes Not Random Movies
Hi
I need a code for loading random scenes for a flash intro. I have only found a code for loading random movies but I don't want to have to do the preloader for every movies because it would destroy the whole thing on how it loads.
Any help is appreciated.
Thanks!!
Goto Random Frames At Random Times?
hey,
it is basically the title i would like the movie to jump to either frames 8 or 9 at random times. the movie stays on frame 1 unless told to move.
please help
i have MX and i would also like a button to do a similar task except for the random time thing
thanks in advanced
Random Background With Random Text File
I am trying to create a resizable flash file that will act as a background for my html/css website. Within the flash I want to have a script that randomly loads a jpg file from a specific folder on my server as well as a correlating txt file for that background. Here is an example of what I mean.
Say there is a movieclip named "background" and then a dynamic text area named "info" in the lower left-hand corner of the flash movie. I want a script to randomly load a jpg file (say 234.jpg) from a folder named "backgrounds" on the server. I also want it to load the correlating text file into the dynamic text area (234.txt) from a folder named "info". How would I do this and what would the script be?
NOTE: the names of the jpg and txt files would be 1.jpg, 1.txt, 2.jpg, 2.txt, etc.
Thank you for any help you can give!
-- K
Playing A Random Moive At Random Intervals
ello
basic rundown:
i have five movies on the stage that are stopped
i want to play one of the five at random intervals
here is what i knocked up:
Code:
minTime = 1000;
maxTime = 5000;
setInterval(function () {
trace("go bubbles");
_root.bub = "bubbles"+(random(6)+1);
_root.bub.play();
trace(bub);
}, Math.ceil(Math.random()*(maxTime-minTime+1))+(minTime-1));
it outputs random bubbles2, bubbles5 etc to the bub variable (as seen in the trace) but when i try to create a string so it plays the bub variable, it doesnt work.
yes i have the bubble movies labeled
im also not sure if the random interval changes each time, is there a way to do this?
thanks for any help
my priority is for the script to tell a random "bubbles" movie to play
thanks
Random Quotes On Random Spot Flashing
I want to display random quotes from an array and have them fade in at a random spot that fits them inside the flash document, wait for like 2 seconds, fade out, then after like 3 seconds, another one fades in and it keeps repeating over and over. How would I do this? Thanks.
Creating 10 Random Circles With Random Colors
hi folks.
I´m trying to write a simple function: create 10 circles (with random coordinates) and the circles should have random colors.
How can I assign the random colors? Is there an AS function that can help me?
Using Math.random() To Generate 14 Random Cards
I am relatively new to Actionscript and Flash, but not to web development in general. I have made a small matching game of pairs, where you have to find the pairs and remember where the cards where.
You can see the game here: http://www.mrmen.net/flash.php?game=mrmenmatch
I found a tutorial on how to do this and edited as much as I could after having previous knowledge of PHP and Javascript (as Actionscript has the same C style syntax) and made it display how I wanted it to.
However the code reads from a directory of images. I have 80 images in this directory that I want to use, but as there are only 28 squares (therefore only 14 images are used) it takes the first 14 images in the directory and uses them in a random order to place them in different positions. I want it to be able to randomly select 14 of the 81 images in the directory if possible.
I have posted the whole script below, but the part that I am interested in is where it refers to the location of each image ("http://www.mrmen.net/flash/matchImages/...")
Code:
// Gamefield settings
// EDIT HERE
card_w = 100
card_h = 100
card_wdistance = 10
card_hdistance = 10
// STOP EDIT
card_dw = card_w+card_wdistance
card_dh = card_h+card_hdistance
/*row_card = Math.floor((Stage.width-card_wdistance) / card_dw)
col_card = Math.floor((Stage.height-card_hdistance) / card_dh)*/
row_card = 7;
col_card = 4;
n_card = col_card*row_card%2 == 0 ? col_card*row_card : (col_card-1)*row_card
imgs_n = n_card/2
// CENTER THE IMAGE IN THE CARD
centerImage = function(target){
target.front._visible = false
target.front.container._x -= target.front.container._width/2
target.front.container._y -= target.front.container._height/2
}
// ---------------------------------------------
empty = new Array()
function createCard(n,w,h){
empty.push(n)
this.createEmptyMovieClip('card'+n,n)
with(this['card'+n]){
lineStyle(0,0x000000,100)
beginFill(0xFF9900,120)
moveTo(w/2,0)
lineTo(w/2,h/2)
lineTo(-w/2,h/2)
lineTo(-w/2,-h/2)
lineTo(w/2,-h/2)
lineTo(w/2,0)
endFill()
createEmptyMovieClip('front',1)
front.createEmptyMovieClip('container',2)
front.createEmptyMovieClip('backgr',1)
with(front.backgr){
moveTo(-w/2,-h/2)
lineStyle(0,0x000000,0)
beginFill(0x333333,100)
lineTo(w/2,-h/2)
lineTo(w/2,h/2)
lineTo(-w/2,h/2)
lineTo(-w/2,-h/2)
endFill()
}
front.onEnterFrame = function(){
tot = this.container.getBytesTotal()
car = this.container.getBytesLoaded()
if(tot == car && tot > 200){
this._parent._parent.centerImage(this._parent)
delete this.onEnterFrame
}
}
}
}
selcards = []
function placeImages(){
act_img = 1
for(img=0;img<imgs_n;img++){
for(k=0;k<2;k++){
act = Math.round(Math.random()*(empty.length-1))
this['card'+empty[act]].img_id = act_img
this['card'+empty[act]].front.container.loadMovie("http://www.mrmen.net/flash/matchImages/img"+act_img+".gif")
this['card'+empty[act]].onRelease = function(){
this.rotateCard(0,0)
this.enabled = false
MovieClip.prototype.enabled = false
}
empty.splice(act,1)
}
act_img++
}
}
MovieClip.prototype.rotateCard = function(v,i){
this.operazione = v == 0 ? +0.1 : -0.1
this.incremento = i == 0 ? 100 : 10
selcards.push(this._name)
this.onEnterFrame=function(){
this.incremento += this.operazione;
this._xscale = (100*Math.sin(this.incremento));
if(this._xscale > 0){
this.front._visible = v==1 ? false : true
}
if(this._xscale >= 99 ){
delete this.onEnterFrame
selcards.length < 2 ? MovieClip.prototype.enabled = true : null
v==0 && selcards.length > 1 ? checkCards() : null
}
}
}
function generateGameField(cards,distance,hdistance){
Ypos = card_h/2 + hdistance
Xpos = card_w/2 + distance
for(c=0;c<cards;c++){
createCard(c,card_w,card_h)
if(c%row_card==0 && c>0){
Ypos += this['card'+c]._height + hdistance
Xpos = card_w/2 + distance
}
this['card'+c]._x = Xpos
this['card'+c]._y = Ypos
Xpos += this['card'+c]._width + distance
}
placeImages()
}
generateGameField(n_card,card_wdistance,card_hdistance)
playerScore = 0
playerTries = 0
function checkCards(){
if(this[selcards[0]].img_id == this[selcards[1]].img_id){
playerScore++
displayScore.text = playerScore;
eval(selcards[0])._visible = eval(selcards[1])._visible = false
} else {
eval(selcards[0]).rotateCard(1,1)
eval(selcards[1]).rotateCard(1,1)
eval(selcards[0]).enabled = eval(selcards[1]).enabled = true
}
selcards = []
playerTries++
displayTries.text = playerTries;
if(playerScore == 14) {
finishMessage._visible = true;
} else {
MovieClip.prototype.enabled = true
}
}
|