A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Click once, do something, click again, do another

  1. #1
    FK's Giant Steve_w_V's Avatar
    Join Date
    Mar 2003
    Location
    San Jose, California
    Posts
    2,113

    Click once, do something, click again, do another

    code:
    if (_global.step == "level1") {
    _root["subB"+gh].onRelease = function() {
    for (var i = 0; i<6; i++) {
    _root["text"+i].html = true;
    _root["text"+i].htmlText = doc.firstChild.childNodes[i].attributes.name;
    trace(_global.step);
    }
    for (num=0; num<6; num++) {
    _root["text"+num].text = doc.firstChild.childNodes[this._name.substr(4, 5)].childNodes[num].attributes.name;
    }
    };
    if (_global.step == "level1") {
    _global.step = "level2";
    }
    if (_global.step == "level2") {
    root["subB"+gh].onRelease = function() {
    getURL(doc.firstChild.childNodes[this._name.substr(4, 5)].childNodes[num].attributes.info);
    for (num=0; num<6; num++) {
    _root["text"+num].text = doc.firstChild.childNodes[this._name.substr(4, 5)].childNodes[num].attributes.name;
    }
    };
    if (_global.step == "level2") {
    _global.step = "level1";
    }
    }
    }


    Ok, now that you've seen that, here's my problem. I have a bunch a buttons named "subB0", "subB1", etc. In a loop, I'd like, when clicked, have all of them switch their duties. "gh" is the loop incremental value (=0, <3)

    _global.step's default is "level1". If that equals level 1 when the person clicks on it, I'd like the corresponding textboxes to do one thing. However, once clicked, _global.step needs to change to "level2". If _global.step equals "level2" when clicked, it needs to do something else.

    I've tried with the code above to no avail. Any idea?
    The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...

  2. #2
    Re Member websam's Avatar
    Join Date
    Jul 2000
    Location
    Australia (VIC)
    Posts
    660
    Code:
    task=0;
    
    btn.onRelease=function(){
      swith(task){
         case 0:
           // do something while task=0
           task=1;
           break;
         case 1:
           // do something while task=1
           task=0;
           break;
      }
    }
    with this structure, you can dynamically code your flash to handle almost infinite number of tasks with one button.

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