A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] How do i control a function from a button inside a mc

  1. #1
    Senior Member
    Join Date
    Sep 2001
    Posts
    189

    [F8] How do i control a function from a button inside a mc

    This is the code for my cycle function on the main timeline:

    var intID:Number;
    var frame:Number = 0;

    function playOn(){

    if(frame == 2){
    frame +=8;
    }else{
    frame +=10;
    }
    if(frame > 40){
    frame = 2;
    }
    gotoAndStop(frame);
    }

    intID = setInterval(playOn,2000);

    ---------------------------------------------
    I want my button to clear the function and then stop where it is. Shouldn't this work?

    on (release) {
    _root.clearInterval(intID);
    _root.stop();
    }

  2. #2
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    Dont write codes in your button. Use frames to write your codes.
    example:

    In frame#5:
    yourButton.onRelease=function(){
    clearInterval(intID);

    }

    Do you have the button script, the 'function' and setInterval declaration on the same frame?

  3. #3
    Senior Member
    Join Date
    Sep 2001
    Posts
    189

    Unhappy

    i do now. The problem is when i click say button 5, it does three things:

    1. Clears the interval
    2. Stops on frame 5 (of main timeline)
    3. Calls up a frame ("playbutton") inside a mc with a play button (playbutton_btn) on it.

    The challenge right now seems to be trying to get 'playbutton_btn' to restart the function/interval again.

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