Jump to content
Search Community

How to control the loaded SWF?

a-ok test
Moderator Tag

Recommended Posts

var firstchild = itemArray[currentItem].getChildAt(0);
firstchild.gotoAndStop(2);

reports the following error:

ReferenceError: Error #1069: Property gotoAndStop not found on com.greensock.loading.display.ContentDisplay and there is no default value.

 

itemArray[currentItem] was set as a container for a SWFloader but itemArray[currentItem].getChildAt(0) is not a MovieClip but something called ContentDisplay. I want to control whatever's at getChildAt(0) as a MovieClip, how do I do that? I tried casting it as MovieClip() but it doesn't work.

 

 

Thanks

Link to comment
Share on other sites

ContentDisplay is like a wrapper for the SWFLoader's raw content. There are a bunch of reasons why ContentDisplay is necessary/useful, but I'll spare you the details (you can read the docs if you want). The ContentDisplay's rawContent points to the swf's root in your case, so you'd do:

 

firstchild.rawContent.gotoAndStop(2);

 

The ASDocs are at http://www.greensock.com/as/docs/tween/_loadermax.html

Link to comment
Share on other sites

Thanks but when I replace

var firstchild = itemArray[currentItem].getChildAt(0);
firstchild.gotoAndStop(2);

with

var firstchild = itemArray[currentItem].getChildAt(0);
firstchild.rawContent.gotoAndStop(2);

I get:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

 

trace(firstchild); //returns [object ContentDisplay]

trace(firstchild.rawContent); //returns null

firstchild.alpha = 0.5; //fades the loaded SWF correctly

Link to comment
Share on other sites

Did you wait for the content to load first? rawContent is null until the content loads.

 

If you're still having trouble, please post a very simple FLA that demonstrates the issue (no need to post your production file(s)) so that we cna publish it and see what's going on.

Link to comment
Share on other sites

Did you wait for the content to load first? rawContent is null until the content loads.

 

If you're still having trouble, please post a very simple FLA that demonstrates the issue (no need to post your production file(s)) so that we cna publish it and see what's going on.

 

Yup, that was it, I'm the king of stupid. What confused me is that I was able to change alpha, x and other properties yet not to play and stop the video.

 

Anyway, thanks for your help.

Link to comment
Share on other sites

if you load a swf like this:

 

 

loader=new SWFLoader("ladybug_finished.swf",{container:holder,x:0,y:0,alpha:0,name:"swf1",onComplete:completeHandler});

 

you can then do:

 

function completeHandler(e:LoaderEvent):void {

trace(e.target.content.parent.name); //traces holder

        trace(e.target.vars.container.name); //traces holder


TweenLite.to(e.target.content, 1, {alpha:1});


}

 

*if you don't want the name, and just the object... remove .name

Link to comment
Share on other sites

  • 2 years later...

You can call any public functions of the loaded swf from the parent swf through the rawContent property of the SWFLoader that loaded the swf.

import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;

var swf:SWFLoader = new SWFLoader("info.swf", {container:this, onComplete:completeHandler});

swf.load();

//target function in swf as soon as it loads:
function completeHandler(e:LoaderEvent):void {
    e.target.rawContent.somePublicFunction();
}

//or later on sometime after the swf has loaded:

swf.rawContent.somePublicFunction();

//or
LoaderMax.getLoader("intro.swf").rawContent.somePublicFunction();
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...