Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread Matt S.
And what was the fix? :)

On Thu, Aug 14, 2008 at 1:39 PM, SJM - Flash <[EMAIL PROTECTED]> wrote:
> Think ive fixed my problems with this now!
>
> Many thjanks for your help!
>
> SJM
>  - Original Message -
>  From: H
>  To: Flash Coders List
>  Sent: Thursday, August 14, 2008 2:30 PM
>  Subject: Re: [Flashcoders] AS3 accessing functions from other classes
>
>
>  Sorry man I didn't read the original post :S ...
>
>  main_site is loaded into gallery, and main_site has some buttons that when
>  you press them, they should trigger handlers in gallery.
>
>  I think it goes like this - add this code to your loader complete function
>  in gallery:
>
>  //where target is Loader
>  var main_site_instance:Sprite = ev.target.content as Sprite;
>  main_site_instance.addEventListener("bk2globe", bk2globeListener);
>  main_site_instance.addEventListener("randomImg", randomImgListener);
>
>  main_site should dispatch these events when you interact with it. This needs
>  to happen on the document class level...
>
>  H
>
>  On Thu, Aug 14, 2008 at 8:55 AM, SJM - Flash <[EMAIL PROTECTED]> wrote:
>
>  > Again another solution i tried but this too does not work!
>  >
>  > Thanks
>  > SJM
>  >   ----- Original Message -----
>  >  From: Kenneth Kawamoto
>  >  To: Flash Coders List
>  >   Sent: Thursday, August 14, 2008 1:36 PM
>  >  Subject: Re: [Flashcoders] AS3 accessing functions from other classes
>  >
>  >
>  >   You should be able to do access the parent by using, "parent".
>  >
>  >  Kenneth Kawamoto
>  >  http://www.materiaprima.co.uk/
>  >
>  >  SJM - Flash wrote:
>  >  > Hi guys, im having some trouble accessing a function from another class
>  > and I would like to know how its done.
>  >  >
>  >  > In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla', each of
>  > the FLAs has its own document class 'gallery.as' and 'main_site.as'. When
>  > compiled the second SWF(main_site) is loaded into the first SWF(gallery).
>  >  >
>  >  > In the same class that loads the SWF there is a number of other
>  > functions i want to access from buttons located within the loaded SWF
>  > (main_site).
>  >  >
>  >  > The SWF is loaded using this code...
>  >  >
>  >  > // CODE from within FUNCTION
>  >  > var swfLoader:Loader = new Loader();
>  >  > var swfURL:URLRequest = new URLRequest(filename);
>  >  > swfLoader.load (swfURL);
>  >  > swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
>  > swfLoadComplete);
>  >  >
>  >  > // CODE from within 'swfLoadComplete' FUNCTION
>  >  >addChild(ev.target.content);
>  >  >var loader:LoaderInfo = LoaderInfo(ev.target);
>  >  >loader.content.x = 0;
>  >  >loader.content.y = 0;
>  >  >
>  >  > SJM
>  >  ___
>  >  Flashcoders mailing list
>  >  Flashcoders@chattyfig.figleaf.com
>  >  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>  > ___
>  > Flashcoders mailing list
>  > Flashcoders@chattyfig.figleaf.com
>  > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>  >
>  ___
>  Flashcoders mailing list
>  Flashcoders@chattyfig.figleaf.com
>  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread SJM - Flash
Think ive fixed my problems with this now!

Many thjanks for your help!

SJM
  - Original Message - 
  From: H 
  To: Flash Coders List 
  Sent: Thursday, August 14, 2008 2:30 PM
  Subject: Re: [Flashcoders] AS3 accessing functions from other classes


  Sorry man I didn't read the original post :S ...

  main_site is loaded into gallery, and main_site has some buttons that when
  you press them, they should trigger handlers in gallery.

  I think it goes like this - add this code to your loader complete function
  in gallery:

  //where target is Loader
  var main_site_instance:Sprite = ev.target.content as Sprite;
  main_site_instance.addEventListener("bk2globe", bk2globeListener);
  main_site_instance.addEventListener("randomImg", randomImgListener);

  main_site should dispatch these events when you interact with it. This needs
  to happen on the document class level...

  H

  On Thu, Aug 14, 2008 at 8:55 AM, SJM - Flash <[EMAIL PROTECTED]> wrote:

  > Again another solution i tried but this too does not work!
  >
  > Thanks
  > SJM
  >   - Original Message -
  >  From: Kenneth Kawamoto
  >  To: Flash Coders List
  >   Sent: Thursday, August 14, 2008 1:36 PM
  >  Subject: Re: [Flashcoders] AS3 accessing functions from other classes
  >
  >
  >   You should be able to do access the parent by using, "parent".
  >
  >  Kenneth Kawamoto
  >  http://www.materiaprima.co.uk/
  >
  >  SJM - Flash wrote:
  >  > Hi guys, im having some trouble accessing a function from another class
  > and I would like to know how its done.
  >  >
  >  > In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla', each of
  > the FLAs has its own document class 'gallery.as' and 'main_site.as'. When
  > compiled the second SWF(main_site) is loaded into the first SWF(gallery).
  >  >
  >  > In the same class that loads the SWF there is a number of other
  > functions i want to access from buttons located within the loaded SWF
  > (main_site).
  >  >
  >  > The SWF is loaded using this code...
  >  >
  >  > // CODE from within FUNCTION
  >  > var swfLoader:Loader = new Loader();
  >  > var swfURL:URLRequest = new URLRequest(filename);
  >  > swfLoader.load (swfURL);
  >  > swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
  > swfLoadComplete);
  >  >
  >  > // CODE from within 'swfLoadComplete' FUNCTION
  >  >addChild(ev.target.content);
  >  >var loader:LoaderInfo = LoaderInfo(ev.target);
  >  >loader.content.x = 0;
  >  >loader.content.y = 0;
  >  >
  >  > SJM
  >  ___
  >  Flashcoders mailing list
  >  Flashcoders@chattyfig.figleaf.com
  >  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  > ___
  > Flashcoders mailing list
  > Flashcoders@chattyfig.figleaf.com
  > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  >
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread H
Sorry man I didn't read the original post :S ...

main_site is loaded into gallery, and main_site has some buttons that when
you press them, they should trigger handlers in gallery.

I think it goes like this - add this code to your loader complete function
in gallery:

//where target is Loader
var main_site_instance:Sprite = ev.target.content as Sprite;
main_site_instance.addEventListener("bk2globe", bk2globeListener);
main_site_instance.addEventListener("randomImg", randomImgListener);

main_site should dispatch these events when you interact with it. This needs
to happen on the document class level...

H

On Thu, Aug 14, 2008 at 8:55 AM, SJM - Flash <[EMAIL PROTECTED]> wrote:

> Again another solution i tried but this too does not work!
>
> Thanks
> SJM
>   - Original Message -
>  From: Kenneth Kawamoto
>  To: Flash Coders List
>   Sent: Thursday, August 14, 2008 1:36 PM
>  Subject: Re: [Flashcoders] AS3 accessing functions from other classes
>
>
>   You should be able to do access the parent by using, "parent".
>
>  Kenneth Kawamoto
>  http://www.materiaprima.co.uk/
>
>  SJM - Flash wrote:
>  > Hi guys, im having some trouble accessing a function from another class
> and I would like to know how its done.
>  >
>  > In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla', each of
> the FLAs has its own document class 'gallery.as' and 'main_site.as'. When
> compiled the second SWF(main_site) is loaded into the first SWF(gallery).
>  >
>  > In the same class that loads the SWF there is a number of other
> functions i want to access from buttons located within the loaded SWF
> (main_site).
>  >
>  > The SWF is loaded using this code...
>  >
>  > // CODE from within FUNCTION
>  > var swfLoader:Loader = new Loader();
>  > var swfURL:URLRequest = new URLRequest(filename);
>  > swfLoader.load (swfURL);
>  > swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
> swfLoadComplete);
>  >
>  > // CODE from within 'swfLoadComplete' FUNCTION
>  >addChild(ev.target.content);
>  >var loader:LoaderInfo = LoaderInfo(ev.target);
>  >loader.content.x = 0;
>  >loader.content.y = 0;
>  >
>  > SJM
>  ___
>  Flashcoders mailing list
>  Flashcoders@chattyfig.figleaf.com
>  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread Kenneth Kawamoto

No, I mean when you trace it from the button.

Kenneth Kawamoto
http://www.materiaprima.co.uk/

SJM - Flash wrote:

Kenneth i get... [object Loader] when tracing parent
 
SJM


- Original Message -
*From:* Kenneth Kawamoto <mailto:[EMAIL PROTECTED]>
*To:* Flash Coders List <mailto:flashcoders@chattyfig.figleaf.com>
*Sent:* Thursday, August 14, 2008 2:11 PM
*Subject:* Re: [Flashcoders] AS3 accessing functions from other classes

What do you get if you do "trace(parent);"?

Kenneth Kawamoto
http://www.materiaprima.co.uk/

SJM - Flash wrote:
 > Again another solution i tried but this too does not work!
 > 
 > Thanks

 > SJM
 >
 > - Original Message -
 > *From:* Kenneth Kawamoto <mailto:[EMAIL PROTECTED]>
 > *To:* Flash Coders List
<mailto:flashcoders@chattyfig.figleaf.com>
 > *Sent:* Thursday, August 14, 2008 1:36 PM
     >     *Subject:* Re: [Flashcoders] AS3 accessing functions from
other classes
 >
 > You should be able to do access the parent by using, "parent".
 >
 > Kenneth Kawamoto
 > http://www.materiaprima.co.uk/
 >
 > SJM - Flash wrote:
 >  > Hi guys, im having some trouble accessing a function from
another
 > class and I would like to know how its done.
 >  >
 >  > In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla',
 > each of the FLAs has its own document class 'gallery.as' and
 > 'main_site.as'. When compiled the second SWF(main_site) is loaded
 > into the first SWF(gallery).
 >  >
 >  > In the same class that loads the SWF there is a number of
other
 > functions i want to access from buttons located within the loaded
 > SWF (main_site).
 >  >
 >  > The SWF is loaded using this code...
 >  >
 >  > // CODE from within FUNCTION
 >  > var swfLoader:Loader = new Loader();
 >  > var swfURL:URLRequest = new URLRequest(filename);
 >  > swfLoader.load (swfURL);
 >  >
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,

 > swfLoadComplete);
 >  >
 >  > // CODE from within 'swfLoadComplete' FUNCTION
 >  >addChild(ev.target.content); 
 >  >var loader:LoaderInfo = LoaderInfo(ev.target); 
 >  >loader.content.x = 0;

 >  >loader.content.y = 0;
 >  >
 >  > SJM

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread SJM - Flash
Kenneth i get... [object Loader] when tracing parent

SJM
  - Original Message - 
  From: Kenneth Kawamoto 
  To: Flash Coders List 
  Sent: Thursday, August 14, 2008 2:11 PM
  Subject: Re: [Flashcoders] AS3 accessing functions from other classes


  What do you get if you do "trace(parent);"?

  Kenneth Kawamoto
  http://www.materiaprima.co.uk/

  SJM - Flash wrote:
  > Again another solution i tried but this too does not work!
  >  
  > Thanks
  > SJM
  > 
  > - Original Message -
  > *From:* Kenneth Kawamoto <mailto:[EMAIL PROTECTED]>
  > *To:* Flash Coders List <mailto:flashcoders@chattyfig.figleaf.com>
  > *Sent:* Thursday, August 14, 2008 1:36 PM
  > *Subject:* Re: [Flashcoders] AS3 accessing functions from other classes
  > 
  > You should be able to do access the parent by using, "parent".
  > 
  > Kenneth Kawamoto
  > http://www.materiaprima.co.uk/
  > 
  > SJM - Flash wrote:
  >  > Hi guys, im having some trouble accessing a function from another
  > class and I would like to know how its done.
  >  >
  >  > In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla',
  > each of the FLAs has its own document class 'gallery.as' and
  > 'main_site.as'. When compiled the second SWF(main_site) is loaded
  > into the first SWF(gallery).
  >  >
  >  > In the same class that loads the SWF there is a number of other
  > functions i want to access from buttons located within the loaded
  > SWF (main_site).
  >  >
  >  > The SWF is loaded using this code...
  >  >
  >  > // CODE from within FUNCTION
  >  > var swfLoader:Loader = new Loader();
  >  > var swfURL:URLRequest = new URLRequest(filename);
  >  > swfLoader.load (swfURL);
  >  > swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
  > swfLoadComplete);
  >  >
  >  > // CODE from within 'swfLoadComplete' FUNCTION
  >  >addChild(ev.target.content);  
  >  >var loader:LoaderInfo = LoaderInfo(ev.target);  
  >  >loader.content.x = 0;
  >  >loader.content.y = 0;
  >  >
  >  > SJM
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread Matt S.
you could also try:

var myMC:MovieClip = new MovieClip();
myMC = ev.target.content;
myMC.name = "myMC";
myMC.x= 0;
myMC.y= 0;
this.addChild(myMC);

.m

On Thu, Aug 14, 2008 at 8:11 AM, SJM - Flash <[EMAIL PROTECTED]> wrote:
> Hi Jason thanks for your help! Ive added what you said but the event 
> listeners do not seam to to be hearing the dispatched event.
>
> main_site is the document class for main_site.fla, and is loaded into 
> 'gallery.swf'  using this code...
>
> // CODE from within FUNCTION
>var swfLoader:Loader = new Loader();
>var swfURL:URLRequest = new URLRequest(filename);
>swfLoader.load (swfURL);
>swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
> swfLoadComplete);
>
> // CODE from within 'swfLoadComplete' FUNCTION
>   addChild(ev.target.content);
>   var loader:LoaderInfo = LoaderInfo(ev.target);
>   loader.content.x = 0;
>   loader.content.y = 0;
>
> ive tried adding these but they do not work
>   loader.content.name = "main_site";
> ...and...
>   loader.content.instanceName = "main_site";
>
> The EventDispatcher is imported (the whole import flash.events.*; are 
> imported).
>
> Thanks
> SJM
>  - Original Message -
>  From: Merrill, Jason
>  To: Flash Coders List
>  Sent: Wednesday, August 13, 2008 10:14 PM
>  Subject: RE: [Flashcoders] AS3 accessing functions from other classes
>
>
>  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);
>  >>
>  >>  p

Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread Kenneth Kawamoto

What do you get if you do "trace(parent);"?

Kenneth Kawamoto
http://www.materiaprima.co.uk/

SJM - Flash wrote:

Again another solution i tried but this too does not work!
 
Thanks

SJM

- Original Message -
*From:* Kenneth Kawamoto <mailto:[EMAIL PROTECTED]>
*To:* Flash Coders List <mailto:flashcoders@chattyfig.figleaf.com>
*Sent:* Thursday, August 14, 2008 1:36 PM
*Subject:* Re: [Flashcoders] AS3 accessing functions from other classes

You should be able to do access the parent by using, "parent".

Kenneth Kawamoto
http://www.materiaprima.co.uk/

SJM - Flash wrote:
 > Hi guys, im having some trouble accessing a function from another
class and I would like to know how its done.
 >
 > In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla',
each of the FLAs has its own document class 'gallery.as' and
'main_site.as'. When compiled the second SWF(main_site) is loaded
into the first SWF(gallery).
 >
 > In the same class that loads the SWF there is a number of other
functions i want to access from buttons located within the loaded
SWF (main_site).
 >
 > The SWF is loaded using this code...
 >
 > // CODE from within FUNCTION
 > var swfLoader:Loader = new Loader();
 > var swfURL:URLRequest = new URLRequest(filename);
 > swfLoader.load (swfURL);
 > swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
swfLoadComplete);
 >
 > // CODE from within 'swfLoadComplete' FUNCTION
 >addChild(ev.target.content);  
 >var loader:LoaderInfo = LoaderInfo(ev.target);  
 >loader.content.x = 0;

 >loader.content.y = 0;
 >
 > SJM

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread SJM - Flash
Again another solution i tried but this too does not work!

Thanks
SJM
  - Original Message - 
  From: Kenneth Kawamoto 
  To: Flash Coders List 
  Sent: Thursday, August 14, 2008 1:36 PM
  Subject: Re: [Flashcoders] AS3 accessing functions from other classes


  You should be able to do access the parent by using, "parent".

  Kenneth Kawamoto
  http://www.materiaprima.co.uk/

  SJM - Flash wrote:
  > Hi guys, im having some trouble accessing a function from another class and 
I would like to know how its done.
  > 
  > In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla', each of the 
FLAs has its own document class 'gallery.as' and 'main_site.as'. When compiled 
the second SWF(main_site) is loaded into the first SWF(gallery). 
  > 
  > In the same class that loads the SWF there is a number of other functions i 
want to access from buttons located within the loaded SWF (main_site).
  > 
  > The SWF is loaded using this code...
  > 
  > // CODE from within FUNCTION 
  > var swfLoader:Loader = new Loader();
  > var swfURL:URLRequest = new URLRequest(filename);
  > swfLoader.load (swfURL);
  > swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
swfLoadComplete);
  > 
  > // CODE from within 'swfLoadComplete' FUNCTION 
  >addChild(ev.target.content);   
  >var loader:LoaderInfo = LoaderInfo(ev.target);   
  >loader.content.x = 0;
  >loader.content.y = 0;
  > 
  > SJM
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread SJM - Flash
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
  > >>  Flashcoders@chattyfig.figleaf.com
  > >>  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  > >>___
  > >>Flashcoders mailing list
  > >>Flashcoders@chattyfig.figleaf.com
  > >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  > >>
  > ___
  > Flashcoders mailing list
  > Flashcoders@chattyfig.figleaf.com
  > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  >
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread Kenneth Kawamoto

You should be able to do access the parent by using, "parent".

Kenneth Kawamoto
http://www.materiaprima.co.uk/

SJM - Flash wrote:

Hi guys, im having some trouble accessing a function from another class and I 
would like to know how its done.

In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla', each of the FLAs has its own document class 'gallery.as' and 'main_site.as'. When compiled the second SWF(main_site) is loaded into the first SWF(gallery). 


In the same class that loads the SWF there is a number of other functions i 
want to access from buttons located within the loaded SWF (main_site).

The SWF is loaded using this code...

// CODE from within FUNCTION 
var swfLoader:Loader = new Loader();

var swfURL:URLRequest = new URLRequest(filename);
swfLoader.load (swfURL);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
swfLoadComplete);

// CODE from within 'swfLoadComplete' FUNCTION 
   addChild(ev.target.content);   
   var loader:LoaderInfo = LoaderInfo(ev.target);   
   loader.content.x = 0;

   loader.content.y = 0;

SJM

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-14 Thread SJM - Flash
Hi Jason thanks for your help! Ive added what you said but the event listeners 
do not seam to to be hearing the dispatched event.

main_site is the document class for main_site.fla, and is loaded into 
'gallery.swf'  using this code...

// CODE from within FUNCTION 
var swfLoader:Loader = new Loader();
var swfURL:URLRequest = new URLRequest(filename);
swfLoader.load (swfURL);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
swfLoadComplete);

// CODE from within 'swfLoadComplete' FUNCTION 
   addChild(ev.target.content);   
   var loader:LoaderInfo = LoaderInfo(ev.target);   
   loader.content.x = 0;
   loader.content.y = 0;

ive tried adding these but they do not work
   loader.content.name = "main_site";
...and...
   loader.content.instanceName = "main_site";

The EventDispatcher is imported (the whole import flash.events.*; are imported).

Thanks
SJM
  - Original Message - 
  From: Merrill, Jason 
  To: Flash Coders List 
  Sent: Wednesday, August 13, 2008 10:14 PM
  Subject: RE: [Flashcoders] AS3 accessing functions from other classes


  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
  >>  Flashcoders@chattyfig.figleaf.com
  >>  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  >>___
  >>Flashcoders mailing list
  >>Flashcoders@chattyfig.figleaf.com
  >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  >>
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-13 Thread H
"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
> >>  Flashcoders@chattyfig.figleaf.com
> >>  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>___
> >>Flashcoders mailing list
> >>Flashcoders@chattyfig.figleaf.com
> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] AS3 accessing functions from other classes

2008-08-13 Thread Merrill, Jason
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
>>  Flashcoders@chattyfig.figleaf.com
>>  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>___
>>Flashcoders mailing list
>>Flashcoders@chattyfig.figleaf.com
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-13 Thread SJM - Flash
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
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 accessing functions from other classes

2008-08-13 Thread Eduardo Omine
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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] AS3 accessing functions from other classes

2008-08-13 Thread SJM - Flash
Hi guys, im having some trouble accessing a function from another class and I 
would like to know how its done.

In my project i have 2 FLAs 'gallery.fla' and 'main_site.fla', each of the FLAs 
has its own document class 'gallery.as' and 'main_site.as'. When compiled the 
second SWF(main_site) is loaded into the first SWF(gallery). 

In the same class that loads the SWF there is a number of other functions i 
want to access from buttons located within the loaded SWF (main_site).

The SWF is loaded using this code...

// CODE from within FUNCTION 
var swfLoader:Loader = new Loader();
var swfURL:URLRequest = new URLRequest(filename);
swfLoader.load (swfURL);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
swfLoadComplete);

// CODE from within 'swfLoadComplete' FUNCTION 
   addChild(ev.target.content);   
   var loader:LoaderInfo = LoaderInfo(ev.target);   
   loader.content.x = 0;
   loader.content.y = 0;

SJM
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders