A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: setting vars in instantiated mc's

Threaded View

  1. #1
    Senior Member
    Join Date
    Feb 2000
    Posts
    226

    setting vars in instantiated mc's

    Hi,

    I use this to create new instances of a movieclip:

    Code:
    var myOnStageClip:MovieClip = this.text_mc;
    var myLinkage:Class = Class(getDefinitionByName(getQualifiedClassName(myOnStageClip)));
    var myDuplicateClip:MovieClip = new myLinkage();
    Setting properties of components inside this mc works fine:

    Code:
    myDuplicateClip.text1.text = "something";
    However there are some vars in this mc on the the first frame, something like:

    var myurl:String;

    When I set this var in the code after the mc is duplicated:

    Code:
    var myOnStageClip:MovieClip = this.text_mc;
    var myLinkage:Class = Class(getDefinitionByName(getQualifiedClassName(myOnStageClip)));
    var myDuplicateClip:MovieClip = new myLinkage();
    
    myDuplicateClip.text1.text = "something";
    
    myDuplicateClip.myurl = "http://www......";
    trace(myDuplicateClip.myurl) returns the contents of the var correctly.

    However, when duplicating the movie clip, another movie clip is also duplicated with a var referencing the first duplicated movie clip:

    Code:
    var myOnStageClip1:MovieClip = this.drag_mc;
    var myLinkage1:Class = Class(getDefinitionByName(getQualifiedClassName(myOnStageClip1)));
    var myDuplicateClip1:MovieClip = new myLinkage1();
    
    myDuplicateClip1.source_mc = myDuplicateClip;
    The second movieclip has an eventlistner:
    Code:
    function MouseDown(event:MouseEvent):void{
        trace("url" + source_mc.myurl + "   " + source_mc.text1.text);
    }
    The trace comment outputs:
    Code:
    url: something
    The var myurl in souce_mc is empty!

    I hope I have explained the problem clearly. Does anyone have an idea of what is going on here?

    Thanks,
    Raoul
    Last edited by raoul; 10-29-2010 at 09:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center