reference textfield on timeline
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: reference textfield on timeline

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    33

    reference textfield on timeline

    In de Flash IDE I create this movieclip 'MC1' and assign class MC1.as to it.

    On the timeline, I add a textfield 'TF1'.

    Now, in MC1.as I can change the textfield easily: TF1.text = 'text here'.

    This works perfectly and I should not complain... however;

    Is there a way I can tell my class MC1.as that there is a TF1 that is a textfield? So I can use codehinting?

    If I add

    Code:
     var TF1:TextField;
    the reference to the textfield is lost and now NULL. So that does not work.

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    You can create a variable for it but you'll hit the code-before-stage problem. Basically your class constructor can be run at "frame -1" so that everything is set up properly before everything is added into the display list...to work around that you need to wait until the display items are all added before you grab the reference to the textfield.


    PHP Code:
    public var TF1:TextField;

    //  constructor
    public function MC1(){
        
    addEventListener(Event.ADDED_TO_STAGE, function(e:Event):void{
            
    removeEventListener(Event.ADDED_TO_STAGEarguments.callee);
            
    TF1 TextField(getChildByName('TF1'));
        });


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

Poll by Flashkit.com