Solved

AS3 Event.COMPLETE Bug

Posted on 2010-09-03
11
618 Views
Last Modified: 2013-11-11
Hi

I have an AS3 preloader script but it fails in IE (both local and live), it looks like it fails to fire the Event.COMPLETE function.

Works fine on FF Safari on a mac, the only other thing is flash player version, my ie installs are currently running 10.0.45.2 and all the other browsers are running 10.1.x.x +

Could this be a bug in the Flash Player and if so is there are work around for users with 10.0 installed??

You thoughts would be much appreciated??

S
// Import Classes
//import com.greensock.*;
//import com.greensock.easing.*;
import caurina.transitions.*;
	
// Vars
var origLogoHeight:Number = preLogo.height;
var origLogoWidth:Number = preLogo.width;
var l:Loader;

// Loader

function preResizeHandler(e:Event):void
{
	positionLoader();
}

function positionLoader():void {
	preLogo.x = (stage.stageWidth / 2) - (preLogo.width / 2);
	preLogo.y = (stage.stageHeight / 2) - (preLogo.width / 2);
}



function preInit():void {
	
	this.stage.frameRate = 30;
	this.stage.showDefaultContextMenu = false;
	this.stage.scaleMode = StageScaleMode.NO_SCALE;
	this.stage.align = StageAlign.TOP_LEFT;
	this.stage.addEventListener(Event.RESIZE, preResizeHandler);
	
	
	//preLogo.strapGradient.mask = preLogo.strap;
	
	
	preLogo.strapGradient.alpha = 0;
	preLogo.strapGradient.mask = preLogo.strapMask;
	
	preLogo.letters.alpha = 0;
	
	preLogo.brackets.left.alpha = 0;
	preLogo.brackets.right.alpha = 0;
	
	preLogo.brackets.left.x = (preLogo.brackets.width / 4) - preLogo.brackets.left.width ;
	preLogo.brackets.right.x = (preLogo.brackets.width / 4);

	preLogo.percent.alpha = 0;
	preLogo.percentGradient.mask = preLogo.percent;

	preLogo.width = 100;
	preLogo.scaleY = preLogo.scaleX;
	
	preLogo.x = (stage.stageWidth / 2) - (preLogo.width / 2);
	preLogo.y = (stage.stageHeight / 2) - (preLogo.height / 2);
	
	Tweener.addTween(preLogo.brackets.left, {delay: 1.5, time:1.5, transition:"easeInOutElastic", alpha: 1, x: 0});
	Tweener.addTween(preLogo.brackets.right, {delay: 1.5, time:1.5, transition:"easeInOutElastic", alpha: 1, x: ((preLogo.brackets.width/2) - preLogo.brackets.right.width)});
	Tweener.addTween(preLogo.percent, {delay: 1, time:1.5, transition:"easeOutCirc", alpha: 1, onComplete: preInitLoad});
	
	/*
	
	// Using TweenLite

	var bracketTimeline:TimelineLite = new TimelineLite({onComplete:preInitLoad});
	bracketTimeline.insertMultiple([
		TweenLite.to(preLogo.brackets.left, 0.5, {delay: 2, alpha: 1, x: 0, ease:Circ.easeOut}),
		TweenLite.to(preLogo.brackets.right, 0.5, {delay: 2, alpha: 1, x: ((preLogo.brackets.width/2) - preLogo.brackets.right.width), ease:Circ.easeOut }),
		TweenLite.to(preLogo.percent, 1.5, {delay: 2.5, alpha: 1, ease:Circ.easeOut})
	]);
	*/
}




function preInitLoad():void {
	l = new Loader();
	//this.addChild(l);
	l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preLoadProgress);
	l.contentLoaderInfo.addEventListener(Event.INIT, preLoadComplete);
	l.contentLoaderInfo.addEventListener(Event.COMPLETE, preLoadComplete);
	l.load(new URLRequest("FileToLoad.swf"));
}

function preLoadProgress(e:ProgressEvent):void
{
	
	
	var perc:Number = e.bytesLoaded / e.bytesTotal;
	trace(perc*100);
	preLogo.percent.text = Math.ceil(perc*100).toString();
	
	/*
	if(e.bytesLoaded == e.bytesTotal)
		preLoadComplete();
	else
	{
	}
	*/
}


function preLoadComplete(e:Event):void
{
	
	var preLogoX:Number = (stage.stageWidth / 2) - (origLogoWidth / 2);
	var preLogoY:Number = (stage.stageHeight / 2) - (origLogoHeight / 2);
	
	Tweener.addTween(preLogo.percentGradient, {delay: 0, time:0.2, transition:"linear", alpha: 0});
	Tweener.addTween(preLogo, {x:preLogoX, y:preLogoY, width:origLogoWidth, height:origLogoHeight, delay: 0.3, time:1.5, transition:"easeInOutBack", onComplete: function() {
		Tweener.addTween(preLogo.letters, {delay: 0, time:0.7, transition:"linear", alpha: 1, onComplete: function() {
			preLogo.strapMask.x = preLogo.strapMask.x - preLogo.strapMask.width - 5;
			preLogo.strapGradient.alpha = 1;
			Tweener.addTween(preLogo.strapMask, {delay: 0.5, time:1.5, transition:"easeInOutQuad", x:-1, width:(preLogo.strapMask.width + 40)});																			
			Tweener.addTween(preLogo, {delay:2, time:3.5, transition:"easeInOutCubic", alpha: 0, onStart: preInitSite, onComplete: preLoadCleanUp});																			
		}});																			
	}});
	
	/*
	
	// Using TweenLite
	
	var preLogoTimeline:TimelineLite = new TimelineLite({onComplete:preInitSite});
	
	preLogoTimeline.append(TweenLite.to(preLogo.percent, 0.2, {alpha: 0}));
	preLogoTimeline.append(TweenLite.to(preLogo, 1.5, {x:preLogoX, y:preLogoY, width:origLogoWidth, height:origLogoHeight, ease:Back.easeInOut}));
	preLogoTimeline.append(TweenLite.to(preLogo.letters, 0.7, {alpha:1, onComplete: function() {
		preLogo.strapMask.x = preLogo.strapMask.x - preLogo.strapMask.width - 5;
		preLogo.strap.alpha = 1;
	}}));
	preLogoTimeline.append(TweenLite.to(preLogo.strapMask, 1.5, {x:-1}));
	preLogoTimeline.append(TweenLite.to(preLogo, 2, {alpha:1, ease:Back.easeInOut}));
	*/

}

function preLoadCleanUp():void {
	removeChild(preLogo);
}

function preInitSite():void {
	stage.removeEventListener(Event.RESIZE, preResizeHandler);
	addChildAt(l, 0);
}

preInit();

Open in new window

0
Comment
Question by:socross
  • 6
  • 4
11 Comments
 
LVL 9

Expert Comment

by:asaivan
ID: 33597984
What are you targeting as your Flash Player version?
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33598079
I could see that you are not registering for the Error event in your loader. Therefore you will not recieve any notification upon error. As you said it work on safai/mac. Try listening for the ioError:IOErrorEvent or securityError events.

At the bottom of this page is some sample code:
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html

0
 
LVL 1

Author Comment

by:socross
ID: 33598160
Thanks for your replys.

asaivan - I am targeting version 9.0.0

ChristopherDutz - I will look into that now

s
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:socross
ID: 33598234
ChristopherDutz - i dont get any IO Errors, but thats only testing through flash player, how would i test this in the browser environment?

Thanks

s
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33598259
Try the IE Developer Toolbar and have a look at what's actually loaded. Another thing I'd give a try is to load it in the Safari on the Windows machine. Perhaps you are having trouble with the security sandbox. Another option would be to install a debug version of the flash-player on the IE because that player is a real PITA when it comes to complaining about problems :-)
0
 
LVL 1

Author Comment

by:socross
ID: 33598335
I get fairly lost there, is there any chance you might be able to take a look at the site:

http://tinyurl.com/32m85lp

Thanks

s
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33603885
Well I tried the url you sent me with Chrome and IE 8 and it worked like a charm ... and I would really like to spend my holidays in the carribean on that boat! ;-)
0
 
LVL 1

Author Comment

by:socross
ID: 33603952
Ha, yes me too!

It does work perfectly well in most browser combinations. But it fails when on flash version 10.0.45.2, which according to stats is used by 22% of users.

What do think I should do seeing as it's the flash player that is the issue? Or is it something in my code that I need to update?

Thanks

S
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33604274
Well I doubt its a real application issue. Have you tried this combination on other systems? Perhaps only your one plugin version is broken? Unfortunately I don't have that particular version, so I can't try it :-(
0
 
LVL 1

Accepted Solution

by:
socross earned 0 total points
ID: 33610249
Thanks for all you input guys, turns out it was entirely my fault, I had left the code from a memory profiler in the main swf file that it was loading in, it was this that was conflicting with the swfaddress / flash player combination. Got that removed and works a dream.

Thanks

S
0
 
LVL 1

Author Closing Comment

by:socross
ID: 33610259
Problem solved
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now