Solved

How to delay creationComplete

Posted on 2010-08-20
3
502 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
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
andreMariano earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

762 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

11 Experts available now in Live!

Get 1:1 Help Now