Re: [Flashcoders] Event Dispatcher

2006-02-18 Thread judah
Can you give an example of the memory leak you are talking about and 
also an example of the arguments.caller remove listener? I have not 
heard of this before.


Is the memory leak issue caused when you nest a function inside a class?

class myClass {

   function myClass() {

obj.addEventListener(onWhatever, Delegate.create(this, 
myCustomMethod));

// nested function not member of class - this causes memory leak???
function myCustomMethod(evtObj:Object):Void
{
// code
}

   }
}


Johannes Nel wrote:


what john is outlining here is fine in essence, but unless you never want to
remove this event listener this will cause a memory leak. either you create
the delegate function on a class scope or you use arguments.caller in the
handler function to remove the event listener

On 2/17/06, John Grden [EMAIL PROTECTED] wrote:
 


Must resist...the crack...habbit...

 and if you want to point that dispatched to a custom method not named
the same as the event:

obj.addEventListener(onWhatever, Delegate.create(this, myCustomMethod));

private function myCustomMethod(evtObj:Object):Void
{
  // code
}

Also, you don't need to include target in your dispatch, EventDispatcher
includes that for you.

On 2/17/06, Aaron Smith [EMAIL PROTECTED] wrote:
   


Just make sure int he constructor you initialize it::
EventDispatcher.initialize(this)..

also you ned to have these var definititions:

public var addEventListener:Function
public var removeEventListener:Function;
private var dispatchEvent:Function


then to dispatch:

dispatchEvent( { type:'whatever', target:this,
someOtherProp:'somothervalue' } )

all those props in the dispatchEvent call are just properties in a
basic Object. you must have type though.


SMITH



On Feb 17, 2006, at 12:44 PM, Jamie Alpers wrote:

 


This may be a duh question, but when you use dispatchEvent in a
custom
created component, can I use my own event name or do i have to use
one of
the built in ones of an object.  For example, I am creating custom
quiz
component (the built in ones dont have the flexibility we need) and
would
like to add a 'QuestionCompleted' event.  Is this possible?

-Jamie
___
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

 



--
John Grden - Blitz
___
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

   





--
j:pn
___
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

 




--
Always bear in mind that your own resolution to succeed is more important than any 
one thing.

You can have anything you want - if you want it badly enough. You can be anything you want to be, do anything you set out to accomplish if you hold to that desire with singleness of purpose. 


- Abraham Lincoln

___
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


Re: [Flashcoders] Event Dispatcher

2006-02-17 Thread Johannes Nel
yeah. the type property can be whatever, as long as you know what you are
listening for all is good.

On 2/17/06, Jamie Alpers [EMAIL PROTECTED] wrote:

 This may be a duh question, but when you use dispatchEvent in a custom
 created component, can I use my own event name or do i have to use one of
 the built in ones of an object.  For example, I am creating custom quiz
 component (the built in ones dont have the flexibility we need) and would
 like to add a 'QuestionCompleted' event.  Is this possible?

 -Jamie
 ___
 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




--
j:pn
___
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


Re: [Flashcoders] Event Dispatcher

2006-02-17 Thread Scott Fanetti
If you are using Flex2 , create a custom event that extends from the 
event class. and inject the namespace for the custom event into the 
superclass.


___
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


Re: [Flashcoders] Event Dispatcher

2006-02-17 Thread Jamie Alpers
Thanks.  I relooked at my code and realized i was just making a stupid
mistake by confusing object names. it works now :-)

On 2/17/06, Johannes Nel [EMAIL PROTECTED] wrote:

 yeah. the type property can be whatever, as long as you know what you are
 listening for all is good.

 On 2/17/06, Jamie Alpers [EMAIL PROTECTED] wrote:
 
  This may be a duh question, but when you use dispatchEvent in a custom
  created component, can I use my own event name or do i have to use one
 of
  the built in ones of an object.  For example, I am creating custom quiz
  component (the built in ones dont have the flexibility we need) and
 would
  like to add a 'QuestionCompleted' event.  Is this possible?
 
  -Jamie
  ___
  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
 



 --
 j:pn
 ___
 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


Re: [Flashcoders] Event Dispatcher

2006-02-17 Thread Aaron Smith
Just make sure int he constructor you initialize it::  
EventDispatcher.initialize(this)..


also you ned to have these var definititions:

public var addEventListener:Function
public var removeEventListener:Function;
private var dispatchEvent:Function


then to dispatch:

dispatchEvent( { type:'whatever', target:this,  
someOtherProp:'somothervalue' } )


all those props in the dispatchEvent call are just properties in a  
basic Object. you must have type though.



SMITH



On Feb 17, 2006, at 12:44 PM, Jamie Alpers wrote:

This may be a duh question, but when you use dispatchEvent in a  
custom
created component, can I use my own event name or do i have to use  
one of
the built in ones of an object.  For example, I am creating custom  
quiz
component (the built in ones dont have the flexibility we need) and  
would

like to add a 'QuestionCompleted' event.  Is this possible?

-Jamie
___
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


Re: [Flashcoders] Event Dispatcher

2006-02-17 Thread John Grden
Must resist...the crack...habbit...

 and if you want to point that dispatched to a custom method not named
the same as the event:

obj.addEventListener(onWhatever, Delegate.create(this, myCustomMethod));

private function myCustomMethod(evtObj:Object):Void
{
   // code
}

Also, you don't need to include target in your dispatch, EventDispatcher
includes that for you.

On 2/17/06, Aaron Smith [EMAIL PROTECTED] wrote:

 Just make sure int he constructor you initialize it::
 EventDispatcher.initialize(this)..

 also you ned to have these var definititions:

 public var addEventListener:Function
 public var removeEventListener:Function;
 private var dispatchEvent:Function


 then to dispatch:

 dispatchEvent( { type:'whatever', target:this,
 someOtherProp:'somothervalue' } )

 all those props in the dispatchEvent call are just properties in a
 basic Object. you must have type though.


 SMITH



 On Feb 17, 2006, at 12:44 PM, Jamie Alpers wrote:

  This may be a duh question, but when you use dispatchEvent in a
  custom
  created component, can I use my own event name or do i have to use
  one of
  the built in ones of an object.  For example, I am creating custom
  quiz
  component (the built in ones dont have the flexibility we need) and
  would
  like to add a 'QuestionCompleted' event.  Is this possible?
 
  -Jamie
  ___
  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




--
John Grden - Blitz
___
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


Re: [Flashcoders] Event Dispatcher

2006-02-17 Thread Johannes Nel
what john is outlining here is fine in essence, but unless you never want to
remove this event listener this will cause a memory leak. either you create
the delegate function on a class scope or you use arguments.caller in the
handler function to remove the event listener

On 2/17/06, John Grden [EMAIL PROTECTED] wrote:

 Must resist...the crack...habbit...

  and if you want to point that dispatched to a custom method not named
 the same as the event:

 obj.addEventListener(onWhatever, Delegate.create(this, myCustomMethod));

 private function myCustomMethod(evtObj:Object):Void
 {
// code
 }

 Also, you don't need to include target in your dispatch, EventDispatcher
 includes that for you.

 On 2/17/06, Aaron Smith [EMAIL PROTECTED] wrote:
 
  Just make sure int he constructor you initialize it::
  EventDispatcher.initialize(this)..
 
  also you ned to have these var definititions:
 
  public var addEventListener:Function
  public var removeEventListener:Function;
  private var dispatchEvent:Function
 
 
  then to dispatch:
 
  dispatchEvent( { type:'whatever', target:this,
  someOtherProp:'somothervalue' } )
 
  all those props in the dispatchEvent call are just properties in a
  basic Object. you must have type though.
 
 
  SMITH
 
 
 
  On Feb 17, 2006, at 12:44 PM, Jamie Alpers wrote:
 
   This may be a duh question, but when you use dispatchEvent in a
   custom
   created component, can I use my own event name or do i have to use
   one of
   the built in ones of an object.  For example, I am creating custom
   quiz
   component (the built in ones dont have the flexibility we need) and
   would
   like to add a 'QuestionCompleted' event.  Is this possible?
  
   -Jamie
   ___
   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
 



 --
 John Grden - Blitz
 ___
 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




--
j:pn
___
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