Hi Steve,

That got it quick and easy.  Thanks a lot. Marking as solved.

Regards,

Angelo


________________________________
From: valdhor <valdhorli...@embarqmail.com>
To: flexcoders@yahoogroups.com
Sent: Saturday, 24 October, 2009 4:11:35
Subject: [flexcoders] Re: Delay / Pause between script executions

  
Two ways....

1.  Add the repeat count parameter to the constructor:

labelTimer = new Timer(5000, messages.length) ;

2.  A little math is required (Arrays are zero based and the first event 
triggered will have a count of 1. We need to take that into account):

<?xml version="1.0" encoding="utf- 8"?>
<mx:Application xmlns:mx="http: //www.adobe. com/2006/ mxml" layout="vertical"
    creationComplete= "onCreationCompl ete()">
    <mx:Script>
        <![CDATA[
            private var labelTimer:Timer;
            private var messages:Array = [    "This is my first message", 
                                            "This is my second message", 
                                            "This is my last message"];
            
            private function onCreationComplete( ):void
            {
                labelTimer = new Timer(1500);
                labelTimer.addEvent Listener( TimerEvent. TIMER, 
labelTimerTriggered );
                labelTimer.start( );
            }
            
            private function labelTimerTriggered (event:TimerEven t):void
            {
                if(labelTimer. currentCount > messages.length - 1)
                {
                    labelTimer.stop( );
                }
                timerLabel.text = messages[(labelTime r.currentCount - 1) % 
messages.length] ;
            }
        ]]>
    </mx:Script>
    <mx:Label id="timerLabel" />
</mx:Application>

--- In flexcod...@yahoogro ups.com, Angelo Anolin <angelo_anolin@ ...> wrote:
>
> Hi Steve,
> 
> Thanks for the sample code.  I was able to come up with something quite 
> similar to what you have posted.
> 
> One question still remains, though.  I tried to issue a timer.stop() command 
> when for example, all the text values have been displayed in the label 
> control, but the timer event does not seem to stop.
> 
> How to specifically stop the timer once all the messages have been displayed?
> 
> Thanks.
> 
> Angelo
> 
> 
> 
> 
> ____________ _________ _________ __
> From: valdhor valdhorlists@ ...
> To: flexcod...@yahoogro ups.com
> Sent: Saturday, 24 October, 2009 2:07:16
> Subject: [flexcoders] Re: Delay / Pause between script executions
> 
> 
> Here is a simple example:
> 
> <?xml version="1.0" encoding="utf- 8"?>
> <mx:Application xmlns:mx="http: //www.adobe. com/2006/ mxml" layout="vertical"
>     creationComplete= "onCreationCompl ete()">
>     <mx:Script>
>         <![CDATA[
>             private var labelTimer:Timer;
>             private var messages:Array = [    "This is my first message", 
>                                             "This is my second message", 
>                                             "This is my last message"];
> 
>             private function onCreationComplete( ):void
>             {
>                 labelTimer = new Timer(5000); // 5 Seconds
>                 labelTimer.addEvent Listener( TimerEvent. TIMER, 
> labelTimerTriggered );
>                 labelTimer.start( );
>             }
> 
>             private function labelTimerTriggered (event:TimerEven t):void
>             {
>                 timerLabel.text = messages[labelTimer .currentCount % 
> messages.length] ;
>             }
>         ]]>
>     </mx:Script>
>     <mx:Label id="timerLabel" text="This is my first message"/>
> </mx:Application>
> 
> HTH
> 
> 
> Steve
> 
> 
> --- In flexcod...@yahoogro ups.com, Angelo Anolin <angelo_anolin@ ...> wrote:
> >
> > Hi Flexcoders,
> > 
> > I know this may sound very elementary but I cannot figure the hell out of 
> > me how to achieve this.
> > 
> > I have a label control.  I want to display different messages after every 5 
> > seconds, such as:
> > 
> > myLabel.text = "This is my first message"
> > // Need to delay for about 5 seconds here
> > 
> > myLabel.text = "This is my second message"
> > // Need to delay for about 5 seconds here
> > 
> > myLabel.text = "This is my last message"
> > 
> > I cannot figure out how to properly use the pause or timer utilities in 
> > achieving this.
> > 
> > Any idea would be appreciated.
> > 
> > Thanks.
> > Regards,
> > Angelo
> >
>

   


      

Reply via email to