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);
>  >>
>  >>  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

Reply via email to