You also may want to avveride the clone method in the custom event class:
/**
* @private
*/
override public function clone():Event
{
return new RemoteClick(type, bubbles, cancelable);
}
- just omit the arguments if you are not using any
Cheers,
Claudiu
----- Original Message ----
From: shaun <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, October 17, 2008 6:23:59 AM
Subject: Re: [flexcoders] Custom event - Create, dispatch, and listen to.
Hi,
Class names should begin with an Uppercase letter. RemoteClick not
remoteClick.
The type String can be lowercase if you want..
Something like the following..
package modulecode
{
import flash.events. Event;
public static const remoteClick: String="remoteCl ick";
public class RemoteClick extends Event
{
public function RemoteClick( type:String= "remoteClick" ,
bubbles:Boolean= false,
cancelable:Boolean= false)
{
super(type, bubbles, cancelable);
}
}
}
//Some component that dispatches and handles RemoteClick events
<MyCanvas>
<script>
public function handleButtonClick( ):void{
var eventObj:RemoteClic k = new RemoteClick( ); //no bubble
dispatchEvent( eventObj) ;
}
public function handleRemoteClickEv ent(e:RemoteClic k):void{
trace("handleRemote Click: "+e);
}
public function init():void{
addEventListener( "remoteClick" , handleRemoteClickEv ent);
}
</script>
<mx:FormItem label="" textAlign="right" >
<mx:Button label="Run" click="handleButton Click()" id="run"/>
</mx:FormItem>
</MyCanvas>
Or....
//Some component that dispatches RemoteClick events. NOTE : the name of
the event and the type.
<MyCanvas2>
<mx:Metadata>
[Event(name= "remoteClick" , type="modulecode. RemoteClick" )]
</mx:Metadata>
<script>
public function handleButtonClick( ):void{
var eventObj:RemoteClic k = new RemoteClick( ); //no bubble
dispatchEvent( eventObj) ;
}
</script>
<mx:FormItem label="" textAlign="right" >
<mx:Button label="Run" click="handleButton Click()" id="run"/>
</mx:FormItem>
</MyCanvas2>
Use MyCanvas2 in another component..
<ACanvas>
<script>
function handleRemoteClick( e:RemoteClick) :void{ ... }
</script>
<MyCanvas2 remoteClick= "handleRemoteCli ck(event) " ... />
</ACanvas>
HTH.
- shaun
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com