Solved

How to delay creationComplete

Posted on 2010-08-20
3
512 Views
Last Modified: 2013-11-11
I use this code.. but it does not function....

Help me please!!!
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	initialize="init()"
	creationComplete="completed()">


private function init():void 
{
   setTimeout(timerCompleted, 10000);                                
}
            
private function timerCompleted():void
{
  dispatchEvent(new Event(Event.COMPLETE));
}
			
private function completed():void
{
   Alert.show("completed !!!!!!!!!!!!!!!!!!!");
}

Open in new window

0
Comment
Question by:jorgeani
[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
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
andreMariano earned 250 total points
ID: 33487855
1º  Event.COMPLETE!= FlexEvent.CREATION_COMPLETE
2º you are already setting the function do dispatch in the creationComplete  in the <mx:Application>
3º Sorry, but, does not make any sense to delay the creationComplete, because only when all the components are created in the screen that you can interact with then...
anyway... You can try this (Remember that you wont delay the creationComplete ;) ):
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	initialize="init()" >

<mx:Script>
	<![CDATA[
		import mx.events.FlexEvent;
		import mx.controls.Alert;
		import mx.rpc.AsyncDispatcher;
		
		private function init():void 
		{
		   setTimeout(timerCompleted, 1000);     
		   addEventListener(Event.COMPLETE,completed,false,0,true);   
		                           
		}
		            
		private function timerCompleted():void
		{
		  dispatchEvent(new Event(Event.COMPLETE));
		}
					
		private function completed(ev:Event):void
		{
		   Alert.show("completed !!!!!!!!!!!!!!!!!!!");
		}
	]]>
</mx:Script>
</mx:Application>

Open in new window

0
 
LVL 1

Expert Comment

by:jth_92
ID: 33489533
The following would also work but because of your timeout it is delay about 1 sec:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	initialize="init()" >

<mx:Script>
	<![CDATA[
		import mx.events.FlexEvent;
		import mx.controls.Alert;
		import mx.rpc.AsyncDispatcher;
		
		private function init():void 
		{
		   setTimeout(timerCompleted, 1000);     
		   addEventListener(Event.COMPLETE,completed,false,0,true);   
		                           
		}
		            
		private function timerCompleted():void
		{
		  dispatchEvent(new Event(Event.COMPLETE));
		}
					
		private function completed(ev:Event):void
		{
		   Alert.show("completed !!!!!!!!!!!!!!!!!!!");
		}
	]]>
</mx:Script>
</mx:Application>

Open in new window

0
 
LVL 1

Assisted Solution

by:jth_92
jth_92 earned 250 total points
ID: 33489543
Sorry about that last post andreMariano for copying. I didn't paste the write thing.
   
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
				initialize="init()" creationComplete="completed(event)">
	
	<mx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.controls.Alert;
			import mx.rpc.AsyncDispatcher;
			
			private function init():void 
			{
				setTimeout(timerCompleted, 1000);				
			}
			
			private function timerCompleted():void
			{
				dispatchEvent(new Event(Event.COMPLETE));
			}
			
			private function completed(ev:Event):void
			{
				Alert.show("completed !!!!!!!!!!!!!!!!!!!");
			}
		]]>
	</mx:Script>
</mx:Application>

Open in new window

0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

623 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