Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
kuba sanitrak

SWFLoader - play/stop loaded swf

Recommended Posts

Hello,

I have a question about accessing loaded swf files by SWFLoader class.

I am loading swf file and want to play/stop its content on certain event managed by certain function, not autoplay.

I have managed to access child clip of loaded swf (see sample code below).

But is there a way to "play" directly the loaded swf file, so I do not have to put all my animations into child clips of loaded swf?

Thanks up front for any suggestions

kuba

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import com.greensock.loading.data.*;
import flash.display.MovieClip;
var clip_var:MovieClip;
var myLoader:SWFLoader = new SWFLoader("data/swf/test2.swf", {name:"nameSwf", container:container_mc, autoPlay:false, onComplete:completeHandler} );
//start loading
myLoader.load();

function progressHandler(event:LoaderEvent):void
{
//trace("progress: " + event.target.progress);
}
function completeHandler(event:LoaderEvent):void
{
trace(event.target + " is complete!");
clip_var = myLoader.getSWFChild("clip_test") as MovieClip;//GET CHILD CLIP OF LOADED SWF (NAMED "clip_test")
}

function errorHandler(event:LoaderEvent):void
{
trace("error occured with " + event.target + ": " + event.text);
}
function swfPlay(e:MouseEvent):void
{
clip_var.play();
}
stage.addEventListener(MouseEvent.CLICK, swfPlay);

Link to post
Share on other sites

I think what you want is:

 

function swfPlay(e:MouseEvent):void
{
myLoader.rawContent.play();
}

Link to post
Share on other sites

Thank you Carl,

just couldn't figure it out myself. Got a bit lost in all the videos and slides filled with great stuff. The more I pushed, the more confused I got. Thanks again. Take care, kuba

Link to post
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.

×