dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: for loops on buttons

  1. #1
    on the up and up phaty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    677

    for loops on buttons

    i tried to be clever but shot myself in the foot.


    got this script. for my buttons. now the goto and stop isnt working. everything is assigned but the gotoAndStop is the same for all the buttons. i swear it was working at one point. but not now. any ideas ?

    Code:
    for(var i = -1; i < 3; i++){
    		_root["clip_"+i].onPress = function(){
    			gotoAndStop("label_"+i)
    			trace(this)
    			check_home  ()
    			ComingFromHome = false
    		}
    }
    "I am a professional web designer,
    is that regular fries or super size....."

    www.designtoday.info - twitter

  2. #2
    on the up and up phaty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    677
    ok i fixed it lol - just name the label the same as the clip names. then right this in the goto and stop script. it might be conflicting but i dont care it works lol mouahahahaahahaha.

    of course if anyone else could suggest and alternative then that would be great

    Code:
    for(var i = -1; i < 3; i++){
    		_root["clip_"+i].onPress = function(){
    			gotoAndStop(this)
    			trace(this)
    			check_home  ()
    			ComingFromHome = false
    		}
    }
    "I am a professional web designer,
    is that regular fries or super size....."

    www.designtoday.info - twitter

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    hi u cud change the original code to

    Code:
    for(var i = -1; i < 3; i++){
    
                     _root["clip_"+i].id = i;
    		_root["clip_"+i].onPress = function(){
    			gotoAndStop("label_"+this.id)
    			trace(this)
    			check_home  ()
    			ComingFromHome = false
    		}
    }
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  4. #4
    on the up and up phaty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    677
    what is the id?
    "I am a professional web designer,
    is that regular fries or super size....."

    www.designtoday.info - twitter

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