RE: [Flashcoders] AS2: EventDispatcher.initialize() andsuper()conflict?

2007-06-11 Thread Merrill, Jason
With that said, any reason why you're not decorating the 
super class with EventDispatcher?
When decorating the super class every subclass will have 
event dispatching (which is usually what you want).

No good reason, other than I learned to use EventDispatcher long after
that pariticular superclass was written.  I could certainly modify it.
Thanks,

Jason Merrill
Bank of America  
GTO Learning  Leadership Development
eTools  Multimedia Team


 
___
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] AS2: EventDispatcher.initialize() andsuper()conflict?

2007-06-11 Thread Merrill, Jason
Unless you need to dispatch an event afterwards.

I need to dispatch events, but thanks!  I have the issue solved, thanks
everyone for the ideas.

Jason Merrill
Bank of America  
GTO Learning  Leadership Development
eTools  Multimedia Team


 
___
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] AS2: EventDispatcher.initialize() andsuper()conflict?

2007-06-09 Thread Alain Rousseau
On another note, if you only need to listen to another class events 
simply register that class with the one you use. (like a controller)

Unless you need to dispatch an event afterwards.


import classToListen;
class myClass extends otherClass
{

private var _classToListen:classToListen;
   function myClass(m:Model)
   {
   super();
   }

   public function register(registeredClass)
   {
   _classToListen = registeredClass;
   _classToListen.addEventListener(onEvent, Delegate.create(this, 
eventHandler);

   }

   public function eventHandler(evtObj:Object)
   {
   //do stuff
   }
}


if you need to dispatch events then decorate with EventDispatcher as 
Jesse and Muzak recommand.


Alain

Muzak wrote:

As Jesse said, use the static way instead of initializing it in the constructor.
This serves 2 purposes:
- mixin only occurs once (rather than which each instance created)
- mixin occurs before the constructor is run

With that said, any reason why you're not decorating the super class with 
EventDispatcher?
When decorating the super class every subclass will have event dispatching 
(which is usually what you want).

regards,
Muzak

- Original Message - 
From: Jesse Graupmann [EMAIL PROTECTED]

To: flashcoders@chattyfig.figleaf.com
Sent: Saturday, June 09, 2007 1:57 AM
Subject: RE: [Flashcoders] AS2: EventDispatcher.initialize() andsuper()conflict?


  

I never use super() so I have no idea, but see what happens when you throw
the initialize in a static variable like;


class myClass extends otherClass
{
private static var EventDispatcherDependancy  =
mx.events.EventDispatcher.initialize ( myClass.prototype );
public var addEventListener:Function;
public var removeEventListener:Function;
public var dispatchEvent:Function;

public function myClass (m:Model) {
super();
}
}

_

Jesse Graupmann
www.jessegraupmann.com
www.justgooddesign.com/blog/
_



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Merrill,
Jason
Sent: Friday, June 08, 2007 4:31 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] AS2: EventDispatcher.initialize() and
super()conflict?

I have a class that has to call it's superclass in the constructor.
However, it also needs to initialize EventDispatcher to listen to
dispatch events that another class is listening to.  It seems, and I
could be wrong, that EventDispatcher does not work if it's not the first
thing in the constructor.  I thought someone had said once, or I read
it, that EventDispatcher has to be first in the constructor.  And of
course, probkem then is super() will not work if it's not first, so it
seems to be a catch-22.  Is this true regarding
EventDispatcher.initialize() and how to avoid?

code snippet:

  /*=Constructor=*/
public function MyClass(m:Model)
{
super(m);
EventDispatcher.initialize(this);
}

If this is OK then maybe something else is wrong in my code, I just
wanted to find out if maybe this is why the events aren't firing.

Thanks,





___
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] AS2: EventDispatcher.initialize() andsuper()conflict?

2007-06-08 Thread Muzak
As Jesse said, use the static way instead of initializing it in the constructor.
This serves 2 purposes:
- mixin only occurs once (rather than which each instance created)
- mixin occurs before the constructor is run

With that said, any reason why you're not decorating the super class with 
EventDispatcher?
When decorating the super class every subclass will have event dispatching 
(which is usually what you want).

regards,
Muzak

- Original Message - 
From: Jesse Graupmann [EMAIL PROTECTED]
To: flashcoders@chattyfig.figleaf.com
Sent: Saturday, June 09, 2007 1:57 AM
Subject: RE: [Flashcoders] AS2: EventDispatcher.initialize() andsuper()conflict?


I never use super() so I have no idea, but see what happens when you throw
 the initialize in a static variable like;


 class myClass extends otherClass
 {
 private static var EventDispatcherDependancy  =
 mx.events.EventDispatcher.initialize ( myClass.prototype );
 public var addEventListener:Function;
 public var removeEventListener:Function;
 public var dispatchEvent:Function;

 public function myClass (m:Model) {
 super();
 }
 }

 _

 Jesse Graupmann
 www.jessegraupmann.com
 www.justgooddesign.com/blog/
 _



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Merrill,
 Jason
 Sent: Friday, June 08, 2007 4:31 PM
 To: flashcoders@chattyfig.figleaf.com
 Subject: [Flashcoders] AS2: EventDispatcher.initialize() and
 super()conflict?

 I have a class that has to call it's superclass in the constructor.
 However, it also needs to initialize EventDispatcher to listen to
 dispatch events that another class is listening to.  It seems, and I
 could be wrong, that EventDispatcher does not work if it's not the first
 thing in the constructor.  I thought someone had said once, or I read
 it, that EventDispatcher has to be first in the constructor.  And of
 course, probkem then is super() will not work if it's not first, so it
 seems to be a catch-22.  Is this true regarding
 EventDispatcher.initialize() and how to avoid?

 code snippet:

   /*=Constructor=*/
 public function MyClass(m:Model)
 {
 super(m);
 EventDispatcher.initialize(this);
 }

 If this is OK then maybe something else is wrong in my code, I just
 wanted to find out if maybe this is why the events aren't firing.

 Thanks,



___
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