Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to delay creationComplete

Posted on 2010-08-20
3
Medium Priority
?
515 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 1000 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 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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 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…
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 how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

879 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