Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple button script not working

New Here ,
Apr 02, 2013 Apr 02, 2013

I am using AS2 and need help figuring out why this simple button script is not working:

stop();

buttonWS1.onRelease = function(){

                    gotoAndStop("Stage1and2_Boss",4);

};

buttonWS2.onRelease = function(){

                    nextFrame();

};

//end

My buttons are the square letter-puzzles below. They are images that I converted to "symbols" (specifically, buttons). I put their names as above (buttonWS1, buttonWS2, etc.) in the "instance names" boxes.

I have no idea what is going on. Please help!

Screen Shot 2013-04-02 at 9.54.32 PM.png

TOPICS
ActionScript
722
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 02, 2013 Apr 02, 2013

buttonWS1 is problematic but buttonWS2 should work.  does it advance the timeline that contains that code to the next frame?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 02, 2013 Apr 02, 2013

Thanks for the response. Neither works. Neither advances the timeline. I have to put a continue button on the page for it to advance.

The strange thing is that at one point I got one of the puzzles to work as a button. But then i changed all the images, and I can't get even one of them to work.

Any ideas?

Message was edited by: sjc77

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 03, 2013 Apr 03, 2013

go to the frame that contains your button code.

click on the object you think is buttonWS2. 

1. check the properties panel to see if buttonWS2 is listed as that button's instance name.

2. make sure there's no code attached to that button

if both those check out, add a trace statement to that button's onRelease and check if the onRelease executes by clicking it and watching for the trace output.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2013 Apr 03, 2013

Hi -

1. Yes, buttonWS2 is the instance name

2. The only code attached to it is the code I pasted above.

3. onRelease does not execute because my trace statement does not appear in the output

Here is the modified code for buttonWS2:

buttonWS2.onRelease = function(){

                    trace("clicked!");

                    nextFrame();

};

Question: It shouldn't matter if I have commented-out code within that set of codes should it?:

buttonWS2.onRelease = function(){

          //if (puzzleschosenarray[0] == 2 || puzzleschosenarray[1] == 2) {

          // cannot be chosen -- make button non-functional

          //}

          //else{

                    //puzzleschosenarray[roundnumber-1] = 2;

                    trace("clicked!");

                    nextFrame();

          //}

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 03, 2013 Apr 03, 2013

your commented code looks good.

now take and attach 2 screenshots.  one that shows your timeline and buttonWS2 selected on stage and shows the properties panel so i can confirm buttonWS2 is named correctly and a second that shows your timeline and the actions panel with the latest buttonWS2.onRelease.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2013 Apr 03, 2013

properties panel.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2013 Apr 03, 2013
LATEST

action panel.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines