Solved

AS3 Event.COMPLETE Bug

Posted on 2010-09-03
11
614 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
Comment Utility
What are you targeting as your Flash Player version?
0
 
LVL 20

Expert Comment

by:ChristoferDutz
Comment Utility
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
Comment Utility
Thanks for your replys.

asaivan - I am targeting version 9.0.0

ChristopherDutz - I will look into that now

s
0
 
LVL 1

Author Comment

by:socross
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:socross
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Problem solved
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to how to record live broadcast.

763 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

8 Experts available now in Live!

Get 1:1 Help Now