A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS2 CS4 - Simple Button script not working

  1. #1
    Member
    Join Date
    Jan 2005
    Location
    Earth
    Posts
    81

    AS2 CS4 - Simple Button script not working

    I've got a really simple script that on a button click, changes the alpha of a set of mc's from 0 to 100, then on second click changes back to 0. The first click works fine but for some reason the second click isn't working. The button needs to stay "on" as well so I've got the buttons in a mc with named frames "on" and "off". Here's the code:
    Code:
    Actionscript Code:
    ltBlueButton_mc.ltBlueOff_btn.onRelease = function(){
        contentMain.page1_mc.Pg1LtBlue_mc._alpha = 100;
        contentMain.page2_mc.Pg2LtBlue_mc._alpha = 100;
        contentMain.page3_mc.Pg3LtBlue_mc._alpha = 100;
        contentMain.page4_mc.Pg4LtBlue_mc._alpha = 100;
        contentMain.page5_mc.Pg5LtBlue_mc._alpha = 100;
        contentMain.page6_mc.Pg6LtBlue_mc._alpha = 100;
        contentMain.page7_mc.Pg7LtBlue_mc._alpha = 100;
        ltBlueButton_mc.gotoAndStop("on");
       
        };

    ltBlueButton_mc.ltBlueOn_btn.onRelease = function(){
        contentMain.page1_mc.Pg1LtBlue_mc._alpha = 0;
        contentMain.page2_mc.Pg2LtBlue_mc._alpha = 0;
        contentMain.page3_mc.Pg3LtBlue_mc._alpha = 0;
        contentMain.page4_mc.Pg4LtBlue_mc._alpha = 0;
        contentMain.page5_mc.Pg5LtBlue_mc._alpha = 0;
        contentMain.page6_mc.Pg6LtBlue_mc._alpha = 0;
        contentMain.page7_mc.Pg7LtBlue_mc._alpha = 0;
        ltBlueButton_mc.gotoAndStop("off");
       
        };

    I know the fix is simple, I'm just not seeing it. All suggestions welcome!

  2. #2
    Senior Member
    Join Date
    Jan 2010
    Location
    England
    Posts
    268
    this is why i only use buttons on there own. never inside anything else.
    try puttin
    Code:
     _root.
    at the beginning of yoru instance names, or try targeting withthe target icon, maybe try putting
    Code:
    this
    . before it.

    just suggestions.
    might be addicted to flash...
    _______________________________________

  3. #3
    Member
    Join Date
    Jan 2005
    Location
    Earth
    Posts
    81
    Thanks Steve. I did away with the named frames and used _visible = true and _visible = false with the two buttons on the same frame. that did the trick!

  4. #4
    Senior Member
    Join Date
    Jan 2010
    Location
    England
    Posts
    268
    aye but its not the EXACT same thing. and it wouldnt tween it to make it look better, my advise is to use the tween class to make it fade in and out. make them into functions the ncall tehm when your buttion is pressed. and to make it easier forget the button and just have a movieclip. thats what i usually do and have onRollOver if i want a nice hover effect.
    might be addicted to flash...
    _______________________________________

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