A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Making a button refresh? - Active button

  1. #1
    Blood elf, or PHP guru... hmmm Paradoxz's Avatar
    Join Date
    Aug 2001
    Location
    Califorina
    Posts
    589

    Talking

    on (rollover) {
    tar = tar +10;
    }

    When i use this on a button, is there any way to make it keep repeating? Such as as long as the mouse is over the button, it adds +10 in like second intervals?

    Thank You,
    -Dox'

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    There may be an easier way to do it, but one way would be to drop the button into a MC. Detect when the mouse is over the mc with something like:

    onClipEvent(enterFrame) {

    x_pos = _root.myMovieClip._xmouse
    y_pos = _root.myMovieClip._ymouse
    etc. }

    When that condition becomes true, your button variable could begin incrementing and stop when it is no longer true.

  3. #3
    Senior Member
    Join Date
    Apr 2002
    Location
    Hong Kong
    Posts
    171
    Another option is to use setInterval.
    Assume that you have a mc called myButton (I know - names are not my strong point) that contains a text field called counter, then:
    Code:
    var IntervalID;
    var myCounter = 0;
    myButton.onRollOver = function() {
    	IntervalID = setInterval( incrementMe, 1000 , this);
    };
    myButton.onRollOut = function() {
    	clearInterval(IntervalID)
    };
    function incrementMe(me) {
    	me.countText.text=(myCounter++);
    };
    This will bump up the counter every second while the mouse is over the mc.

  4. #4
    Blood elf, or PHP guru... hmmm Paradoxz's Avatar
    Join Date
    Aug 2001
    Location
    Califorina
    Posts
    589

    Docka!

    Thanks Docker, I was messin with Set Interval earlier.. couldnt get it to work.. I'll try your way.

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