A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: looping through buttons?

  1. #1
    Junior Member
    Join Date
    Apr 2005
    Posts
    3

    looping through buttons?

    hi there i would like to create a loop.

    i have 6 button movieclip for now but i will have more later.

    on each movieclip i have an actionscript.

    on (release) {
    loadMovie("pop_1.swf", 1);
    _level0.b1.enabled = false;
    _level0.b2.enabled = false;
    _level0.b3.enabled = false;
    _level0.b4.enabled = false;
    _level0.b5.enabled = false;
    _level0.b6.enabled = false;
    _level0.b7.enabled = false;

    }
    i'm trying to create a loop for the _level0.b1.enabled = false;.
    i tried to read up on loops but couldn't implement it...lol

    thank you

  2. #2
    Space Monkey daarboven's Avatar
    Join Date
    Sep 2001
    Location
    in the basement boiling soap...
    Posts
    217
    like this?
    code:

    number_of_buttons=12;
    for(i=0;i<number_of_buttons;i++){
    current=eval("_level0.b"+i )
    current.enabled= false;
    }

    :::i am jacks complete lack of surprise:::

  3. #3
    Junior Member
    Join Date
    Apr 2005
    Posts
    3
    daarboven thank you very much for that code.

    i have built that code into a function.

    script on frame.

    number_of_buttons=4;

    _global.deact = function() {
    for(i=0;i<number_of_buttons;i++){
    current=eval("_level0.b"+i )
    current.enabled= false;
    }
    };

    and on the buttons

    on (release) {
    loadMovie("pop_2.swf", 1);
    deact();
    }

    i got this working in a test file call test.fla

    but i can't seem to get it working in my gallery.fla
    the only difference is the path where

    current=eval("_level0.gallery.b"+i )

    when i test the file and click on the debug its says my path
    is _level0.gallery.b1.

    so i'm i doing something wrong?

    i'm using 2004mx
    Attached Files Attached Files

  4. #4
    Junior Member
    Join Date
    Apr 2005
    Posts
    3
    got it to work ....thank you

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