I'm afraid mike but you're wrong.
The MovieClip.onRelease handler doesn't pass any parameter...
From the help files : MovieClip.onRelease = function() {}
What Jeff could do is using a Delegate alternative class that allows him to pass parameters to the handler, but he can also link his button movieclips to a class that would dispatch events:


class MenuButton extends MovieClip {

  // EventDispatcher mix-in functions here

  public function MenuButton(){
    EventDispatcher.initialize(this);
  }

  public function onRelease():Void {
    dispatchEvent({type:"click", target:this});
  }

}


class Menu extends MovieClip {

  private var btn1:MenuButton
  private var btn2:MenuButton

  public function Menu(){
    btn1.addEventListener("click", Delegate.create(this, onMenuRelease);
    btn2.addEventListener("click", Delegate.create(this, onMenuRelease);
  }

  private function handleEvent(event:Object):Void {
    if (event.target == btn1) {
      // do some stuff...
      btn1.enabled = false;
      btn2.enabled = true;
    }

    if (event.target == btn2) {
      // do some stuff...
      btn2.enabled = false;
      btn1.enabled = true;
    }
  }
}



mike cann a écrit :
ummm correct me if im wrong but onRelease you are passed an event object
that contains the target of the event?

so:

funciton addChild( txt:String ):Void
{
 // make new mc, with a text field and set the txt
 myNewMc.onRelease = Delegate( this, onMenuRelease );
{

function onMenuRelease( event:Object):Void
{
   event.target.myPropertyOfmyNewMc = somevalue;
}

I could be wrong however...

Mike

On 09/06/06, Jeff Jonez <[EMAIL PROTECTED]> wrote:

This is exactly what I was looking for, cheers Mark and Morten!
> >   myNewMc.onRelease = Delegate( this, onMenuRelease, myNewMc );

Previously, I kept a reference to my class in mc variable, which
wasn't so bad codewise... not sure if there are other side effects to
doing that.

Re: Matt
> can you not add your children in a loop?

The children or menu items are added and removed dynamically by
calling add/remove child ( and then I animate them on and off) from
some other class that wants to use the menu
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

_______________________________________________
Flashcoders@chattyfig.figleaf.com
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