Skip to main content
Participant
April 9, 2013
Question

AS2 to AS3 convertion

  • April 9, 2013
  • 1 reply
  • 566 views

Hi , I'm new to AS3 and facing some problems on the AS3 scripting. Could anyone out there please help? Your help is much appreaciated. 😃

//create balloons

var numB:Number = 10;

var balloonsCount:Number = 0;

function createBalloons():Void

{

 

          duplicateMovieClip(balloons,"ball",balloonsCount);

          balloonsCount++;

}

for (var i:Number = 0; i < numB; i++)

{

          createBalloons();

}

//create confetti

var numConf:Number = 100;

var confCount:Number = 0;

function createConfetti():Void

{

 

          duplicateMovieClip(conf,"confetti",confCount);

          confCount++;

}

for (var i:Number = 0; i < numConf; i++)

{

          createConfetti();

}

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
April 9, 2013

AS3 does not have an equivalent of the AS2 duplicateMovieClip function.  What you can do instead is create MovieClips and assign them a Class Name in the library (right click in the library and select Linkage).

Then, say you were to name the balloons class Balloon... to create new instances you can use...

function createBalloons():Void

{

          var balloon:Ballons = new Balloon();

          addChild(balloon)

          balloonsCount++;

}

April 9, 2013

Ned's got it. I would just make one suggestion:

function createBalloons():Void

{

          var balloon:MovieClip = new Balloon();

          addChild(balloon)

          balloonsCount++;

}

Ned had the balloon type as Balloons, but I sugegst keeping it MovieClip because it keeps it clear what it is. Just a preference of mine really, but when you start getting bitmapData, sounds, movieClips and such, keeping the base type makes things much more readable and easy to follow.