A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [HELP] Loops - other then For Loops

  1. #1
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167

    [HELP] Loops - other then For Loops

    Hello everyone,

    I just have a quick question. Is it possible to use a loop OTHER then the for loop?

    This is what I want to accomplish. I have a dynamic text box, and a button. When you hold down the button the dynamic text box increases by 1 (number starting at 1940)

    I want it to keep going until you release the button and thought to do so with a loop

    If someone could please tell me how to go about doing this, it would be greatly appreciated

    Thanks

  2. #2
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    This would be my approach

    use enter frame to add the number to your initial value. The button will set a holder clip to a frame that contains an empty clip with the onEnterFrame actions, release will set the holder clip back to the first frame, which doesn't have the empty clip, thus not taxing the processor unneccesarily. Check the attachment.
    Last edited by bitsk308; 01-10-2008 at 01:32 PM.

  3. #3
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    bitsk308

    Sorry but Im working in Flash MX, and so cannot open your attachment though I appreciate the effort you made

    If you could perhaps explain to me what you did in the .fla?

  4. #4
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Here's an MX and MX04 version (though some things may have been lost in the down conversion, I can't test 'cause I don't have MX.)

    Here's the basic Idea:
    1. Define a _root variable for your text field, say yourNumber:Number = 1940.
    2. Make an empty movie clip and give at instance name of "control_mc"
    3. On the first frame of control_mc but a stop() call.
    4. On frame 2 of control_mc, add another blank mc, called node_mc.
    5. Give node_mc (which should only exist on frame 2) the following code;
    onClipEvent(enterFrame){
    if(_root.yourNumber < " your max number"){
    _root.yourNumber += 1;
    }
    }
    6. Make a button with the following code:
    on(press){
    _root.control.gotoAndStop(2);
    }
    on(release){
    _root.control.gotoAndStop(1);
    }

    This should get 'er done.
    Last edited by bitsk308; 01-10-2008 at 01:32 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center