doing it this way creates a load of problems!
Thanks for your help!
SJM
----- Original Message -----
From: H
To: Flash Coders List
Sent: Thursday, August 14, 2008 12:19 AM
Subject: Re: [Flashcoders] AS3 accessing functions from other classes
"Call to a possibly undefined method addEventListener through a reference
with static type Class"
I think you're calling these methods on the Class main_site.
Try this:
var main_site_instance:main_site = new main_site();
main_site_instance.addEventListener("bk2globe", bk2globeListener);
But, if you are having trouble with this, grab a copy of actionscript 3.0
essentials <http://www.amazon.com/Essential-ActionScript-3-0/dp/0596526946>.
Here is a short article that might help you:
http://www.adobe.com/devnet/flash/quickstart/creating_class_as3/
Keep at it!
H
On Wed, Aug 13, 2008 at 4:14 PM, Merrill, Jason <
[EMAIL PROTECTED]> wrote:
> Is main_site the name of the instance? It doesn't seem like it if you
> are getting that error. Does it also import EventDispatcher or at
> least, extend it? Depending on where the code sits, you could do:
> this.addEventListener instead of main_site - main_site should be an
> instance name - you cannot listen to events from non-instances.
>
> Jason Merrill
> Bank of America
> Enterprise Technology & Global Risk L&LD
> Instructional Technology & Media
>
> Join the Bank of America Flash Platform Developer Community
>
> Are you a Bank of America associate interested in innovative learning
> ideas and technologies?
> Check out our internal GT&O Innovative Learning Blog & subscribe.
>
>
>
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED]
> >>[mailto:[EMAIL PROTECTED] On Behalf
> >>Of SJM - Flash
> >>Sent: Wednesday, August 13, 2008 1:47 PM
> >>To: Flash Coders List
> >>Subject: Re: [Flashcoders] AS3 accessing functions from other classes
> >>
> >>Hi Eduardo, thanks for your help! Ive implimented this into
> >>my code but still does not work, i now get a couple of errors...
> >>
> >>Desc: 1061: Call to a possibly undefined method
> >>addEventListener through a reference with static type Class.
> >>Src: main_site.addEventListener("bk2globe", bk2globeListener);
> >>
> >>Desc: 1061: Call to a possibly undefined method
> >>addEventListener through a reference with static type Class.
> >>Src: main_site.addEventListener("randomImg", randomImgListener);
> >>
> >>here is my code
> >>
> >>* * * * * * * * * *
> >>main_site.as
> >> dispatchEvent(new Event("bk2globe"));
> >> dispatchEvent(new Event("randomImg"));
> >>
> >>* * * * * * * * * *
> >>
> >>gallery.as
> >>main_site.addEventListener("bk2globe", bk2globeListener);
> >>main_site.addEventListener("randomImg", randomImgListener);
> >>
> >> private function bk2globeListener(ev:Event):void
> >> {
> >> goBackToMain();
> >> }
> >> private function randomImgListener(ev:Event):void
> >> {
> >> loadPhoto(randRange(1, 52));
> >> }
> >>
> >>* * * * * * * * * *
> >>
> >>Thanks
> >>SJM
> >> ----- Original Message -----
> >> From: Eduardo Omine
> >> To: Flash Coders List
> >> Sent: Wednesday, August 13, 2008 6:19 PM
> >> Subject: Re: [Flashcoders] AS3 accessing functions from
> >>other classes
> >>
> >>
> >> Dispatch an event from the loaded SWF and let the parent
> >>SWF handle the action.
> >>
> >> * * * * * * * * * *
> >> MainSite.as
> >> dispatchEvent(new Event("myEventName"));
> >>
> >> * * * * * * * * * *
> >>
> >> Gallery.as
> >> mainSite.addEventListener("myEventName", myListener);
> >>
> >> private function myListener(e:Event):void
> >> {
> >> // call desired method here
> >> }
> >>
> >> * * * * * * * * * *
> >>
> >> HTH
> >>
> >> --
> >> Eduardo Omine
> >> http://blog.omine.net/
> >> http://www.omine.net/
> >> _______________________________________________
> >> Flashcoders mailing list
> >> [email protected]
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>_______________________________________________
> >>Flashcoders mailing list
> >>[email protected]
> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders