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

Reply via email to