Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS2 to AS3 convertion

New Here ,
Apr 08, 2013 Apr 08, 2013

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();

}

TOPICS
ActionScript
542
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2013 Apr 08, 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++;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 09, 2013 Apr 09, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines