dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: buttons function only on main timeline?

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    121

    buttons function only on main timeline?

    it seems that whenever I place a button inside of a MC and then place it on the mainstage, it never works.

    once I take the button outside of the MC and just place it on the main timeline, it works. However, this can be mildly inconvenient to the organization of my movie.

    why is this? is there a way to get it to work inside of a MC?

    thanks.

  2. #2
    Left-Handed Flash User mickbrit55's Avatar
    Join Date
    Nov 2003
    Location
    NJ USA
    Posts
    1,375
    Hiya

    Yes, you have to make sure that the button knows where to send the playhead though.

    To access the main timeline remember to use the "_root" global reference :


    on (release) {
    _root.gotoAndStop(20); // places the playhead on F20 on the main timeline
    }


    Mick

  3. #3
    Senior Member
    Join Date
    May 2001
    Posts
    121
    Thanks! so this is an addressing issue.

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    121
    so actually, I am attaching the actionscript to the timeline, not the button.

    this is the code. it is an alpha rollover:
    button1.onRollOver = function() {
    fadeoutInterval = setInterval(fadeout,5);
    function fadeout(){
    if (button1._alpha <= 50) {
    clearInterval(fadeoutInterval);
    }else{button1._alpha -= 1;}
    }
    }

    button1.onRollOut = function(){
    fadeinInterval = setInterval(fadein,5);
    function fadein(){
    if (button1._alpha >= 100.0) {
    clearInterval(fadeinInterval);
    button1._alpha=100;
    }else{button1._alpha += 1;}
    }
    }

    when I put the button straight on the main timeline, it works fine. but when i put it inside of a movie clip, the alpha fade doesn't work.

  5. #5
    Senior Member
    Join Date
    Feb 2003
    Location
    Out There...
    Posts
    162
    Hmm. Mickbrit was right to say you're having a pathing issue. What it looks like you should do is for wherever you have button1._alpha or whatever, put MC.button1._alpha , where MC would be the movieclip where the button is residing. Now I havn't looked too extensively at it, but you might also want to try a this._alpha .

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