Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Pav

Playing loaded SWF's from Frame 1

Recommended Posts

Greetings! I am using the following code to load an external SWF into my main movie with LoaderMax:

 

import com.greensock.*;

import com.greensock.loading.*;

import com.greensock.events.LoaderEvent;

import com.greensock.loading.display.ContentDisplay;

 

progressBar.scaleX = 0;

 

var powerpointmovie:SWFLoader = new SWFLoader("powerpoint.swf",

{container:this, alpha:0, onprogress:progressHandler, onComplete:completeHandler});function progressHandler(event:LoaderEvent):void

{

progressBar.scaleX = powerpointmovie.progress;

}

function completeHandler(event:LoaderEvent):void

{

trace(event.target.content);

var powerpointmovie:ContentDisplay = event.target.content;

TweenLite.to(powerpointmovie, 0, {alpha:1});

TweenLite.to(progressBar, 0, {alpha:0});

TweenLite.to(incubateblinker, 0, {alpha:0});

TweenLite.to(progressbartitle, 0, {alpha:0});

TweenLite.to(progessbarcasing, 0, {alpha:0});

TweenLite.to(spawnprogresstitle, 0, {alpha:0});

}

powerpointmovie.load();

 

The loader bar functions as it should, and the SWF comes up in the main movie as expected with all of its functionality intact. However, the loaded SWF does not play from frame 1. Instead, it appears that upon completion, the loaded movie "skips" to the last frame. To this end, the loaded SWF appears rather "abruptly" without any of the tweens and other animations contained in all of the prior frames.

 

Hopefully, I have described my problem clearly. It is probably a very small issue, but one that is quite confounding (at least to me anyways!). Thanks in advance for any assistance you might afford me in this matter.

Link to comment
Share on other sites

Hi Pav,

 

Welcome to the GreenSock forums.

 

Thanks for taking the time to clearly explain the issue. I think the problem is that your swf is playing before it is fully loaded. This is the nature of swfs and one of their biggest benefits; they can stream and start playing before they are fully loaded.

 

To prevent the swf from playing before it is loaded you have 2 options:

 

1: place a stop() action in the first frame of powerpoint.swf

2: set autoPlay:false in the powerpointmovie SWFLoader's constructor like so:

 

 

var powerpointmovie:SWFLoader = new SWFLoader("powerpoint.swf",

{container:this, autoPlay:false, alpha:0, onprogress:progressHandler, onComplete:completeHandler});

 

 

I recommend option 2.

 

In order to call play() on the loaded swf once your onComplete fires, do this:

 

 

function completeHandler(event:LoaderEvent):void

{

trace(event.target.content);

var powerpointmovie:ContentDisplay = event.target.content;

powerpointmovie.rawContent.play();

TweenLite.to(powerpointmovie, 0, {alpha:1});

TweenLite.to(progressBar, 0, {alpha:0});

TweenLite.to(incubateblinker, 0, {alpha:0});

TweenLite.to(progressbartitle, 0, {alpha:0});

TweenLite.to(progessbarcasing, 0, {alpha:0});

TweenLite.to(spawnprogresstitle, 0, {alpha:0});

}

 

Or, if you have some sort script-based animation or initializing function that you need to run, you can do something like:

 

powerpointmovie.rawContent.myCustomInitFunction();

 

 

You can learn about content vs rawContent here: http://www.greensock...loadermax-tips/

Just as an additional note, The SWFLoader and the SWFLoader's content both have a rawContent property which both allow you to call functions on the loaded swf. Both rawContent properties refer to the same thing. In your case I used content.rawContent as you already pointed powerpointmovie to the content of the SWFLoader. In other words, the following 2 lines point to the same thing:

 

event.target.content.rawContent
event.target.rawContent

 

Please let us know if you need more help

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