How to add parameters in the constructor of a class A, subclassing Movieclip, present on stage at design time

There is a library component represented by Class A. But constructor of this class requires some parameters. When the component needs to be added dynamically, it's fine because of code :

var abc:A = new A(param1,param2)

But what if my movieclip is already present on the stage. I notice it gives out error, that the parameters are null.

Is their any way to insert constructor parameters for movieclips already on stage.



Vishwas, any symbols on the stage have already been instantiated. You cannot call their constructor again. Instead, try writing a public function in those classes that sets up the variables that you need. Internally, if those variables are not set, you can toggle the visibility to false and wait, or just not process anything. Once they are set, your clips are off and running again.

Then, in addition to calling the public function on the clips on the stage, you can add optional parameters to the constructor for those instances you'll create via code, not the Flash IDE. If the parameters exist in the constructor, just go ahead and call the function right there.

public function Constructor ( var1:String = '', var2:MovieClip = null) {
    if (var1 && var2) init (var1, var2);

public function init (var1:String, var2:MovieClip) {

Need Your Help

Getting user login and logout information in AWS CloudTrail

logging amazon-web-services amazon-iam amazon-cloudtrail

I have enabled CloudTrail using the AWS Management Console and the Amazon S3 Bucket policies are the defaults ones that are created automatically when enabling CloudTrail.