Hi,

The AS2 event mechanism is slightly different - there is not really an Event type - you just get an object with a "type" string and a "target" property.

   In AS2, Events don't "bubble" either...

You might be quicker / easier to persuade your client that AS3 is the way forward - not sure of the reasoning here, but surely the benefits of AS3 outweigh the downsides, erm, what downsides apart from a learning curve and the ability to cause memory leaks easily :)

If you want your classes to dispatch events you will need them to implement the EventDispatcher API - With AS2, I used to create a class which extended MovieClip, then implemented the EventDispatcher "mixin" bit - look in the Components Reference.

See the stuff below, although someone else may have written a nice framework / set of classes to implement events a bit more - check out osflash.org

   HTH

   Glen


/**
*
* Class: EventDispatcherForm - implements the EventDispatcher mixin to allow
* subclasses to easily dispatch events.
*/
import mx.events.EventDispatcher;

class com.glenpike.common.view.EventDispatcherForm extends MovieClip
{
function EventDispatcherForm ()
   {
       EventDispatcher.initialize(this);
   }
public function addEventListener(event:String, listener):Void {} public function removeEventListener(event:String, listener):Void {} public function dispatchEvent(eventObject:Object):Void {} }

Then in my classes which dispatch events:

class com.glenpike.sasanim.view.RolloverButton extends EventDispatcherForm
{
//...
   function onRelease ()
   {
       if(mEnabled) {
           //...
           dispatchEvent( { type: "release"} );
       }
}
}

Then my lazy function in the parent clip which contains lots of buttons, but I could not be bothered to refer to them all by name for adding listeners..: class com.glenpike.common.view.Page extends EventDispatcherForm //Also dispatches events
{
function setUp() {
   for(var btn in this) {
if(this[btn] instanceof com.glenpike.sasanim.view.RolloverButton) { this[btn].addEventListener("release", Delegate.create(this, btnClick));
           }
       }
}
function btnClick(evt:Object) {
       trace("Override me ******");
}
}

Lord, Susan, CTR, DSS wrote:
I know this seems like a backwards question... but my client has
requested (300 plus fla's later) that we revert our code back to AS2.  I
was wondering if there was a quick way to do this.  When I ran my first
piece in AS2 and it was searching for the event class. I was wondering
if there was a quick way around this... like somehow incorporating the
event class into an AS2 piece or will this piece completely have to be
rewritten?

Thanks!
Susan _______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



--

Glen Pike
01326 218440
www.glenpike.co.uk <http://www.glenpike.co.uk>

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to