Skip to main content
Participant
April 20, 2022
Answered

Is it possible to duplicate objects through actionscript?

  • April 20, 2022
  • 1 reply
  • 369 views

I'm making a bullet hell but i've encountered a slight problem, I can't use just one sprite for everything and manually animating each attack would be way too time-consuming, Is it possible for symbols to be duplicated through actionscript?

 

The example here is what i know how to do, being the use of a single object on loop in a set path.

                      

 

But what i need is for a single stationary object to be able to create duplicates of itself when a function is called, then have those clones do a desired action or go on a set path. As shown below.

 

This topic has been closed for replies.
Correct answer kglad

make your bullet a movieclip

assign a linkage id (ie, class name), eg Bullet_mc.  if you don't need it to have any properties/methods, let animate create the class for you, but youi might want to remove the bullets (from the display list and ready them for gc) when they're not visible.

 

either way, you can use:

 

var bullet1:Bullet_mc = new Bullet_mc();  // to create a bullet instance

addChild(bullet1); to add it to stage

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 20, 2022

make your bullet a movieclip

assign a linkage id (ie, class name), eg Bullet_mc.  if you don't need it to have any properties/methods, let animate create the class for you, but youi might want to remove the bullets (from the display list and ready them for gc) when they're not visible.

 

either way, you can use:

 

var bullet1:Bullet_mc = new Bullet_mc();  // to create a bullet instance

addChild(bullet1); to add it to stage