Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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++;
}
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now