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

Flash coding question "if yes then go, if no then skip"

Community Beginner ,
Jun 12, 2019 Jun 12, 2019

Its taken me all to get what little I have done but I've hit a block. I'm doing an OC "interactive" reference sheet(or flash in this case anyway) I (after hours and hours) manage to get it where you hit play, it runs a few frames, you read hit next and it plays for a few frames again(like read at your own pace I guess anyway again) where I'm at now I need two buttons. If you hit button one, It will take you to the next stage but if you hit button 2 it will skip that stage and go to the one after it instead. I'm using adobe flash cs2 and action script 3 (no I'm not updating, the cs2 is from when they still used the one time payment computer CD's that you just bought at the store and kept installing where ever you needed it and it wasn't a monthly/yearly subscription) 

from what I've read/understand I cant attach functions to the buttons them selves soooo any help would be awesome

586
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

Community Expert , Jun 17, 2019 Jun 17, 2019

Since you don't have code snippets I pulled some code for you. It is in AS3.

/* Click to Go to Next Frame and Stop

Clicking on the specified symbol instance moves the playhead to the next frame and stops the movie.

*/

button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);

function fl_ClickToGoToNextFrame(event:MouseEvent):void

{

nextFrame();

}

/* Click to Go to Previous Frame and Stop

Clicking on the specified symbol instance moves the playhead to the previous frame and stops the movie.

*/

butt

...
Translate
LEGEND ,
Jun 12, 2019 Jun 12, 2019

Does CS2 not have Code Snippets? There should be one that does exactly what you're wanting to do.

Code snippets for beginning ActionScript 3 programmers and designers | Adobe Developer Connection

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 Beginner ,
Jun 13, 2019 Jun 13, 2019

not that I've found sadly. I've looked everywhere I can think of in the program and online for its code snippits and it doesnt seam to be a thing

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 ,
Jun 17, 2019 Jun 17, 2019

Since you don't have code snippets I pulled some code for you. It is in AS3.

/* Click to Go to Next Frame and Stop

Clicking on the specified symbol instance moves the playhead to the next frame and stops the movie.

*/

button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);

function fl_ClickToGoToNextFrame(event:MouseEvent):void

{

nextFrame();

}

/* Click to Go to Previous Frame and Stop

Clicking on the specified symbol instance moves the playhead to the previous frame and stops the movie.

*/

button2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame);

function fl_ClickToGoToPreviousFrame(event:MouseEvent):void

{

prevFrame();

}

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 Beginner ,
Jun 20, 2019 Jun 20, 2019
LATEST

Thank you!

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 ,
Jun 19, 2019 Jun 19, 2019

HI,

According to a new Adobe announcement... I think its actually illegal now to use anything but the latest version and the previous version. But I won't tell anyone!

In order for your buttons to work

1. You have to create two buttons, place them on the stage, and give them different instance names.

Then you can create a new layer and call it "ACTIONS" and press F9 to open the Actions panel.


You will have to create two event listeners. lets assume your buttons are named "button1_btn" and "button2_btn" (adding the "_btn" helps let you know its a button, and lets actionscript enable code hints as you type)

/************* EVENT LISTENERS ***************/

button1_btn.addEventListener(MouseEvent.CLICK, myFirstFunction);

button2_btn.addEventListener(MouseEvent.CLICK, mySecondFunction);

/* this is a comment tag... text between "/*" and closing tag "*/" is not read by Flash or Actionscript, and it used for notes to self so you can remember what the code is doing, or add any other info you need. The name "myFirstFunction" above, can be called whatever you want, name it something that makes sense to you, that is the function it will call by the EXACT name as you can see I use again below . The if the user clicks the button with instance named "button1_btn" it will look for the mouseEvent "CLICK" pressing mousing and letting go, and then it will perform the instructions within the function "myFirstFunction", and same for button2_btn except of course it calls a different set of instructions (or function) */

/************* FUNCTIONS ***************/

function myFirstFunction (event:MouseEvent):void

{

gotoAndStop(4);

}

function mySecondFunction (event:MouseEvent):void

{

gotoAndPlay(6);

}

/* you can put the frame number, or better to create a label and put the label name in quotes

like gotoAndStop("myLabel") but if you dont know how, use frame number for now. And you can have the playhead go to frame 4 and stop or go to frame 4 and play.  */

Hope that helps!

cheers,
mark

headTrix, Inc. | Adobe Certified Training & Consulting
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 Beginner ,
Jun 20, 2019 Jun 20, 2019

I'm cheap lol I have enough subcriptions I don't need another espically when I still have the install code from when I bought cs4 but thank you! and yes you've both been helpful!

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