dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Simplify Repeating Pattern Question

  1. #1
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476

    Simplify Repeating Pattern Question

    How do I simplify this if this goes on and on into the hundreds?
    Code:
    button1.onRelease = function() {
        gotoAndStop("frame1");
    };
    button2.onRelease = function() {
        gotoAndStop("frame2");
    };
    button3.onRelease = function() {
        gotoAndStop("frame3");
    };
    If possible, could someone show me exactly how this should be written?

  2. #2
    Senior Member
    Join Date
    Aug 2001
    Location
    Egypt
    Posts
    332
    If you have 100 buttons:

    Code:
    for(var i=0; i<100; i++) {
       this["button"+i].onRelease = function() {
          this.gotoAndStop(("frame"+i));
       }
    }
    regards,
    Hamza.

  3. #3
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476
    Hamza,
    I'm sorry, I thought I could make this easier by simplifying my code. Here's the real thing with pb1 and "tp1" being the variables. I couldn't figure out how to use what you showed me.
    Code:
    _level1.thumbScroller.tmp_mc.stripOne.pb1.invisibleButton.onRelease = function() {
    	_level1.gotoAndStop("tp1");
    };

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