> // I usually define event handlers as simple function not public nor
> private - took that approach from ARP :)

there's no such thing as 'simple function'.
Properties and methods are public by default.

 function onTransition(evtObj:Object) {
 }

is that same as

public function onTransition(evtObj:Object) {
}

And in most cases event handlers should be private, as they should be 
accessible by the class instance only.

regards,
Muzak

----- Original Message ----- 
From: "Alain Rousseau" <[EMAIL PROTECTED]>
To: <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, June 07, 2007 3:20 PM
Subject: RE: [Flashcoders] EventDispatcher weirdness in AS2


> If you are using this exact code then I believe you have an error in the
> constructor :
>
> "public function MyClass"  should be  "public function MyMainClass"
>
> also you should either set your vars as private or whatever kind you need.
>
> Another thing, your eventlistener should have an object as second param, not
> a function so your Class should become :
>
>
> import myClass;
> import myOtherClass;
> import mx.events.EventDispatcher;
>
> class MyMainClass
> {
> private var _myClass:MyClass;
> private var _myOtherClass:MyOtherClass;
>
> public function MyMainClass()
> {
> doStuff();
> }
>
> private function doStuff()
> {
> _myClass = new MyClass();
> // Refer to the listening object, in this case it's the
> current Class MyMainClass (this)
> _myClass.addEventListener("onTransition", this)
> _myOtherClass = new MyOtherClass();
> }
>
> // I usually define event handlers as simple function not public nor
> private - took that approach from ARP :)
> function onTransition(evtObj:Object)
> {
> trace("Hello World, the event fired");
> trace(_myOtherClass);
> }
>
> }
>
> This is not tested but I believe it should yield something
>
> As for your MovieClip problem, I feel your pain ... seen it before and can't
> remember how I fixed it. Is there a stop() at the beginning of that clip ?
> in another timeline code or class ? This usually brings problems with
> gotoAndPlay ... Sometimes we forget to remove a stop() at certain places
> where it is unneeded - OnEnterFrame, setInterval, etc ..
>
> HTH
>
> Alain


_______________________________________________
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

Reply via email to