RANDOM DUPLICATE MCs?
I am trying to create the effect of several random boxes, that are very transparent, moving around slowly on the screen - ideally in relation to the users mouse. I am having a lot of trouble however, and the movement often seems to fast. For an example of sort of what I'm talking about check out: http://www.lookandfeel.com, at the bottom of the screen they have these series of lines dynamically moving around.
If I cant get it to go with the mouse, atleast I want to achieve an effect like this. Please Help. Thanks.
Mr. Jengals
FlashKit > Flash Help > Flash ActionScript
Posted on: 07-15-2001, 01:29 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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 And Duplicate Mc
hii to you all
i want to creat a shape that can be MC (with instance) and duplicate it all over the stage in random places. something very simple.. but i dont know how to do it.
thanks
ari -tintoon-
Duplicate Random's
does anyone know a way to get rid of the duplicate random entries that flash tends to create if the random variable is set to a low number? I'm using it to load random images so I need to find a way to eliminate duplicates...
How To Random Xml By Not Duplicate ?
i have XML like this how to random it show by not duplicate until end of record length ???
Quote:
<?xml version="1.0"?>
<!DOCTYPE quiz [
<!ELEMENT quiz (title, items)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT items (item)+>
<!ELEMENT item (question, answer, answer+)>
<!ELEMENT question (#PCDATA)>
<!ELEMENT answer (#PCDATA)>
<!ATTLIST answer correct (y) #IMPLIED>
]>
<quiz>
<title>Trial Quiz</title>
<items>
<item>
<question>____ is a car.</question>
<answer correct="y">This</answer>
<answer>That</answer>
<answer>These</answer>
</item>
<item>
<question>____ is a boy.</question>
<answer correct="y">This</answer>
<answer>Those</answer>
<answer>That</answer>
</item>
<item>
<question>____ is an orange.</question>
<answer correct="y">That</answer>
<answer>Those</answer>
<answer>This</answer>
</item>
<item>
<question>____ is a telephone.</question>
<answer correct="y">That</answer>
<answer>This</answer>
<answer>Those</answer>
</item>
<item>
<question>____ are dogs.</question>
<answer correct="y">These</answer>
<answer>Those</answer>
<answer>This</answer>
</item>
<item>
<question>____are birds.</question>
<answer correct="y">These</answer>
<answer>This</answer>
<answer>Those</answer>
</item>
<item>
<question>____are pencils.</question>
<answer correct="y">These</answer>
<answer>Those</answer>
<answer>This</answer>
</item>
<item>
<question>____are rulers.</question>
<answer correct="y">These</answer>
<answer>This</answer>
<answer>Those</answer>
</item>
<item>
<question>____ are erasers.</question>
<answer correct="y">These</answer>
<answer>Those</answer>
<answer>This</answer>
</item>
<item>
<question>____are boys.</question>
<answer correct="y">These</answer>
<answer>This</answer>
<answer>Those</answer>
</item>
<item>
<question>____are bags.</question>
<answer correct="y">These</answer>
<answer>Those</answer>
<answer>This</answer>
</item>
<item>
<question>____are horses.</question>
<answer correct="y">These</answer>
<answer>This</answer>
<answer>Those</answer>
</item>
</items>
</quiz>
Duplicate MC And Set Random Position
Hi All,
Need some expert help.
I need to duplicate a MC five times, and set its position on the X axis randomly.
Towards this end i used this script:
Code:
duplicateMovieClip ("mark", "mark1", -1);
duplicateMovieClip ("mark1", "mark2", -2);
duplicateMovieClip ("mark2", "mark3", -3);
duplicateMovieClip ("mark3", "mark4", -4);
duplicateMovieClip ("mark4", "mark5", -5);
setProperty ("mark",_x,random (550))
setProperty ("mark1",_x,random (550))
setProperty ("mark2",_x,random (550))
setProperty ("mark3",_x,random (550))
setProperty ("mark4",_x,random (550))
setProperty ("mark5",_x,random (550))
The script works perfectly, but unfortunately, at times the duplicated clips overlap one another. How do I ensure that there will be no overlapping of the clips at all?
Thanks for any inputs
Duplicate And Random Animation
Hi
I have a box (130 wide, 432 high) sitting on the hard left of my page. I want to get the box to populate line by line from the left, so ideally I would have 216 lines (lines are 2 high) zooming in from the left side. So I assume I would use duplicate move clip to save animating so many lines, and I also want the 216 lines to come in at different speeds or times, but eventually all end up as a solid box.
I can duplicate the lines OK
thistimeline = this;
for(i = 1; i<100; i ++){
lined_mc.duplicateMovieClip("lined" + i + "_mc", i, lined_mc)
thistimeline["lined" + i + "_mc"]._y += (i);
But getting them to move like I have described has me stumped...
Any ideas. Thanks.
Random Bits? Duplicate MC?
I'm trying to create an application that will allow the user to fill an area with a variety of materials by dragging a scrollbar. I've got a rough version at:
http://www.designdevelopdeliver.com/pieces.htm
Two problems:
1)I can't mask the duplicate clips. I've masked the layer that the original clip is on, but none of the duplicated clips are masked.
2)And the BIG one, I need the slider to fill the circle with randomly SHAPED portions of the movie clip and I can't figure out how to randomly shape the pieces...any ideas???
TIA...
Help - Duplicate And Random Placement
Hi,
Im trying to get the correct syntax for this...,
Could anyone help....deadline looms ahead for me.
Basically a bubble mc called bbl_1 on the root timeline gotta be duplicated in random _x positions while the _y coordinate stays the same. It duplicates allright but, no random positioning.
The code:
onClipEvent (mouseDown) {
_root.main.bbl_1.duplicateMovieClip("bbl_"+"x", x);
_root.main["bbl_"+x]._x=random(400);
x++;
}
HELP please!
Random+duplicate+width.. Help Please?
hi.. i have a little problem with a script i found...
PHP Code:
for (i=0; i<30; i++) {
newBall = mask_mc.duplicateMovieClip("mask_mc"+i, i);
newBall._x = Math.random*600;
newBall.targX = Math.random()*600;
newBall.i = 0;
newBall.rand = Math.random()*50;
newBall.onEnterFrame = function() {
this.i++;
if (this.i>this.rand) {
this.targX = Math.random()*600;
this.i = 0;
this.rand = Math.random()*50;
}
this._x -= (this._x-this.targX)/5;
};
}
Problem is this does'nt seem to work in a mc with a mask.. it works i know that cos if i unmask my layer it starts perfectly but as soon as i make the layer mask again it stops working....
how come and how do i fix this?
Ps, and wile your at it.. how do i add a random width section to this script?
Random No Duplicate Pics
I'm using a slideshow in this site gallery but I want to integrate a random to display. How to make a random display without any duplicate pics??
ex: I have 5 pics in xml file, then they inserted in an array. From there, i want to display them randomly without any duplication
thanks in advance
Using A Loop To Duplicate And Random X Pos
Hi people, got some code working to duplicate a movieclip, but what I'd really like to do is obviously randomise the movieclip's x position so that it spreads across the stage, rather than stacking in the same position as it is now. Any clues greatly apprciated
julie
x
Code:
for (i=1; i<11; i++){
duplicateMovieClip("alien", "alien_new_"+i, 22-10, i);
}
[FlashCS3-AS2] Duplicate Mc, Random _y Help
Greetings - I've been prowling and found a start for what I'm trying to do. Need help refining it. I pilfered the snowconfetti.fla AS and have modified it, but not quite there.
I want to attach a MC at a random _y location, and move it left to right across the stage, at random speeds. Then when it goes offstage, a new one is generated.
Right now the interval loads a new clip at 8 sec. no matter where the current clip resides on stage, so I'm sure that is wrong.
Code:
function brand() {
clip = attachMovie("brand_mc", "brand"+i, i);
clip._x = -50;
clip._y = Math.floor(Math.random()*640);
clip.xspeed = Math.random()*4-1;
clip.onEnterFrame = move;
i++;
if(i > 20){
clearInterval(myInterval);
}
}
function move() {
this._x += this.xspeed;
if (this._x>1100) {
this.removeMovieClip();
brand();
}
}
myInterval = setInterval(brand, 8000);
Thanks much for the help!
Random+duplicate+width.. Help Please?
hi.. i have a little problem with a script i found...
PHP Code:
for (i=0; i<30; i++) {
newBall = mask_mc.duplicateMovieClip("mask_mc"+i, i);
newBall._x = Math.random*600;
newBall.targX = Math.random()*600;
newBall.i = 0;
newBall.rand = Math.random()*50;
newBall.onEnterFrame = function() {
this.i++;
if (this.i>this.rand) {
this.targX = Math.random()*600;
this.i = 0;
this.rand = Math.random()*50;
}
this._x -= (this._x-this.targX)/5;
};
}
Problem is this does'nt seem to work in a mc with a mask.. it works i know that cos if i unmask my layer it starts perfectly but as soon as i make the layer mask again it stops working....
how come and how do i fix this?
Ps, and wile your at it.. how do i add a random width section to this script?
Duplicate Random Numbers
I am loading random images into 3 different blank MCs. I've got the randomization down, but I was wondering, how can I check to make sure that the 3 random numbers aren't the same? I could simply divide the images up into different names or folders and that way I know the 3 random images wouldn't be the same image, but how could I do it with actionscript?
ActionScript Code:
num = random(36)+1;
num2 = random(36)+1;
num3 = random(36)+1;
loadMovie("sidebar/image"+num+".jpg", "_root.image1.loadit");
loadMovie("sidebar/image"+num2+".jpg", "_root.image2.loadit");
loadMovie("sidebar/image"+num3+".jpg", "_root.image3.loadit");
stop();
Duplicate Random Numbers (preventing)
Sorry for yet another thread..........I seem to have planned a large scripting game before knowing my full coding.........
Anyhow......
I have a dynamic textbox named "Output" that displays random quotes. These are chosen randomly and that all works fine. My problem comes when the same quote is randomly chosen...........it overwrites the quote in "Output" and as a result, turns the text invisible.............I think this is down to an overwriting issue that turns same colour pixels white !?!
Anyhow, I tried code to choose a different number so as to try and prevent this issue yet it isn't functioning. Can anyone enlighten me as to what I'm doing wrong, or if there's a better/safer method of achieving this.
Basically I don't want the same quote printed twice in a row.
My code from frame 1: (Where "Correct" is an array with quotes duly allocated)
----------------------------------
quotenumber = Math.ceil(Math.random() * Correct.length);
-------------------------------------------------------
My code from frame 2:
-------------------------------------
_root.TempQuote = Correct[quotenumber];
if (_root.TempQuote == _root.LastQuote){
gotoAndPlay(1);
}
else {
_root.LastQuote = Correct[quotenumber];
Output = Correct[quotenumber];
GoodPlay.attachSound(GoodSounds[quotenumber]);
GoodPlay.start(0, 1);
TotalScore = TotalScore + 1;
}
-----------------------------------------------
Any ideas ?
Array And Duplicate Random Pictures
hi there all, hope someone can help,
i am displaying random pictures in a movie. each time the
user clicks a square on the screen an image/movieclip appears.
my problem is that at the moment 2 or more of the same image/movieclip
can appear on the screen at the same time and i do not want
that.
i have tried adding each number representing the random
movie to an array and then doing a check to see if that number exists in the array. if it does exists this means the image/movieclip
is already displayed on the screen so do not show it and generate
a new number and so forth. i am receiving all the necessary
values perfectly.
my code to do the check is as follows :
i = 0;
_root.myArrayPhoto.push(randMov);
outerArraylength = _root.myArrayPhoto.length;
for(i=0; i <= outerArraylength; i++) {
if ((_root.myArrayPhoto[i] == randMov)) { //check if movie exists
gotoAndPlay(1);//goto first frame and to random func again
}
}
//else loop finished so
//movieclip does not on screen so show it :
loadMovie "swf/photo"+randMov+".swf", "_root."+_root.thisWhich);
gotoAndPlay(1); //goto first frame and start again
thanks!
Duplicate, Random Placement With Easing
doesn someone know how to recreate the initial load of the rectangles that this site uses?
http://www.ag.raise-media.com/and_gaiv.htm
i took a shot at it from scratch and its not working out
ActionScript Code:
div = 4;
i = 0;
while (i<20) {
duplicateMovieClip("clip", "clip"+i, i);
endX = random(400);
endY = random(400);
_root["clip"+i].onEnterFrame = function() {
this._x += (endX-this._x)/div;
this._y += (endY-this._y)/div;
};
i++;
}
it appears as the every single duplicate of "clip" is receiving the same x and y coords and i dont know how to assign separate x,y to each individual clip
i could be going about it all wrong so if someone has another solution it would be greatly appreciated.
thanks
-a
Duplicate By Random And Remain On Stage
Hi,
I got a project containing 4 movieclips to be duplicated by random and placed on a certain position on stage.
all movieclips are placed on top of on another.
the problem is: already placed movieclips don't remain on stage - they get replaced by the next movieclip duplicated in.
How can I make the already placed clips stay on the stage?
Please review to my attachement.
Thanx guys, you are my last resort!
MC Duplicate With Random Location In Set Range
Hey all!
Im having a bit of a problem with duplicating a movieclip.
Im an AS noobie, so dont kill me for stupid mistakes lol.
Heres what im trying to do:
I have a button, when the <Insert> key is pressed and if the variable money at root is higher or equal, then make the variable "vpill" equals 1 and duplicate the MC "pill".
Heres the code i have for that:
Code:
on (keyPress "<Insert>"){
if (_root.money >= 1000){
_root.vpill = 1;
_root.money -= 1000;
duplicateMovieClip(_root.pill, "pill"+1, _root.pill);
}
}
As for the MC "pill", what i want is if the variable "vpill" equals 1 then at a random location (in a set range), place the mc, and if hitTest is true with "player" then _root.speed -= 1; make "vpill" equal 0 and remove the duplicated MC.
Heres the code i have on "pill" MC:
Code:
onClipEvent (load) {
randomNum=function(Minimum,Maximum){
return Minimum+Math.random()*(Maximum-Minimum);
}
if (_root.vpill == 1) {
pillx = randomNum(220, 480);
pilly = randomNum(70, 330);
this._x = pillx;
this._y = pilly;
if (this, hitTest(_root.player)) {
_root.speed -= 1;
this.removeMovieClip();
_root.vpill == 0;
}
}
}
NOTE: Variables are all placed in the root.
Thx in advance!
If u dont understand something, feel free to ask. THX!
Duplicate By Random And Remain On Stage
Hi,
I got a project containing 4 movieclips to be duplicated by random and placed on a certain position on stage.
all movieclips are placed on top of on another.
the problem is: already placed movieclips don't remain on stage - they get replaced by the next movieclip duplicated in.
How can I make the already placed clips stay on the stage?
Please review to my attachement.
Thanx guys, you are my last resort!
AS2 Random Swf Load - Remove Duplicate
Hi,
I have a banner movie that Im loading a random swf into. When this has finished playing i want to load another random swf in its place. This is working fine other than I am occationally getting the same swf twice in a row.
Can I check if the swf was just loaded and, if so, get another random swf?
I thought I could use something like this but is still has duplicates (maybe because the second random number is the same as the first?)
Code:
// Sets the number of images in the random sequence
var myImageSequence = 6;
var oldmyRandomNumber = myRandomNumber;
// Creates a random number:
var myRandomNumber = Math.floor(Math.random()*myImageSequence)+1;
// Check what last number was
if (myRandomNumber == oldmyRandomNumber) {
var myRandomNumber = Math.floor(Math.random()*myImageSequence)+1;
}
var myImageName = "slides/" + myRandomNumber + ".swf";
// Loads the random swf:
loadMovie(myImageName, this.empty_holder.empty);
Any pointers?
DUPLICATE,ANIMATE,ALPHA,SIZE All Random
How do I make a movie clip duplicate 50 times on a stage of 800x600 and animate each randomly on the stage, each starting from on point and all spreading randomly across the stage togather.. Also each movie clip should scale to 1% and the alpha sholud fade out to 0%....phew...
and can anyone give me the script for this in Flash 4.0
very very urgent...
Thanks in advance
Duplicate Mc Movement/random Start Times
I've got an mc of a animal that i'm using in the background of a site. at the moment 5 of these mc's move across the screen inside another mc, using this code on the mc:
Code:
onClipEvent (load) {
//set initial x pos of clip
this._x = 0;
}
onClipEvent(enterFrame){
//this moves our clip 1 pixel to the right every frame
//up to a certain point
if (this._x<670)
{
this._x+=0.08;
}
if(this._x == 670){
wait+=1;
// Wait 100 frames before resetting things
if(wait>100){
//Reset actions here
wait=1;
this._x = 0;
}
}
}
This is all good but the 5 animals all walk in tandem which gives an unnatural look to it all. I was thinking that it would be better to just have one mc and duplicate this where needed. a random number between 2 and 5 could be chosen and this number of animals would move across the screen having all started at random times (but within confines so that they still move as a group. i would also want the delay to remain so that the effect remains subtle.
Any hints on the actionscript would be much appreciated.
Thanks.
A For Loop With Random Vairalbes - How Not To Get Duplicate Results
Hey All, I have a loop that runs through 5 times and each time calls a function that puts two variables together randomly:
CODE:
myname = [];
for (i=0; i<4; i++) {
createRandomName();
trace(diarytextvar);
myname[i] = randomname;
trace(myname[i]);
}
randomname is a random match of two variables (ie., ShortDog, CrazyChicken, etc.). How can I check if a duplicate has occured and if so run the function again. So that each of my variables (myname0, myname1, myname2, myname3, myname4) are not duplicates?
Thanks in advance, Dvl
Getting Duplicate Item From Range Of Random Numbers
hi everyone,
Im trying to create a list random numbers from 1-30 but only 10 will appear. but i also need to make sure that the list of random numbers will not have duplicates (eg 1,1,20,14,3,28,4,1,18,21). I had the thought of using an array to store the list of numbers but im stuck with how to properly use an if..then to check if the same number has already appeared.
Sorry if this was asked before but im just really confused with how to extract the contents of the array and see if one of them already appeared. I've attached the code so anyone can see what went wrong with it.
Anyone's help is greatly appreciated. Thanks everyone!
_scriptRookie
Code:
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
var myArray:Array = new Array();
for (var i = 0; i<9; i++) {
var n:Number = randRange(1, 30);
trace(n);
myArray.push(n);
for (var j = 0; j<myArray.length; j++) {
if (myArray[j] == n) {
myArray.pop();
var n:Number = randRange(1, 30);
}
trace(">> "+myArray[j]);
}
}
Duplicate Grid Of MovieClips With Random Starting Times
Need a bit of help here, if anyone can show me the right path?
I need to create a regular grid of movieclips using duplicatemovieclip, which cover the screen. let's say, an animated square that fades from white to black. I then need these movieClips to start at random times so that the eventual state is of the whole screen with a grid of black squares. Kind of like asped up film of lights going out on a skyscaper. Sort of.
Any ideas?
cheers people...
Duplicate Movieclip, Drag Duplicate, Leave Original Behind
Hello all,
I have been searching frantically for an answer to this. I know it has to be easy....
I want to duplicate a movieclip on press and also drag the duplicate, leaving the original behind. I've attached a sample of what I'm doing. Does anyone have any ideas? Is there a way to target the duplicated movieclip to drag that? And leave the original in it's original location?
Any help, guidance, nudging would be greatly appreciated. I've been trying to figure this out for hours.
Thanks,
jessicuh
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?
"Duplicate Scene" Does NOT Duplicate
I just erased a month's worth of work because Macromedia has a funny definition for "duplicate."
I have different scenes which will make up my movie. I build one. it has certain characteristics I want the other scenes to include. So I duplicate the first one, rename it, then make my changes. Straightforward, right? Only, duplicate actually seems to duplicate and link or attach the original and the copy. It does not make a copy, a separate and distinct scene!!!! SO I go back to my first scene, and everything is gone, because it's mysteriously linked or a clone or something of the one I just created (the copy). It's like you have two instances of the scene, and editing either one affects the other. It wasn't so in F5.
What the #$@$*%?!!
Can anyone explain?
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
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
}
}
Has Anyone Tested How Random Is The Math.Random() Function?
Just wondering whether anyone out there has ever run any tests on how random the Math.Random() function is as a random number generator?
I've been asked me to test it to prove that it is random and it seems a pointless waste of time, so I'm hoping to get evidence from elsewhere to convince the powers that be that there's no need to run the tests.
I've googled for it but come up with nothing so I'm hoping there might be someone out there who has already done the research?
Math.random With Non-repeating Random Choices
I'm trying to create a puzzle game wherein pieces pop up randomly, but each piece will pop up randomly only once. The code I've used to start is:
ActionScript Code:
pics.gotoAndStop(Math.floor(Math.random()*4));
where I've placed a movie clip containing all of the pieces on the main timeline and named it "pics".
How can I make it such that each piece is eliminated from random pick once it has been picked?
|