Jump to content
Search Community

[Solved] gotoAndPlay Works In Flash, But Not From Published HTML

stevenp test
Moderator Tag

Recommended Posts

Greetings and thank you in advance for reading this,

 

I built a two frame animation that works splendidly in the CS4 authoring environment (no error nor any output other than the "trace" returns), and when the SWF file is opened with a browser, but not when the authored HTML that references the SWF is opened by the browser. The problem is that once the animation of frame 1 completes, it goes back to frame 1's default set up.

 

It's a two-frame because logically that made sense to me. I wanted to use SWFloader and noCache, and this was the way it laid itself out to me when I developed it. I'm familiar with "gotoAndPlay" using frame numbers/names in AS3, so I built an animation that runs when a button is clicked. Upon completion of the animation, we go to frame 2 and load the external SWF.

 

Is there something in my code that might be killing the browser?

 

Frame 1's AS3:

stop();

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

 var var_gotoAndPlay_timer:Number = 2;

 mc_gotoAndPlay.addEventListener(MouseEvent.CLICK, gotoAndPlayFuntion);

function gotoAndPlayFuntion(e:MouseEvent):void{
 	trace("call the gotoAndPlayFunction function");
	
	var tl_gotoAndPlay:TimelineMax = new TimelineMax({delay:1, onComplete:tweenOnComplete});
	tl_gotoAndPlay.insert(TweenMax.to(mc_gotoAndPlay, var_gotoAndPlay_timer, {alpha:0, y:"-50"}) );
	tl_gotoAndPlay.insert(TweenMax.to(mc_overlay, var_gotoAndPlay_timer, {alpha:0}) );
	tl_gotoAndPlay.insert(TweenMax.from(mc_loadingTXT, var_gotoAndPlay_timer, {delay:1, alpha:0, y:"50"}) );
	}
	
//function tweenOnComplete(e:TweenEvent):void {
function tweenOnComplete() {
	trace("call the tweenOnComplete function");
	gotoAndPlay(2);
}

Frame 2's AS3:

stop();

trace("we are on frame 2");

var video:SWFLoader = new SWFLoader("video-cache_buster-dev-03.swf", {container:mc_holder, noCache:true, width:480, height:320, onComplete:setupButtons});

video.load();

function playSWF(e:MouseEvent):void{
 	video.rawContent.play();
	}
	
function pauseSWF(e:MouseEvent):void{
 	video.rawContent.stop();
	}	
	
function setupButtons(e:LoaderEvent){
	play_btn.visible = true;
	pause_btn.visible = true;
	play_btn.addEventListener(MouseEvent.CLICK, playSWF);
	pause_btn.addEventListener(MouseEvent.CLICK, pauseSWF);
	}

Most of the code I've used was gleaned from help other people got on these forums, so a "thank you" to the people who helped them out because you've helped me, too.

 

Best regards,

Steve

Link to comment
Share on other sites

is your html file and all your swfs in the same directory? 

Have you tried adding onError or onFail callbacks to your SWFLoader? http://api.greensock.com/as/com/greensock/loading/SWFLoader.html

 

Even though you can't see traces in your browser you could still add text to dynamic text field when errors occur or use Monster Debugger: http://demonsterdebugger.com/tour

 

Feel free to zip up your files (as simplified and lean as possible) and post them here

Link to comment
Share on other sites

Thanks Carl.

 

I used onError to see if anything was returned, and there were no errors returned (I left this debugging code in the FLA). I tried to attach a CS4 file that includes only the source FLA, and the SWF that is referenced in the AS in frame 2, but wasn't able to do so. "no file selected" after three minutes of trying to upload. No clue what that means as I did, of course, select a file to upload then clicked "upload". So I tried the advanced method to attach ... and my 32 MB file is too large? Okay ...

 

http://giantsquid.us/flash.zip <-- a friend let me park it here.

 

I tried MonsterDebugger, but couldn't link to the SWC file. Their instructions are for CS5, and I have CS4 ... but the directions for linking via library were not clear to me, so I did not try that method to debug. Thank you for pointing me to that option.

 

 

Link to comment
Share on other sites

Changing

 

function tweenOnComplete() {
trace("call the tweenOnComplete function");
gotoAndPlay(2);
//TweenMax.to(mc_loadingTXT, var_gotoAndPlay_timer, {delay:1, alpha:1, y:"-50"});
}
 
to
 
function tweenOnComplete() {
trace("call the tweenOnComplete function");
gotoAndStop(2);
//TweenMax.to(mc_loadingTXT, var_gotoAndPlay_timer, {delay:1, alpha:1, y:"-50"});
}
 
worked for me
  • Like 1
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...