|
-
As2 cs4: control number of objects falling at the same time
Hi
I've got the following I've been trying to do (however with no luck )
I have a fixed amount of words. Lets say 20 words.
I want each of these words to be put into symbols - so i have 20 symbols (box1...box20).
Now i want the boxes to fall from the top of the screen and until they reach below the screen. But (and this is where i'm lost) I want to have them fall at different speeds AND I want to control how many boxes falls at a time. Starting out with one box and when this box is out of the screen I want to control the amount of boxes/symbols entering the screen next.
A function telling that next there should be i.e. three boxes entering and falling/floating across the screen (from just above the top of the screen untill they all have reached the bottom). And i want to be able to call a function which starts X boxes - even before the existing boxes in the scenes has dropped).
It would be nice to have a function, ie. fallBox(3) , which may be called at any time.
I will appreciate any help.
Cheers
-
Prid - Outing
Don't know if this is what you want, but make a box, turn it into a movieclip, and delete/remove it from stage. Open Library (CTRL+L) and locate your newly created movieclip, right-click, click on Properties... (or Linkage in Flash 8), tick/check Export for ActionScript, and in the Identifier field, type in box - and press OK. Then, use this code on your frame:
Actionscript Code:
fallBox(100);
function fallBox(num){ for(i=0;i<num;i++){ X = (Math.random()*Stage.width-20)+10; _speed = (Math.random()*10)+2; depth = getNextHighestDepth(); attachMovie("box", "box"+depth, depth, {_x:X, _y:-10}); fallDown(this["box"+depth], _speed); } }
function fallDown(mc, speed){ mc.onEnterFrame = function(){ mc._y += speed; if(mc._y > Stage.height+mc._height){ unloadMovie(mc); delete mc.onEnterFrame; } } }
And as you can see by the first code, you can use a function to call a desired number of boxes with different X coordinate and speed!
DOWNLOAD EXAMPLE FLA FILE
Hope it helps
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
I am very grateful! Thanks a lot.
-
Prid - Outing
So it helped?!?! I thought you wanted something else, lol xD
No problem
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
I did, but I was able to change your code a bit to fit my needs
-
Prid - Outing
Great
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|