PDA

View Full Version : Controlling external swf...help needed asap!



beyondlearning
December 18th, 2008, 04:04 PM
Hi everyone,

I'm trying to call a function defined in an externally loaded swf from the main swf. I actually got the following code to work:

//code in main.swf

slideshowLoader = new Loader();
var galleryURL:URLRequest=new URLRequest("myGallery.swf");
slideshowLoader.load(galleryURL);
slideshowLoader.contentLoaderInfo.addEventListener (Event.INIT,slideshowHandler);

function slideshowHandler(e:Event):void{
var mySlideshow = MovieClip(slideshowLoader.content);
addChild(mySlideshow);
mySlideshow.stopTimer();
}

//function in external swf (myGallery.swf)

function stopTimer():void {
trace("timer stopped");
}


In the above example, mySlideshow is added to the stage and works fine. However I actually need to add it to a nested mc in the main.swf. So I tried the following code...without success:

//code in main.swf

slideshowLoader = new Loader();
var galleryURL:URLRequest=new URLRequest("myGallery.swf");
slideshowLoader.load(galleryURL);
slideshowLoader.contentLoaderInfo.addEventListener (Event.INIT,slideshowHandler);

function slideshowHandler(e:Event):void{
var mySlideshow = MovieClip(slideshowLoader.content);
sceneMC.containerMC.addChild(mySlideshow);
sceneMC.containerMC.mySlideshow.stopTimer();
}

//function in external swf (myGallery.swf)

function stopTimer():void {
trace("timer stopped");
}

In this case, mySlideshow plays perfectly however the stopTimer function causes an error (Error #1010: A term is undefined and has no properties.
at SMbeta1_fla::MainTimeline/slideshowHandler()).

Can anyone tell me why this doesn't work??


Thanks so much!