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

Adobe Flash Pro CS5 ActionScript?

New Here ,
Nov 12, 2010 Nov 12, 2010

How do I make "Play" and "Stop" buttons in Flash Pro CS5.  I have drawn  the buttons but I don't know how to select the frames, convert them to  symbols and make the buttons usable.  I've seen some of the codes but I  don't know how to use or apply them.  After I type something in, the  buttons aren't usable in the .swf because there is no "OK" button in the  area where you type the code.  Could someone take me through it step by  step?

TOPICS
ActionScript
9.2K
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 ,
Nov 12, 2010 Nov 12, 2010

When I'm in the Code Snippets area, I try to make  aplay button but it says, "To add code for this object, please select an instance of the object in either the main timeline or in a Movie Clip timeline.  Which frames should the stop and play be in?  What do I need to click with the mouse and what buttons do I need to type to get it to work?

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
Explorer ,
Nov 12, 2010 Nov 12, 2010

1. Draw your button (a rectangle, circle, your graphic)

2. Select it and choose Modify> Convert to symbol

3. Choose type "Button"

4. Give it an instance name on the "Properties" window, like my_btn

5. Create a new layer and place your cursor on the first frame for the layer you just created

6. Press F9 in Windows or open the Actions window Windows > Actions

7. Write code to indicate the function for the button:

function playVideo(event:MouseEvent):void

{

     myVideo.play();

}

my_btn.addEventListener(MouseEvent.CLICK, playVideo);

function stopVideo(event:MouseEvent):void

{

          myVideo.pause();

}

myStop_btn.addEventListener(MouseEvent.CLICK, playVideo);

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 ,
Nov 12, 2010 Nov 12, 2010

Thanks for the reply.  I'm a little farther along.  My Stop button is named button_2.  It doesn't stop it in the swf.

The error I'm getting is what do I put where you put "myVideo" in your sample?  The file name (before.fla) doesn't work.  Error reads: Symbol 'Symbol 3', Layer 'Actions', Frame 1, Line 7    1061: Call to a possibly undefined method pause through a reference with static type flash.display:SimpleButton.

Thanks!

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
Explorer ,
Nov 12, 2010 Nov 12, 2010

you get that error because you are calling a "stop" method on a button, and that does not exists.

Describe a bit more what you are building.

There are some good tutorials to get you moving on Flash and AS3 at lynda.com, you might want to check them out.

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 ,
Nov 12, 2010 Nov 12, 2010

I thought that was the idea of the code though.  My understanding was the codes are commands to get my animation to play or stop.  I know how to convert the buttons to symbols and select them.  F9 opens the actions menu.  It won't let me do anything on the first screen, but I'm able to add code in the Code Snippets area.  I've watched several tutorial vids on youtube on the subject and I can't see what I'm doing wrong.  It may be in the selection of the frames.  For example, you'd want the stop button command to be in the first frame where you could then hit the Play button to re-launch the animation from the beginning.  Is the above code the Stop command or no?  Why wouldn't that action exist?  It's frustrating.  I feel like it's one of those things that takes just a minute to do but I don't know what I'm doing wrong.

I'm building an underwater scene.  The animation is just a fish moving across the stage from right to left.  I want to put the Stop and Play buttons in the upper area of the file.

Thanks for the reply!

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 ,
Nov 12, 2010 Nov 12, 2010

copy your code and paste it here.  then copy and paste the error message after clicking file/publish settings/flash and ticking "permit debugging".

the error message will contain a reference to the line number containing the error.  highlight that line of code when you paste your code here.

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 ,
Nov 12, 2010 Nov 12, 2010

Will update later.


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 ,
Nov 12, 2010 Nov 12, 2010

Error: Scene 1, Layer 'Actions',  Frame 30, Line 1    1061: Call to a possibly undefined method play  through a reference with static type flash.display:SimpleButton.

It  keeps teeling me to use this code inside the "Code Snippets" area: Line  1:movieClip_1.stop();  It's one of those deals with instructions grayed  out and surrounded by asteriks so they can be deleted.

And  that's all I've got.  I need to know how to select which frames to  stick the actions in and also the correct code to get them to work.   Thanks for all the help everyone!

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 ,
Nov 12, 2010 Nov 12, 2010

copy your code on frame 30 and paste it here.

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 ,
Nov 13, 2010 Nov 13, 2010

The sample they gave me is what I used: button_3.play();  This is the play button.  I don't know where to put the play button, but frame 30 is my final frame.  Can I have a code sample again?  Also what frame should the play button be in?  I never got what all the commands were supposed to be.

Thanks for the help everyone!

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 ,
Nov 15, 2010 Nov 15, 2010
LATEST

that's not going to work, as you know.

what is that you want to "play" ?  the timeline that contains the code?  a movieclip that's on-stage?  a video?  something else?

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