Jump to content
Search Community

How do I access a function from a child SWF?

goral test
Moderator Tag

Recommended Posts

try this in your child swf:

 

 

var parentMovie:MovieClip = this.parent.root as MovieClip;
//parentMovie.onParentFiredFromLoaded();

parentMovie.myFunction();

 

ps. i deleted the duplicate of this question in the other thread. no worries.

Link to comment
Share on other sites

try this in your child swf:

 

 

var parentMovie:MovieClip = this.parent.root as MovieClip;
//parentMovie.onParentFiredFromLoaded();

parentMovie.myFunction();

 

ps. i deleted the duplicate of this question in the other thread. no worries.

 

Thanks for the snippet, but it doesnt work for me. Heres my code, im trying to hit "resetSlide" from a sub SWF(contentLoader is a movieClip on the stage that im loading everything into):

 

package
{
import flash.display.MovieClip;
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([blurFilterPlugin,TintPlugin, GlowFilterPlugin]);import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;

public class container extends MovieClip
{
 var queue:LoaderMax = new LoaderMax({name:"mainQueue",onComplete:completeHandler});

 public function container()
 {
  init();
  queue.append( new SWFLoader("slide_0.swf", {name:"scene0", estimatedBytes:3000, container:contentLoader.scene0}) );
  queue.append( new SWFLoader("slide_1.swf", {name:"scene1", estimatedBytes:3000, container:contentLoader.scene1}) );
  LoaderMax.prioritize("slide_0.swf");
  queue.load();
 }
 private function completeHandler(event:LoaderEvent):void
 {
  trace(event.target + " is complete!");
 }
 private function init()
 {
  slide1();
 }  private function slide1()
 {
  TweenLite.to(contentLoader.scene0, 1,{x:200});
 }
 private function slide2()
 {
  TweenLite.to(contentLoader.scene1, 1, {x:400});
 }
 private function resetSlide(whichSlide)
 {
  if (whichSlide == "Slide1")
  {
   TweenLite.to(contentLoader.scene0, 0,{x:0});
  }
  else
  {
   TweenLite.to(contentLoader.scene1, 0,{x:0});
  }  }
}
}

Link to comment
Share on other sites

try adding another .parent or 2. I didn't realize that your container was nested 2 levels down.

 

container:contentLoader.scene0

 

also, maybe resetSlide shouldn't be private. don't know.

 

Thanks! Making the function public made things happen. Thanks again :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...