Jump to content
Search Community

How would i call a function from a ContentDisplay SWF

Default test
Moderator Tag

Recommended Posts

I'm very new to LoaderMax, what i'm trying to do is to call a list of swf's and have them cycle through in a slideshow of sorts. I'm adding the loaded SWF's to stage using something similar to the below code.

 

var swfONE:ContentDisplay;

var swfTWO:ContentDisplay;

var swfTHREE:ContentDisplay;

 

LoaderMax.activate([sWFLoader, ImageLoader]);

var queue:LoaderMax = new LoaderMax({name:"loaderQueue",onChildComplete:myChildLoadCompleteFunction, maxConnections:1});

queue.append( new SWFLoader("Slides/swfONE.swf", {name:"swfONE", estimatedBytes:85000, load:true}) );
queue.append( new SWFLoader("Slides/swfTWO.swf", {name:"swfTWO", estimatedBytes:109000, load:true}) );
queue.append( new SWFLoader("Slides/swfTHREE.swf", {name:"swfTHREE", estimatedBytes:195000, load:true}) );
 

function myChildLoadCompleteFunction (event:LoaderEvent):void

{

swfONE = LoaderMax.getContent("swfONE");

swfTWO = LoaderMax.getContent("swfTWO");

swfTHREE = LoaderMax.getContent("swfTHREE");

 

slideContainer.addChild(swfONE);

}

 

From there i have code that cycles through each of the swf's and does a bunch of other stuff. However when that same swf appears again i want to "restart" the swf, so i'm trying to call a function inside the loaded swf that will remove all the necessary items and apply new instances. I'm just confusing myself with how i will communicate to the loaded SWF using the "ContentDisplay" class. I feel like i'm making it much harder than it has to be. Any help or simple example would be much appreciated.

Link to comment
Share on other sites

Hi,

 

Both the SWFLoader and the ContentDisplay object of the SWFLoader have a rawContent property which refers the SWF that is loaded. 

 

http://api.greensock.com/as/com/greensock/loading/SWFLoader.html

 

Both blocks of code below will work exactly the same way:

swfTHREE = LoaderMax.getContent("swfTHREE");
swfTHREE.rawContent.gotoAndPlay(1);

Or throught the loader

swfTHREE = LoaderMax.getLoader("swfThree");
swfTHREE.rawContent.gotoAndPlay(2)
Link to comment
Share on other sites

Thank you, that does help in some, but i'm still a little boggled with using that the way i need. I have attatched some code below that shows what i'm trying to do without loaderMax.

var mySWFLoader:Loader = new Loader();
mySWFLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mySWFLoader.load(new URLRequest("swfONE.swf"));

function onCompleteHandler(evt:Event):void
{
    var embededSWF:MovieClip = MovieClip(evt.target.content);
    addChild(embededSWF);
    embededSWF.function_inside_swfONE();
}

How would something like this be done with the ContentDisplay from LoaderMax?

Link to comment
Share on other sites

I got it! I managed to instead of put the loaded content into a ContentDisplay, i placed the rawContent into a movieclip, then accessed it the same way as i did before!

 

Here's is some sample code of how i solved the issue.

var swfONE_mc:MovieClip;

var queue:LoaderMax = new LoaderMax({name:"loaderQueue",onChildComplete:slideLoadingQueueComplete, onComplete:loadingSlidesComplete, maxConnections:1});
 
queue.append( new SWFLoader("Slides/swfONE.swf", {name:"swfONE", estimatedBytes:85000, load:true}) );

function slideLoadingQueueComplete(event:LoaderEvent):void
{
swfONE_mc= LoaderMax.getContent("swfONE").rawContent;
addChild(swfONE_mc);
swfONE_mc.myfunctiongoeshere();
)

Simple enough!

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...