Alexander,
You're right, this problem is very well known one. One solution is to nest the TextField in a MovieClip, and use that clip in your button movieclip instead of the TextField.
So you would use the path : MyButton -> label_mc -> label_txt

class MyButton extends MovieClip {
  private var label_mc:MovieClip;

  public function setText(str:String):Void {
   label_mc.label_txt.text = str;
  }
}

You might create a class MyTextField to add even more control to your label textfield and to reuse it everywhere :-)

Another solution would be to simulate the _up, _over and _down effects with code and only 1 frame in your button clip:

class MyButton extends MovieClip {
  private var label_txt:TextField;

  public function setText(str:String):Void {
    label_txt.text = str;
  }

  public function onRollOver():Void {
  }

  public function onRollOut():Void {
  }

  public funtion onPress():Void {
    this._x += 10;
    this._y += 10;
  }

  public function onReleaseOutside():Void {
  }

  public function onRelease():Void {
    this._x -= 10;
    this._y -= 10;
  }

}

Hope it helps :)

Julien

Alexander Farber a écrit :
Hello,

I'm trying to create an MC which acts as a Button
and additionally has a text label on the top of it.

For that I have created 3 Frames: _up, _over, _down
and a dummy onRelease() method. This works ok.

I have also a TextField my_txt on the top of my MC
and a method setText(str:String) to set its content.

When I have my_txt in one big frame extending
over _up, _over and _down everything works fine.

But to create the illusion of the button being clicked,
I have to insert a keyframe at the _down and move
my_txt  10 pixels to the right and to the south.

After I do that, the value of my_txt.text gets lost,
even though the name of the instance is still my_txt.

Does anybody have an idea how to workaround
this (probably frequent) problem? Here is my code:

   http://preferans.de/lobby/

And I paste it here too for your convenience:

   class MyButton extends MovieClip {
        private var my_txt:TextField;
public function setText(str:String):Void {
                my_txt.text = str;
        }
public function onRelease() {
            trace('Override me!');
        }
   }

And in the Actions Layer at the main Timeline:

   my_mc.setText('Hello');

Regards
Alex


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to