Solved

How to delay creationComplete

Posted on 2010-08-20
3
508 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
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Youtube video error 30 837
Consuming WCF in Action Script 3 [ flash Develop ] 3 335
Flash Player Action Script Error 1090 5 224
File conversion question 5 131
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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…
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 what frame rate is, how to control it and what effect it has on the video.

713 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