Jump to content

Guest aezzell

autoPlay:false doesn't keep loaded SWF from playing [SOLVED]

Recommended Posts

I took the example from the LoaderMax home page and tried to modify it to load a SWF file. The file is loading just fine, but the SWF is playing automatically. Isn't the point of autoPlay:false to keep that from happening?


What am I missing?


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

//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});

//append several loaders
queue.append( new SWFLoader("europe01.swf", {name:"clip01", container:this, autoPlay:false}) );

//start loading

function progressHandler(event:LoaderEvent):void {
   trace("progress: " + event.target.progress);

function completeHandler(event:LoaderEvent):void {
   var sec01:ContentDisplay = LoaderMax.getContent("clip01");
   TweenLite.to(sec01, 1, {alpha:1});
   trace(event.target + " is complete!");

function errorHandler(event:LoaderEvent):void {
   trace("error occured with " + event.target + ": " + event.text);


I've attached the 2 SWFs and the FLA file for the test loader - the FLA file for the SWF that gets loaded was too big to upload, even after I took the images & excess layers out of it.


Why is the SWF movie playing?



Link to comment
Share on other sites

weird. i used your file to load my own swf and it worked just fine... autoPlay:false did its job and the loaded swf did not play.


attached are the files for you to see.


unfortunately the file you didn't attach: europe01.fla is the one that would be most helpful in determining why the autoPlay:false is being ignored.

do you have script in that file that causes it to play?


if you can attach an fla that creates a swf that ignores autoPlay:false when loaded I'll be glad to look at it. it doesn't have to be anything complicated.



Link to comment
Share on other sites

Here's the script:


import com.greensock.*;
import com.greensock.easing.Expo;
import com.greensock.easing.FastEase;
import flash.events.MouseEvent;
import flash.display.MovieClip;
var hoverTint:String="0xff9900";
var hotTint:String="0x000000";

//set the target for "Learn more... " 
var URLRequest_one:URLRequest=new URLRequest("blendLrn.aspx");



var tl:TimelineMax=new TimelineMax({paused:true});


//UKGovt - people
tl.addLabel("one_in", tl.duration);
//trace("10 " + tl.duration);
tl.append(TweenMax.to(one_mc, 0, {autoAlpha:1, immediateRender:false}));
tl.appendMultiple(TweenMax.allFrom([one_mc.imgOne_mc], .9, {scaleX:.9, scaleY:.9, alpha:0, ease:Expo.easeOut}));
tl.append(TweenMax.from(one_mc.hdrOne_mc, .5, {alpha:0}));

//add the learn more button
tl.append(TweenMax.to(learnMore_mc, 0, {autoAlpha:1, immediateRender:false}));

tl.addLabel("one_complete", tl.duration);

//set up the learn more button
learnMore_mc.addEventListener(MouseEvent.MOUSE_OVER, learnMoreOver);
learnMore_mc.addEventListener(MouseEvent.MOUSE_OUT, learnMoreOut);
learnMore_mc.addEventListener(MouseEvent.CLICK, learnMoreClick);

function learnMoreOver(e:MouseEvent):void {
TweenMax.to(e.target, .4, {tint:hoverTint});

function learnMoreOut(e:MouseEvent):void {
TweenMax.to(e.target, .4, {tint:null});

function learnMoreClick(e:MouseEvent):void {
var targetURL=this["URLRequest_one"];



I don't understand why the FLA file is 3MB with no images - and I've deleted all the images from the library, not just removed them from the stage.


In the morning, I'll see if by starting a new movie from scratch, I can get something small enough to attach.

Link to comment
Share on other sites

To answer your question, yes, there's script that causes the movie to play - but doesn't the autoPlay in the loader not override that?

Link to comment
Share on other sites

no, autoPlay:false only prevents the playhead in the loaded swf from advancing. it is to prevent timeline-based animation from running. there is no way for LoaderMax to prevent scripts from running.


what you could do is have the parent swf call a function in the loaded swf that tells the loaded swf to run its script when the loaded swf has completed loaded.


you can access the loaded swf's methods and properties via the rawContent property of the SWFLoader that loaded your swf.


Please see tip 1: http://www.greensock.com/loadermax-tips/


you can access your SWFLoader via getLoader and then use the rawContent property to target the loaded swf



Link to comment
Share on other sites

Ah. Thanks.


See? I *KNEW* I had to be missing something!


Perhaps the docs could be modified to make this clearer for those of us still running on a 4-bit processor:


autoPlay : Boolean - If autoPlay is true (the default), the swf will begin playing immediately when the INIT event fires. To prevent this behavior, set autoPlay to false which will also mute the swf until the SWFLoader completes. This only prevents timeline-based animations from running, not those controlled via scripting.


Or something like that.

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.