?
Solved

AS3 Event.COMPLETE Bug

Posted on 2010-09-03
11
Medium Priority
?
622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

777 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