A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: target objects created dynamically in library items

  1. #1
    Senior Member
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    326

    target objects created dynamically in library items

    In my library I've got a movie clip. Completely empty, just containing this code:

    Code:
    var myText:TextField = new TextField;
    addChild(myText);
    myText.text="old text"
    Then from the main timeline I add this library movie clip which places it on the main stage and the text appears

    Code:
    var Clippy:textfieldpadding = new textfieldpadding();
    addChild(Clippy);
    But now I want to change the text of that textfield. Which is inside the just placed library movie clip. But this gives an error:

    Code:
    var Clippy:textfieldpadding = new textfieldpadding();
    addChild(Clippy);
    Clippy.myText.text="new text"
    Cause it has no clue what 'myText' is from the main timeline.

    How can I target a textfield, or any other object when it is all dynamically generated and as a movieclip inside the library?

    Illustration | Animation | Web Banners | Graphic Design
    Ducklord Studio

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Timing issue...

    Code on clip
    Code:
    var myText:TextField = new TextField();
    myText.name = "myText";
    addChild(myText);
    myText.text = "old text";
    dispatchEvent(new Event (Event.INIT));
    Code on main timeline
    Code:
    var Clippy:textfieldpadding = new textfieldpadding();
    Clippy.addEventListener(Event.INIT,doText,false,0,true);
    addChild(Clippy);
    
    function doText($e:Event=null):void {
            Clippy.myText.text = "new text";
    }

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