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

How to add actionscript to buttons

New Here ,
May 11, 2009 May 11, 2009

i m using adobe flash cs3 profficional software version...in my flash document i m using some buttons but i didn't get action script to that buttons...what is the reason?....can any one solve this problem....plz give me the reply....

TOPICS
ActionScript
964
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

correct answers 1 Correct answer

LEGEND , May 12, 2009 May 12, 2009

When you posted, it was likely bedtime for most of the folks that help here, so you need to be patient.  And the folks that help here do it voluntarily, so try not to complain if your posting doesn't get answered in a timely manner.  Very often a posting isn't answered because it doesn't provide any information that might help solve it--people don't realize that they need to help others to help them.  And yours would fall into that category.

What code are you using that is not working and where a

...
Translate
New Here ,
May 12, 2009 May 12, 2009

hi guy whats up!!!!!!!!!!.....till now i didn't get any answer!!!!!!!!!!!!.............

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
LEGEND ,
May 12, 2009 May 12, 2009

When you posted, it was likely bedtime for most of the folks that help here, so you need to be patient.  And the folks that help here do it voluntarily, so try not to complain if your posting doesn't get answered in a timely manner.  Very often a posting isn't answered because it doesn't provide any information that might help solve it--people don't realize that they need to help others to help them.  And yours would fall into that category.

What code are you using that is not working and where are you placing it?

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 ,
May 12, 2009 May 12, 2009

just simple button program...whenever click that button one image will be displayed...that is my logic....each button have one image...but the script is not working....how to add actions to buttons?...

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
LEGEND ,
May 12, 2009 May 12, 2009

Show your script code.

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 ,
May 12, 2009 May 12, 2009

stop();

aboutus_btn.onRelease=function(){

gotoAndPlay(1);

gotoAndStop(3);

gotoAndStop(2);

gotoAndStop(6);

gotoAndStop(4);

gotoAndStop(5);

};

contactus_btn.onRelease=function(){

gotoAndPlay(2);

gotoAndStop(1);

gotoAndStop(3);

gotoAndStop(6);

gotoAndStop(4);

gotoAndStop(5);

};

employment_btn.onRelease=function(){

gotoAndPlay(3);

gotoAndStop(1);

gotoAndStop(2);

gotoAndStop(6);

gotoAndStop(4);

gotoAndStop(5);

};

movies_btn.onRelease=function(){

gotoAndPlay(4);

gotoAndStop(1);

gotoAndStop(2);

gotoAndStop(6);

gotoAndStop(3);

gotoAndStop(5);

};

technology_btn.onRelease=function(){

gotoAndPlay(5);

gotoAndStop(1);

gotoAndStop(2);

gotoAndStop(6);

gotoAndStop(4);

gotoAndStop(3);

//gotoAndStop(0);

};

but it is not working properly..........can u plz give me short length code.....

logic is:each button display one image....

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
LEGEND ,
May 12, 2009 May 12, 2009

aboutus_btn.onRelease=function(){

gotoAndPlay(1);

gotoAndStop(3);

gotoAndStop(2);

gotoAndStop(6);

gotoAndStop(4);

gotoAndStop(5);

};

Each of those gotoAndStop commands are telling the timeline that the code is in to go to different frames, so ultimately, you are likely ending up on the last in each list.  Code is executed almost instantaneously, before frame movements occur, so you won't see things moving from frame to frame if that is what you expect.  What do you really want?

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 ,
May 12, 2009 May 12, 2009

i want :-whenever click one button it will be displayed one image....i have 7 buttons & 7 images...(each button have different image)

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
LEGEND ,
May 13, 2009 May 13, 2009
LATEST

I am going to have to make assumptions about your design since you haven't explained how you have it assembled.

From what I've already mentioned, hopefully you understand that you can only use one gotoAndPlay for a button function for it to be sensible.

aboutus_btn.onRelease=function(){

     gotoAndPlay(1);

}

And, assuming your images are one per frame and they are in frames 1 thru 7, and each button is supposed to go to a specific frame, then it will be better to use....

aboutus_btn.onRelease=function(){

     gotoAndStop(1);

}

Either version of the code I showed are valid for making a button work, as long as the code is on the timeline in the presence of the buttons.  So if your buttons are not working, then you may not have given them the instance names your code uses.  Instance names are assigned by you in the properties panel, they are not the names you give them in the library.

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