Copy link to clipboard
Copied
Hi,
I am working on a simple video game in which I need to move 50+ symbols across the stage with the same speed. I would like to use a single as3 command with which I can target all symbols at the same time. Currently I have added the symbols one by one:
Code snippets for moving symbols to the right:
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_3);stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_3); function fl_MoveInDirectionOfKey_3(event:Event) { if (rightPressed) { mc1.x = 5; mc2.x = 5; mc3.x = 5; mc4.x = 5; and so on...., }
What can I do to apply the function to all mc symbols in one go?
Thank you!
Copy link to clipboard
Copied
Did you mean: mc1.x = mc1.x+5;?
That aside, if you are making the movieclips with code you could add them to a container movieclip, and then jusst move the container each frame.
If the objects are supposed to loop, that would make it a bit harder, but you could have two container movieclips that are copies of each other, and as the leftmost inner movieclip goes off the right of the screen, you would move that container straight to the left of the screen minus the width of the container.
Copy link to clipboard
Copied
Hi,
thank you. yes, I meant:
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_3);stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_3); function fl_MoveInDirectionOfKey_3(event:Event) { if (rightPressed) { mc1.x = +5; mc2.x = +5; mc3.x = +5; mc4.x = +5; and so on...., }
I have not creating the symbols with code. They are animated symbolds that I have designed in adobe animate.
How would I go about adding them to a container?
Thank you.
Copy link to clipboard
Copied