Time Delay Help Please

Discussion in 'Jiggy Runtime Development' started by Ragon90, Apr 26, 2008.

  1. Ragon90

    Ragon90 New Member

    Joined:
    Mar 5, 2008
    Messages:
    43
    Likes Received:
    2
    Hello i need some help in making a time delay, with the application i'm using i want this to happen

    Write Line of Code to Page
    Wait 1sec
    Write Line of Code to Page
    Wait 1sec
    Write Line of Code to Page
    Wait 1sec

    etc etc, so yeah basically i want it to stop every 1 second or so, then write the next line, thing is, what i've tried so far hasn't worked, because i need to use a Text Label, like this:

    so yeah i was hoping someone might know like one line of code i could put in between these text labels, i bet it's something stupid like "wait" lol

    thanks for any help you may offer!
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    You need a timer. I have no idea how your would create one in Jiggy, but if it helps, if you can cross reference things, in Objective-C, it is NSTimer that you are looking for.
  3. OneFan

    OneFan Active Member

    Joined:
    Feb 25, 2008
    Messages:
    949
    Likes Received:
    67
    Device:
    iPhone 4 (White)
    ITS REAL EASY...

    Timer

    Timer( double seconds )

    Creates a new timer that will fire every “seconds” seconds. When a timer is created it is stopped - it won’t fire until you call start.

    parameters

    seconds The interval for the timer. Note that this is a double, so you can specify intervals less than a second.
    start

    void start( double seconds )

    Will start the timer, with an optional new interval. After the interval elapses, the onTimer function will be called.

    parameters

    seconds Optional new interval. If you don’t specify it or pass 0, the timer will continue using the interval passed to its constructor.
    stop

    void stop()

    Stops the timer. It will not call onTimer until after you call start again.
    Events
    onTimer

    callback void onTimer( Timer timer )

    This handler will be called every time the timer fires.

    parameters
    timer The timer that fired.​
  4. Ragon90

    Ragon90 New Member

    Joined:
    Mar 5, 2008
    Messages:
    43
    Likes Received:
    2
    erm ok....that isn't very useful...but thanks anyway...i think i'm probably not reading something right..
  5. PAEz

    PAEz New Member

    Joined:
    Jan 29, 2008
    Messages:
    201
    Likes Received:
    10
    heres some source that uses timers, it comes from.....
    http://jiggyapp.com/download/examples/

    and heres the code.....
    Code:
    Plugins.load( "UIKit" );
    
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor = [ 1 , 1 , 1 , 1 ];
     
    var mainView = new UIView();
     
    window.setContentView( mainView );
    
    
    var pb = new UIProgressBar( [10 , 40 , 300 , 48 ] );
    
    pb.setStyle( 1 );
    
    mainView.addSubview( pb );
    
    var progress = 0;
    
    var timer = new Timer( 0.5 );
    
    timer.onTimer = function()
    {
    	progress += 5;
    	
    	if ( progress > 100 )
    	{
    		timer.stop();
    		log( "DONE" );
    		return;
    	}
    	
    	pb.setProgress( progress / 100 );
    }
    
    timer.start();
    You dont do like a wait....you create your text label, then make code like this update the label every second or whatever.
  6. Ragon90

    Ragon90 New Member

    Joined:
    Mar 5, 2008
    Messages:
    43
    Likes Received:
    2
    thanks!

    that looks really cool, i've put it into the program lol!
  7. Ragon90

    Ragon90 New Member

    Joined:
    Mar 5, 2008
    Messages:
    43
    Likes Received:
    2
    Timer( 100 )
    void start( 100 )
    void stop()

    how does this work exactly? i tried using it, and it said 'start is not defined'

    so, i'm not quite sure where to put the first line, can anyone help?

Share This Page