There is a chapter in the Creating Components book on this topic:
 
http://livedocs.macromedia.com/flex/2/docs/00001640.html
 
Stephen

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of John C. Bland II
Sent: Thursday, December 14, 2006 11:02 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Creating Events



Here is a custom event class. Just change LevelEvent to whatever you
want and the public var level to whatever custom data you want/need.
But...you only need this if you need to pass some sort of data with your
event. You could easily do dispatchEvent(new Event("myEventName")) and
it'll work fine. 
 
package events{
 import flash.events.Event;
 public class LevelEvent extends Event{
  public var level:Object;
  public function LevelEvent(level:Object, type:String,
bubbles:Boolean=false, cancelable:Boolean=false){ 
   super(type, bubbles, cancelable);
   this.level = level;
  }
  
  public override function clone():Event{
   return new LevelEvent(level, type);
  }
 }
}

 
On 12/14/06, marloscarmo2004 <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

        I need create a personalized event in my class in AS3. In AS2 I
use
        the dispatchEvent comand.
        
        this.dispatchEvent( { type : "onResult", target : this, data :
        result_arr } );
        
        How do I do in AS3? See my code below. 
        
        package as3.db
        {
        import flash.net.NetConnection;
        import flash.net.ObjectEncoding;
        import flash.net.Responder;
        
        public class AMFConnection
        {
        public var gateway : NetConnection;
        
        public function AMFConnection() { 
        gateway = new NetConnection();
        gateway.objectEncoding = flash.net.ObjectEncoding.AMF0;
        gateway.connect(
        "
http://branco:8080/projetos/5clicks/extranet/source/flex/bin/amfphp/gate
way.php
<http://branco:8080/projetos/5clicks/extranet/source/flex/bin/amfphp/gat
eway.php> ");
        }
        
        public function callMethod( nameMethod : String, params : Array
) :
        void {
        gateway.call( "extranet.callMethod ", new Responder( onResult,
        onFault ), nameMethod, params );
        }
        
        public function onResult( result : String ) : void {
        }
        
        public function onFault( result : String ) : void {
        }
        }
        }
        
        

        




-- 
John C. Bland II
Chief Geek 
Katapult Media, Inc. - www.katapultmedia.com
<http://www.katapultmedia.com> 
---
Biz Blog - http://blogs.katapultmedia.com/jb2
<http://blogs.katapultmedia.com/jb2> 
Personal Blog - http://blog.blandfamilyonline.com
<http://blog.blandfamilyonline.com> 
http://www.lifthimhigh.com <http://www.lifthimhigh.com>  - "Christian
Products for Those Bold Enough to Wear Them"
Home of FMUG.az - http://www.gotoandstop.org
<http://www.gotoandstop.org> 
Home of AZCFUG - http://www.azcfug.org <http://www.azcfug.org>  

 

Reply via email to