Do we still need buttons in Flash CS3?

I was at the Melbourne User Group last night and the 2nd presentation was from Cartoon Smart on Flash Actionscript 3. An interesting point was raised as to why do we still need buttons in Flash when movieclips can behave like buttons. Back home, I tested it and yes, movieclip can behave like button. All it needs is to have multiple frames (with stop action) and at the properties inspector, set the behavior to Button. An advantage of this approach is that we can target which frame it is going to stop (like gotoAndStop(“Down”)). This is something we cannot do with a typical Flash button. So the Flash button is really just a time saver for now.

 Updated (14_06_2008): Demo file now at the link below. The file has been updated to include roll-over state of the movieclip:

http://rapidshare.com/files/122335261/3_MovieclipButtons.fla.html

 

~ by brianchau on July 20, 2007.

188 Responses to “Do we still need buttons in Flash CS3?”

  1. Hi Brian, I appreciated the effort and time you put in to present last night, It was very good, especially liked when you were honest about the little bits that were not working as intended. Overall I think Fireworks is a fantastic tool, I shall consider it. Though I would love to purchase Master Collection, it is not worth it for me at the moment.

    When and If I start working independantly I would almost definitely get Master Collection. Could you asked them to throw in Flex Builder 3 and any other Adobe dev tools not already inside?

    I also think it will be beneficial to have an united usergroup event at least yearly, so we can explore what is happening on both ends and network with people using often similar technologies differently.

    Thanks again!

  2. Hi Brian, I agree with you on this post, re the flash button or button class only being a time saver… because I too use movieClips for buttons, mostly because of the control over the movieClip, and can have some very interesting tweens between button states (up, down, over, etc).

    I’ve just spent the weekend learning AS3 and have found that it is now even easier to control multiple buttons (movieCLips) at one time with the same method.

  3. We really don’t need buttons anymore. Movieclips are more than fine. As far as the button symbol being a time saver, yes, in a way.

    I use a JSFL script to create a button template in a movieclip. If I have something selected on the stage, it assumes that is the object that will be my button and puts it in the created button, even naming the movieclip the name of the object I have selected.

    It is worth looking into JSFL if your seeking speed. If you have an extra 2 minutes, then build the movieclip out manually. In the end, the movielcip buttons offer far more power than the button symbols.

  4. Actually that trick has been around since flash 6, and configuring movieclips to behave like buttons is by far more powerfull… so i do agree with you on some level… however… the reason why i think they left our trusty pal button, is for designers who don’t really want or need to know how to setup a movieclip in such an advanced way…

    good old buttons still save people a lot of time…

  5. I don’t you’d find any devs using buttons (unless they were using the Button component), but buttons are still highly used by designers.

  6. I just got CS3, and i cant add actions to buttons, mine or the ones it came with? Is this correct?

  7. Ryan, if you are creating flash movie using AS3, you can longer attached actions (scripts) onto the button itself. That is deprecated in AS3. You can only add script onto the frame. And remember that no “onRelease” anymore. Use the addEventListener() method.

  8. I am also having button troubles and am not familiar with action scripting i have read all of these posts and created a movieclip with a stop action. all i want to do is have my button go to and play the next scene. Why does this have to be sooooooooo difficult? can anyone please tell me how to make a button or clip go the next scene? I have wasted my entire morning on this very simple procedure and have gotten no further than i was 4 hours ago please help.

  9. brian, check your mail. I have sent you a sample file fla to try.

  10. brianchau could you also send me the sample file please?

  11. This sounds great, could you send me the sample file too? Many thanks.

  12. Mariano and Tachana, fla in your mail boxes. Cheers.

  13. could you send me the file as well

    Thank you

  14. brianchau …you are ever popular! i am in the same quandry as the above… any chance of sending me the file also? ( i have searched the internet for an answer, you seem to be the only person in the universe currently with the key 🙂 ) many thanks

  15. Geo and Zuz, file in your mail box.

  16. brianchau, can you send me too the .fla file to practice with the new script for buttons action

  17. my e mail: sr.vidal@gmail.com

  18. Adrian, it is in your amil box.

  19. Wow, I also have the same problem, Brian can you send me the fla also. capric621@yahoo.com

  20. Brian can you please send me this file, before I too tear out my hear. Thanks.
    kressmi@yahoo.com

  21. Brian… can you send me a sample too… please!

  22. hate to jump on the band wagon… but Brian it would sure help me out too!
    Thanks
    ehughes_tsam@hotmail.com

  23. Rich, Michael, Bis and Kristopher. File in you mail box.

  24. Brian,

    Sorry to ask, but can you also send me the sample .fla file? Much appreciate!

  25. Forgot email, it is: orange_hair_kid@yahoo.com

  26. Hi Brian,

    I was hoping you’d post the file up so that you won’t have to send everyone the file individually. Unfortunately, I’m also in the same situation. Not so newbish to Flash but pretty newbish to Actionscripting. I was hoping to learn this on my own but errors abound aplenty. Er, could you please send me the file too??? Very very very much appreciated.

    artistjp2000@yahoo.com

  27. Unfortunately the blog doesn’t allow attachement of zip or fla file, etc. So I can only email the fla to individual email address.

  28. hi Brian,

    I’m so glad to have found your website. I was struggling w/this for the last 3 days and still haven’t gotten it…would you mind sending me the file also? seems like you have a rich resource! my email is mariak@andrew.cmu.edu.

    thanks for sharing so freely w/others!

    Maria

  29. I’m having the same problem …… Can you PLEASE help me??
    I just want the button to go to the next scene when clicked.

    I am also having button troubles and am not familiar with action scripting i have read all of these posts and created a movieclip with a stop action. all i want to do is have my button go to and play the next scene. Why does this have to be sooooooooo difficult? can anyone please tell me how to make a button or clip go the next scene? I have wasted my entire morning on this very simple procedure and have gotten no further than i was 4 hours ago please help.

  30. Linday, file in your mail box. In regard to how to make a button click to go to the next scene. The simpliest is to grab a prebuilt button, put onto the stage. Name the button instance as something like “myButton_btn” and add the following code (assuming you are coding in AS3) onto the timeline:

    myButton_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    gotoAndStop(1, “scene1”);
    }

    That action would cause the movie to jump to frame 1 of “scene1”.

  31. Hi Brian…Yes you are the only person to have the solution to this. I have a project due today and this is the last hang up. I use Flash to create a menu to launch other Flash .exe’s that are converted PowerPoints. The simply call a batch file. In the other version I simply used:

    on (release) {
    fscommand(“exec”, “filename.exe”);
    }

    Can you please send me the file so that I may learn how to do this in the new Flash CS3? Much thanks! jsaab@nw3c.org

  32. I won the battle but lost the war. I created a layer for all my actions and put this script in (renaming functions and buttons for each one, 8 total…)

    myButton_button_01.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    fscommand(“exec”,”filename.exe”);
    }

    I simply renamed the call doClick2, doClick3, etc. for all 8 buttons. It works, but not without a few hiccups…

    1 – there is about a 5+ second delay when the buttons open separate .exe Flash files (that are PowerPoint conversions). They open faster when you double-click them right in Windows Explorer.

    2 – there are two presentations that are simply .pdf’s, in the past, I have been about to use the

    fscommand(“exec”,”filename.bat”);

    and in the .bat file one line of code that looks like this…

    @start filename.pdf

    This normally would invoke Reader to open, but will not work in Flash CS3. I have tested the batch file by double-clicking it in Windows Explorer and it works fine there, but Flash CS3 seems to have issues with it.

    Any ideas appreciated.

  33. Jaycen, I don’t know why there is a 5 sec delay in your case, I created the following demo script:

    blue_btn.addEventListener(MouseEvent.CLICK, doClick);
    brown_btn.addEventListener(MouseEvent.CLICK, doClick);
    gold_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    switch (e.target.name){
    case “blue_btn”:
    fscommand(“exec”, “blueApp.exe”);
    break;
    case “brown_btn”:
    fscommand(“exec”, “brownApp.exe”);
    break;
    case “gold_btn”:
    fscommand(“exec”, “goldApp.exe”);
    break;
    }

    }

    They responded instantly. Is your delay about launching the app or the delay is on the button responding to mouseClick. You can do a simple trace output to test that.

    In regard to pdf, can you do a simple test to see if the bat file is executed? If yes, then we need to look into the bat statement. I am not all that familiar with bat these days.

  34. Jaycen, I have found an article on issue and solution to calling bat from within fscommand. You have want to check this out:

    http://www.northcode.com/blog.php/2007/08/14/FSCommand-EXEC-is-Broken-in-Flash-CS3

  35. Can you point me in a direction to where I can find where each piece of the code is located in the action script library?

  36. brian, not sure if I understand your question. Do you mean the code that is in my demo file? If yes, they are at the timeline.

  37. Can you send me the example file. Can you post where each piece of the code is located in the Actions-(library)?

  38. Hello Brian, could I have the file as well ? Thanks a lot !

    bohemar@gmx.ch

  39. Hi, I’m having the same problem, I want to make some buttons go to certain scenes, I’m usign AS2, can someone help me?

    adrinoname@yahoo.com

  40. I have 5 scenes in my movie. I have user input to a question. My button is supposed to run and if else statement to determine which scene to go to. My code is below taken from above and edited for my variables. It does not work. If anyone can help me figure out where my code is wrong I would appreciate it.

    btn2.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void{
    if (input == “miller”)
    {
    gotoAndStop(“1”, ‘TryAgain’);
    }
    else
    {
    gotoAndPlay (“1”, “winner”);
    }
    }

    If necessary I can provide the .fla file.

    Many thanks.

    My e-mail is drpepperguy@gmail.com

  41. Adriana, for AS2, the script would be something like:

    my_btn.onRelease = function(){
    gotoAndStop(“sceneTwo”, 1);
    };

  42. Marcus,

    The gotoAndStop statement should be something like:
    gotoAndStop(1, “SceneName”);

    assuming you want to go the the scene “SceneName” frame number 1. If you put “” around the 1, it would mean a frame label named “1”.

  43. Brain..I’m in the same boat I made 4 buttons and trying to get them linked with 4 differnt layers with scene? not sure what the file is but could you sent it to me so I can look it .. ? thanks Aubrey aedge@sandia.gov

  44. Hi Brian…Could you please send me the file as well?

    info@mpuglisi.com

    Thank you.

  45. Brian, i need to make a movieclip button with “extra” states on top of the normal up, down, over…i made some frame labels named “active” and “inactive”…i have a movieclip that i told to act as a button in the property inspector…when i say instanceName.gotoAndPlay(“active”) i get error #1069….something about the simplebutton class…any ideas?

  46. Gena, a sample file is in your mail box. The trick here is not to set tye movieclip as button in the Properties Inspector, but to do it in Actionscript as instancename.buttonMode = true;

  47. hi brian, can i have the fla file too? I have been hanging around the button problem for days…thks so much.
    my email: irainstop@yahoo.com

  48. BRIAN!!! You are the answer of our problems! can i have the fla file too?, why something so basic should be complicated??
    Thank You So Much!!

  49. I was surprised by so many who need help on this topic. Totally unexpected. As there is no way to attach the fla to the WordPress blog, I will reply to each request by emailing the source file individually.

  50. Hi Brian,

    I seem to be having the same problem as many others here and I’m very far from being a professional Flash user. Just to be clear, all I want to do is create a button that, when clicked, starts a simple animation that has a stop action in the first frame.

    Before all I would do is add a the following code to the button:
    on (release) {
    gotoAndPlay(2);

    }
    Now that doesn’t seem to work. Can you help me with this, or point me to a place where I can learn an alternative.

    Thanks so much for your help,
    Chris

  51. Chris, for Actiosncript 3 you can no longer put script onto the button itself. It is possible, though not recommended for Actionscript 2. So below would be the code under AS3:

    stop(); // to stop the playhead at frame 1

    myButton_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    gotoAndPlay(2);
    }

    The above code should be placed at frame 1, ideally on a separate layer. myButton_btn being the name of the button that is on the stage.

  52. Hi I am having the same problem as everyone else. I seem to get the action script to be on the button so I can link to a new scene. I am going to bash my face into the screen if I don’t figure this out soon… could you email me the sample file too??? When I click on the button the action panel is up but everything is grayed out…when I click on the fame I get wicked syntax errors…

    FREAKIN OUT!!

  53. an intereting column – While using AS2, I always used movieclips to act as buttons, but since using AS3, I have gone back to using Buttons…. maybe i alone have missed the point somewhere 😉
    ps nice and clean site you have here.

  54. Hi Brian… Popular aren’t you…
    I’m learning Flash now for the first time and am a couple of weeks in. I seem to be getting the hang of it but am struggling with one silly thing. I have a button that is animated when in mouse over state, but upon releasing the mouse button, it replays the mouse over state. I just want it to stay as the “down” state I have set. What script do I use to tell it that on Release, go to frame dwnframe. (In this case I have called the frame dwnframe where I want it to stay).

    Thanks so much

  55. Adrian, if you have a button object, all you need is to have the over state with an animation. There is no code required to trigger the mouse over state. As soon as the mouse is away from the button, it will go back to its up state. However, if you are using a movieclip as button, you may have to register for the MOUSE_OVER and MOUSE_OUT events.

  56. Sorry Brian… I don’t think I explained myself clearly. I can get the mouse over state to play an animation no problem, and yes, when I click it does perform the “down” state also, but when I release the button it will replay the animation… I don’t want that to happen. I want it to stay on the same image as the “down” state when the mouse button is released. Does that make more sense? The button in question links to another site and I don’t want to see the animation play again befor the new page loads… I just want the image to stop even after clicked. I hope that’s clearer. I figured perhaps I would have to use a movie clip instead of a button object and then just label frames. then with the correct script i can get it to play a certain frame on release as well as open the new URL.

    Thanks for your help Brian

  57. Adrian, from what you described you would need to have a toggle behavior for the button which is not supported for a simple button object. You would need to turn a movieclip into a button to control the states of the button when mouse is moved out of the button.

  58. Yeah… That’s what I thought. Thank you very much for that. As you know, I am very new to Actionscript so only if you get a chance, could you show me an example of the syntax I would use to make the Button\Movie Clip go to a specific fram on release.

    Let’s say the button is called “btn” and the frame is called “rls”.

    Thanks in advance

  59. Adrian, check your mail box. I have sent you a sample file. The buttons (movieclips) though do not have animation.

  60. Brian, can you send me the sample file of how to make the buttons work. All I want is 2 buttons one that goes to the next frame and one that goes to the previous frame. Why does it have to be so difficult? please e-mail to charwebart@yahoo.com

  61. Charlotte, you would use the following codes for a simple button that on click, would go to the next frame:

    stop();

    myButton_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    nextFrame();
    trace (currentFrame);
    }

    Replace nextFrame() with prevFrame() to go back to previous frame.

  62. Hi Brian

    Just wanted to thank you for the FLA you sent me with the Buttons. It was very helpful. Could you recommend a book or site that will help me learn about AS3? Please keep in mind I am learning from scratch. I am in IT so I understand computers, but have had no programming experience what so ever.

    Thanks again Brian

  63. Adrian, this is one where I don’t really know as I have not read any AS3 books yet. I learnt so far by reading the HELP doc from the program. I have recently bought the “Actionscript 3 Design Patterns” book but haven’t started yet. That is for my X’mas reading 🙂
    I hope others may comment on what AS3 books they have read and make some suggestion.

  64. Hey Brian, could you please send me that AS3 sample file? evileyes@rogers.com

    Thanks.

  65. Hello Brian, I am a designer returning to the belly of flash once again, yet finally grasping some actionscripting, I am trying to build me and a friend a website, graphically it’s looking nice, however, it seems I am having the same trouble as everyone else. Could you possibly send me an email with the .fla as well? Thanks so much!

  66. My original post was really about if we can get by without buttons. It didn’t mean we should all do so, especially for new Flash users. If all we want is to have a simple button to do something, like go to another frame,etc, then simply create a button, name it like myButton_btn. Then add the following code at the scene timeline frame:

    myButton_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    // put you code here….
    }

  67. Hi Brian,
    I have searched all over and can’t find a solution to my problem. Maybe you can help 🙂 im using AS3
    I have a series of buttons that once rolled over, play an audio file. I managed to succeed with this, but it seems that the sound file doesnt stop playing on the mouse out. I added the sound to the ‘over’ state of the button, but the music continues to play when the buttons arent activated.
    I think there must be some code that I should add to the main timeline, but i’m not sure what.
    any help would be much appreciated 🙂

  68. Krystie, For simmple button you don’t have to add any code. Simply add the sound file at the Up state and set the Sync setting at the properties inspector to “Stop”, Then at the Over state add the sound file and set the Sycn setting to “Start”. That’s all you need to do.

  69. Hey Brian, could you please send me that AS3 sample file?

    Thanks

  70. Thanks Brian, I got it to work. Really appreciate your help, you don’t get help like this for free in the real world!!

  71. One more question before my buttons are complete, what is the code you use in AS3 now for visibility? Say my button is called ‘inv_btn’ and once it is clicked I want it to dissappear.
    does it look something like this

    inv_btn.addEventListener(MouseEvent.MOUSE_UP,dothis);
    function dothis (event:MouseEvent){
    visibility=false
    }
    last question i promise!

  72. Krystie, You would need the following code:
    inv_btn.addEventListener(MouseEvent.MOUSE_UP, doUp);

    function doUp(e:MouseEvent):void
    {
    e.target.visible = false;
    }

    🙂

  73. Brian – Could I ask you to forward a copy of the sample file mentioned above to my email:

    gnarlie@gmail.com

    Thank you.

  74. Hey Brian,
    This is crazy, we can’t have you manually forwarding the file to the whole universe, will you have the time for anything else?
    why not upload it somehwere on a free filesharing website and give out the url?
    by the way, could you please send me the file 🙂

    many thanks!!!

  75. I have found a free ftp hosting solution and have uploaded the fla file at:

    http://rapidshare.com/files/79740269/3_MovieclipButtons.fla.html

    I will update the top post to highlight the link.

  76. Brian,
    Many thanks for the file.
    Sorry to bother you again, but is it possible to define a hit area (larger / smaller) other than the size of the graphic of the movie-clip button itself?
    I have tried to no success…or maybe this is something that only works with the button symbol?

  77. Brian,

    I came across this looking for a way do reduce the file size of an already designed project. They design them, and give them to me to make them work. I went to the button .fla you uploaded and wanted to thank you. I was in the first stages of seeing what might work, and you have not only helped with this project but inspired my designers with more to consider. I just wanted to let you know you are greatly appreciated. Will send you a link to the final when it’s done.

  78. Hello Brian! Same as everyone else here, I’m having trouble in CS3 fro buttons. I hope you can help. I have 2 btns on a flash banner, one daytime another nighttime. 1 btn needs to start the daytime mc and stop at frame 59. The other btn is to start the nightime and stop at frame 120. Can you please help with the action scripting.

  79. Joanne, the following code assumes you have a button (day_btn) and a movieclip (day_mc) on the stage:

    day_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    day_mc.gotoAndStop(59);
    }

  80. Hello again! Is there a way that I can send you my flash file so that you can see the code and layers? Something is not right and don’t know what it is.

  81. I get this error message:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at pinna2_fla::MainTimeline/doClick()

  82. Hello I have tried this code for my buttons:

    stop(); // to stop the playhead at frame 1
    day_btn.addEventListener(MouseEvent.CLICK,Clickday_btn); //set up day button
    nite_btn.addEventListener(MouseEvent.CLICK,Clicknite_btn); //set up night
    button

    //function for day event
    function Clickday_btn(e:MouseEvent):void
    {
    gotoAndStop(2);
    }

    //function for night event
    function Clicknite_btn(e:MouseEvent):void
    {
    gotoAndStop(61);
    }

    but there is an error of:
    1120: Access of undefined property button.

  83. Oops. Joanne, you have the line: button
    after the nite_btn.add……
    Hence the error

  84. Your the best Brian! Sometimes you need to step away from the hair-pulling situation and have someone else find your minor error!

    Thanks for your help!

    What did you think of the flash swf? How would you have improved it? If you don’t mind me asking!

  85. Can you refer me to a book that shows code to different things you want flash animation do?

  86. Joanne, I don’t know what books to recommend as everyone’s learning styles are different. My suggestion is always to go to a bookshop and browse the books and see if you can learn a thing or two from the book in the short time there. If you can, it probably is one that is good for you.

  87. brianchau- I’m struggling with CS3 and reverted to a simple button which has an html link as the path. I can open my SWF file and the button works fine but when I open my html page the button doesn’t work… are you able to help me? Thanks in advance for your time.
    ((the swf file is http://www.la-mason.com/header.swf and the button is the “YES” button in the top right hand corner. The html page with the SWF file in it is http://www.la-mason.com))

  88. AMM, first make sure your publish setting local playback security is set to “Access network only”. This is a new security implementation of swf movie. The AS3 code would be something like:

    yes_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    navigateToURL(new URLRequest(“http://www.adobe.com”), “_blank”);
    }

  89. Hi Brian,

    I have searched everywhere and I cant seem to figure this out for as3. I have 7 scenes and buttons on each scene for previous scene and next scene working perfectly. I cant however figure out how to have the last scene go back to scene 1. I gave it a name “startHere” but when I click that button it does not see that startHere is part of that scene (which is scene 7). All it seems that I need to do is tell it to go to scene 1! But how?! I really have searched everywhere for this. Thanks!!!

  90. Scratch that last! I got it!

    I changed the default name ‘scene 1’ to ‘firstScene’ than used this in the buttons function!

    function scene7NextHandler ( evt ){
    gotoAndPlay(1,”firstScene”);
    }

    it worked perfectly. Thanks!

  91. Hi Brian,

    I am trying to teach Flash and 1/2 my students have Macromedia’s Flash and the others have Adobe’s CS3. Making buttons work with a simple action script in Macromedia’s version is simple but I cannot make a simple button with a “gotoandplay” scenario in CS3. As many others, could you please send me some help.

    Thanks

  92. Rodney, just some clarification. First, you can still use Flash CS3 to create AS2 movie like what you have been doing with Flash 8. Nothing is changed. But to take advantage of the latest features of AS3, that is when you need to program a bit differently. See below:

    test_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    gotoAndPlay(1);
    }

  93. Hey Brian,

    Am trying to create a simple flash in cs3 where each frame has a button that links to the next frame. I have called the button in the first page myButton_btn1, in the second page myButton_btn2 etc.

    I placed the script below in a new layer on the first frame:

    stop();
    myButton_btn1.addEventListener(MouseEvent.CLICK, doClick);
    myButton_btn2.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    nextFrame();
    }

    It works fine for myButton_btn1, but not for myButton_btn2. Can you please explain what I am doing wrong? Your help would be much appreciated!

    Chantelle.

  94. Chantelle, button2 doesn’t exist on frame 1 yet hence the error. Indeed how even bother to have a new button on each frame when the action is the same. I would simply have a button (myButton_btn) that spans across all frames. Script would then be:

    stop();
    myButton_btn.addEventListener(MouseEvent.CLICK, doClick);
    function doClick(e:MouseEvent):void
    {
    nextFrame();
    }

  95. Hey Brian! I was just wondering …do you work for Adobe? I think it’s so great that you help us like this. I go on your site weekly just to see what others are having problems with and am amazed on how you know all the answers! Also how did you teach your self CS3 so fast? Your the best!

  96. Joanne, I do work for Adobe although this is a personal blog so I am quite free to express my personal opinion. I learn a lot when reading and trying to answer questions. And thanks for your encouragement.

  97. hey!! somebody please help me!… i’m at the middle of an important project and all i want is to know the code to link a button to an SWF file in Flash CS3… it’s been 3 days now triyng to do that… pleeease.. @_@

  98. by the way… the name of the button is inicio_btn and the SWF file is pag-principal.swf… i don’t know what to do anymore… if someone could help me i would apreciate it :)…

  99. As promised, the site is finished (mostly) and the buttons work great.

    http://www.johnnyatomicstudios.com

    Thanks again for posting the .fla

  100. Maurizio, you would need to create a urlrequest object to point to the external swf and a loader object to load the swf. See the code below:

    load_btn.addEventListener(MouseEvent.CLICK, doClick);

    var loader:Loader = new Loader();
    var requester:URLRequest = new URLRequest();

    function doClick(e:MouseEvent):void
    {
    requester.url = “external.swf”;
    loader.load(requester);
    addChild(loader);
    }

  101. ok.. this may sound stupid but… how can i create a url request object? where do i put it?… how can i create a loader object? where do i put it?…

    i know… i’m stupid… i’m sorry haha… if you could let me know that i’ll be thankfull for the rest of my life bro! @_@

  102. and i can’t create a stop(); in the same fotogram… why??… do i need an extra layer?… this is very complicated…

  103. ok… mm… i think i did it!.. but i still can see the first swf file behind!… how can i make it dissapear?

  104. Maurizio, if you want to hide the movie underneath, the simplest way would be a create a graphic layer on the loading swf that would be used as the background layer.

  105. Brian,

    I’m a web developer on a smalll note at work and now that we can’t add action script to buttons I’m lost. I had buttons doing everything from loading flv, swf, html, and other websites. I even bought a download code for a button so I could allow people to download files from our site. If I upgrade my files to AS3 I will be in a fix.

    How can I create code for a button so it can load files on my server or go to websites.

    This is an example of what I have on many buttons:

    on (release) {
    getURL(“filename.html”, “_blank”);
    }

    How do I now do this on a button in AS3?

  106. Jent, I have a new post that showed just that. Go to:

    Learning Actionscript 3 for Flash developers

  107. Here’s a stumper for you, (maybe?)

    I have 5 buttons below is the code I am using on each of the button layers.

    // START OF SCRIPT

    stop();

    // The stop function stops the movie timeline on the current frame.

    function onIntroClick(evt:MouseEvent):void {
    gotoAndPlay(57);
    }

    // We have created a function. This is triggered when the End User clicks the button.
    // This is followed by an Event, which is a Mouse Event.
    // And because we aren’t returning anything, we write void.
    // Between our braces we tell the player what we want it to do. In this case we want to goto
    // and play a frame. My intro is on frame 2, so i have typed 2.

    svcsbtn.addEventListener(MouseEvent.CLICK,onIntroClick);

    // We have added an Event Listener, so that when we Click the intro_btn, the onIntroClick
    // function is triggered.

    // END OF SCRIPT

    Of course the code above is for a btn with an instance odf symbol
    2 with a label of svcsbtn

    Each of my 5 btns have a different label and goes to a particular
    keframe.

    I am trying to migrate a website created in mx 2004 YEARS AGO…
    TO CS3 AS3

    pLEASE HELP AS i AM CRAZY WITH THIS. Also if you can send the file I would be greatful. I need to get a handle on this new code….

    Thanks,

    Edub9

  108. edub9, your above code seems alright to me. Anyway, I have a sample file about basic button interactivity that I posted at:

    Learning Actionscript 3 for Flash developers

    Hope that helps.

  109. Hi Brian,

    I am a new user of flash cs3. I too have a problem of AS3 for a button. I need this to go from 1 scene to another. COuld you aslo mail me the sample file u have mailed to others… your help is much appricitated!

    Vips

  110. Vips, please refer to my other post where I have put some demo files.

    Learning Actionscript 3 for Flash developers

  111. Hi i am using flash cs3 and i need to make a button that when i click on it upon release the button moves . can someone please help

  112. please email me with the answer if you have it ,thank you.

  113. manny, it would be something like:

    test_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    e.target.x = 200;
    }

    If you want to button to animate to the new position, you would need to write some script to handle the Event.ENTER_FRAME event.

  114. HEY i have an assignment to finish in 1 day. i hav a problem with buttons! and i was wondering if you could help. i have produced a animation with many layers and all i want to do now is add a play again button at the end. i am using AS3 on flash CS3. i have made a button named “button1” and hav been using this code on the last frame of my last layer:

    button1.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    gotoAndPlay(1);
    }

    but i keep getting the error message “access of undefined property button1”

    i hope you could help. i hav been trying 4 days!

    thankyou!

  115. minal, the error message usually appeared if flash couldn’t find a button named “button1” on the stage at the time when the code is executed. Are you sure you have a button of that name at the stage. Bear in mind that AS3 is case-sensitive. How about create a simple movie to test to isolate the problem.

  116. hey, names mike as you may have figured, lately ive been into flash and such as my class is doing it and I want to make a interactive movie for kicks. However that doesnt fare well since im using cs3 and it was complicated as it was before and now Its just so much worse im getting really frustrated.

    If someone could take me step for step on how to make a button at the end of a scene by which pressing leads to a separate scene( I want at least 2 buttons(choices) at the end of each scene)

    to Test I put 30 frames in each scene and a symbol and a button
    I had the symbol move across the screen and put in the stop command and it prevented it from going to the next scene. Then I tryed to give the button a command in its own separate layer but it said no actions could be given to the button(in previous versions it could) so I followed some other internet instructions and put a stop in the second layer in the first scene as well as in the first frame but from there I got so messed up, I cant get this to work, and please help me out here.

    thanks in advance, work with me im great at animation but actionscript is new and just so complex and confusing to me.

    Ive posted many places and made SO MANY internet accounts in the past 24 hours please help… Nobody can..lol

  117. Michael, you should have codes like below at the last frame of scene 1:

    stop();

    myButton.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    gotoAndPlay(1, “Scene 2”);
    }

  118. I tryed that and was given 3 reported errors being
    -1093: Syntax error.
    -1084: Syntax error: expecting rightparen before 2.
    -1093: Syntax error.

    I had put the moving symbol on layer one and the button and actionscript on the other otherwise adding the button to the same layer breaks the motion tween which would be a problem in a actual flash movie id make.

    So with specifics, what layer do I put what on and such. Please bear with me and I really appreciate your reply as is.

    The “source” for these three things was “gotoAndPlay(1, “Scene 2″);”

    ty again and please repsond

  119. Michael, you are right to put button and code on separate layers. As for the error, be careful with the quote (“):

    the code should be:
    gotoAndPlay(1, “Scene 2”);

    Now, try not to copy and paste from the above but type it out yourself in flash code panel. The wordpress has a strange way of displaying quote(“).

  120. only one error this time.. im REALLY sorry and I appreciate this again.
    1120: Access of undefined property myButton.

    I figured sicne I heard it somewhere this might have to do with the ”instance name” but I cannot find it ANYWHERE even after checking online and looking where it should have been.
    Should the actionscript be on the same layer as the button? Or the moving object? Does it go on both? -fyi I know im idiotic here but thanks for bearing with me…

    WHY MUST THIS BE SO DIFFICULT I THOUGHT NEWER VIERSIONS SHOULD BE CONVIENIENT!

  121. Michael, do you have the button instance named “myButton”? You need to give the button instance name at the Properties Inspector. Otherwise, flash would have no idea which button is to respond to mouse click. The button and the code can and should be on different layers. Also note that name is case-sensitive.

  122. it took me a bit to find, but I found it, and i t worked! im givign a special thanks to you in the movie and I hope you don t midn I post a link here once im done THANK YOU SSSSOOOO MUCH! I think ill be able to wingi t with the proper code from here on in, THANKS AGAIN! YEAEAH YOU ROCK!!!

  123. Hi Guys,
    I’m totally new to flash, and I would like to know how I can use a graphic that I have created to link to another frame or scene using Flash CS3.
    Thanks for the help.

  124. Brandon, convert your graphic as a button symbol. Then use the script like:

    stop();

    myButton.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    gotoAndStop(10); // assume you want to go to frame 10
    }

  125. Hi Brian
    I am studying Applied Multimedia in college, and i started studying Flash 4 weeks ago. Well i dont have questions yet, but i guess it’s coming soon:)
    after reading whole this page, i just wanna say u r so great and kindly:)

  126. HELP! I am attempting to create a very basic interactive game in Flash CS3. I tried using your example at the top of turning movieclips into buttons out of desperation and can’t get the clip to stop playing and wait to be triggered. i need this project finished by the end of the week.

  127. I figured out how to get the movieclip to behave as a button. Yippie! but i realized it probably wasnt the most logical method to accomplish what im going for. i was desperate. It is a game with three people in dunk tanks and the user would be able to press a button beside them to have them fall in the water. how do i get stop actions to work on my movieclips. i wanted to have a button trigger them to play to a certain frame and then revert back to first frame and stop again. any suggestions and guidance would be appreciated. THANK U!

  128. Hi Brian,

    Thanks for the help!

    I got a question here:

    I’m completely new to flash btw,

    I’m trying to use a graphic as a button that will link to another frame in ActionScript 3.0.

    Here is my code:

    stop();
    import flash.events.MouseEvent;
    BlueButton.addEventListener(MouseEvent.CLICK,doClick);
    function doClick(e:MouseEvent):void
    {
    gotoAndStop(10);
    }

    But when I test my movie, I get this error:

    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::SimpleButton@1c4ce7b1 to flash.display.MovieClip.
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()

    What am I doing wrong?

    Thanks!

  129. Hannah, not sure if I understand you correctly. If you would like to have a button to control the playback of a movieclip, you would use syntax like:

    myButton.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    myMovieclip.gotoAndPlay(2);
    }

    The movieclip would have its own timeline with stop() at appropriate place.

  130. Brandon, I would suggest replacing the graphic with a sample button (like the bar blue) from the Common Libraries/Buttons and test the movie if that fix the error. Let me know how it goes.

  131. Hi Brian,
    That is my problem. i can’t seem to get the stop() to work. my movieclips just keep looping instead of waiting to be triggered by a button inside my scene. HELP! I have three different movieclips of people and i used a second clip of them just for the first frame in each in hopes that if i could get them to stop on the first frame of that clip the other movie would continue to loop so that there was constant motion until it was triggered to play through the rest.

  132. Hannah, did you put a stop() action at the frame 1 on the movieclip timeline, not the main stage timeline?

  133. Hi Brian,
    In the flash file that you uploaded, how would you change the action script so that the button you are on goes back to it’s up state when you rollover another button? Hope this makes sense…

  134. Ben, get the movieclips to listen for MouseEvent.MOUSE_OVER.

  135. Hi Brian,
    I was able to make my button work with a graphic. How do I put in the code for another button? do I put in on a different keyframe?
    If I put it the code on the same keyframe, it looks exactly like this:

    stop();
    import flash.events.MouseEvent;
    BeginNow.addEventListener(MouseEvent.CLICK,doClick);
    function doClick(e:MouseEvent):void
    {
    gotoAndStop(31);
    }
    stop();
    import flash.events.MouseEvent;
    Title.addEventListener(MouseEvent.CLICK,doClick);
    function doClick(e:MouseEvent):void
    {
    gotoAndStop(1);
    }
    When I test the movie, I get this error:

    1021: Duplicate function definition.

  136. Brandon,

    You should either use different event handlers, say doClick1 and doClick2 for handling 2 buttons mouse click event. Or you can still use the same doClick with the following:

    button1.addEventListener(MouseEvent.CLICK, doClick);
    button2.addEventListener(MouseEvent.CLICK, doClick);

    functio doClick(e:MouseEvent):void
    {
    if (e.target.name == “button1” )
    {
    }
    else
    {
    }
    }

    BTW, you don’t need the import statement if the code is in the timeline and definetly not twice.

  137. Hi brian, Ive been struggling with this button problem and my ego wouldnt let me seek for help. Can you please send me the file as well, Pleeeaaase. Many thanks

  138. I’ve been trying to get the hang of buttons for days. This thread sounds promising. I would greatly appreciate a copy of this amazing file. Thanks!

  139. The sample file is at the first post.

  140. Hi brian,
    As you can imagine, it would be nice from you to send me the file… This btton problem is driving me crazy!!!
    Wasn’t it more simple to keep the button thing?
    Thanks in advance

  141. The sample file is at the fist post.

  142. Hi Brian
    I’m realy new to scripting and I have this problem. I have a moviefile and I want it to play when you click on it and then jump back to the beginning. I have managed to make it play this way. I have a button in fram 1 and my moviefile in frame 2. So I have scripted like this
    In my action layer frame 1, I have “stop();”
    My Button I have scripted like this
    “on (release){ gotoAndStop(2); }” so it jumps to frame 2 opens the Moviefile and stops, and when I click on the moviefile (The Button) it starts. Works fine.
    Butt how do I jump back to frame 1 (the Button) when the movie is finished. As it is now it just stops at the end.
    Please help me

  143. hey Brian… i’ve just started learning AS3… i’m reading a book actually and i’ve arrived at the Events chapter… so in order to play around with Events i’ve challenged myself in making 2 buttons using Movie Clips, Events and the target or currentTarget. So the idea is:1. the buttons should have an Over state(done that); 2. the buttons should have a down state(done that); 3. the button that i click should stay down and when i click the other one it should pop right up again(done that too)… but here’s my problem: in the 3rd stage of my idea i can’t make the button that is up to have it’s over state.
    i mean i did it using code that specifies each buttons state separately but i want to make a general code using ‘target’ or ‘currentTarget’.
    here is a link to the .as i’ve been playing with:
    http://www.filesend.net/download.php?f=a26b4813c6a6168d5ac08423f71287fc

    hope you can help me on this one!

    thanks in advanced.

  144. Jan, I am guessing that when you said moviefile, you are referring to a movieclip. And when you sadi you click on it, I am assuming that you meant click on a button which you have the script on. Now assuming that you using AS2, you may want to try putting a frame script at the end of the movieclip timeline (not the stage timeline) with something like _root.gotoAndStop(1). That would work if I have understood you correctly.

  145. Cristian, I have updated my demo file to include roll-over state of the movieclip. You can download the demo file at the first post.

  146. hello, Brian

    I found the code you posted how to create an URL link in flash cs3, I tried it and it didn’t work, it came back with a lot of errors. Would you please review the code and tell me what’s the problem. Thank you.

    my_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    navigateToURL(new URLRequest(”http://www.adobe.com”), “_blank”);
    }

  147. Irina, the code works. Just make sure that you don’t copy and paste from WordPress as the quote(” ) is wrong. Try type the code at the Flash code editor manually.

  148. Hi again Brian
    You are right, I mean movieclip, actually it is a Quicktime movie I have imported into flash. I have made a pict file from the first picture in the movie and I am using it for button. The button I have placed in the first frame and the movie in the second frame. I don’t have a movie that starts in one frame and end’s in another frame, it is all in frame 2.
    So how do i trigger an event when the movie ends.
    If there is a simpler way to do this I’m open for suggestions.
    I want at Button (340×240), when you push on the button the movie plays in the same window and then goes back to the Button stage.

    Hope you can help me.

  149. Hi Brian
    Ja… It’s me again

    I’ve tried your command like this “on (release){
    _root.gotoAndStop(1);
    }” This works fine, when the movie is finished and I click on it and release, it jumps to frame (1).
    This is what I want, but is there a way I can make it jump to frame (1) automatically, so you dont have to click on the movie first. Hope you understand what I mean.

    Thanks
    Jan

  150. No Jan. I dídn’t say putting the code with the on() event. The code should be as it is in the timeline and the code will be triggered when the playhead reach the frame.

  151. Hey again Brian

    Ja I understand, I tried it, it didn’t work. I think it must be for when you have a flash movie going from, let us say frame 2 to frame 125 and then you put the script in frame 125, but then it isn’t the movie who triggers the command to jump back to frame 1, but actually the timeline(frame25) my problem is I only have two frames, so if I put your scripting in frame (2) the movie will never start playing, because it will return to frame 1 immitiatly, you see what i mean. If you look at the comment I did right before the one you responded to(9:18), you will probably see what I am getting at.
    Any way thank you very much. Still I’m a little new to this so excuse if I’m asking som silly questions

  152. thanks for the help B… that’s somethin i’ve also achieved but my goal is to have only one button down at a time… that’s the think that’s driving me nuts… i got that working if i refer to each button specifically through a function onMouseOut… but i’m wondering if this can be done by referring to the buttons with the “target” or “currentTarget”???

    and thanks for replying!

  153. Jan, check your mail. File attached.

  154. cristian, to have only one button at down state is quite simple. Change the doClick event handler to:

    function doClick(e:MouseEvent):void
    {
    red_mc.gotoAndStop(1);
    green_mc.gotoAndStop(1);
    blue_mc.gotoAndStop(1);
    if (this[e.currentTarget.name].currentFrame !=3)
    {
    this[e.currentTarget.name].gotoAndStop(3);
    }
    else
    {
    this[e.currentTarget.name].gotoAndStop(1);
    }
    }

  155. thanks Brian… that did the trick indeed so here is what i’ve done with what i’ve learned: http://www.filesend.net/download.php?f=aad11520b4d72331f3d73b1bbed8978a
    i tend to complicate things and so i’ve made a class that controls the mouse over and out states and inserted the CLICK control in the .fla …this way i could reuse the class that i’ve created in other projects too even if i have to slightly modify it… you can all dld my code.. maybe this could help others as well!

  156. Hi,Brian…i´m creating a site on the flash CS3…my dificulty is on the buttons…I can´t make him going a direction page…Can you help me? An error occurs, is #2108…Thanks a lot!

  157. This is the code I´m using for one of the buttons:

    home_btn.addEventListener(MouseEvent.CLICK, doClick);
    function doClick(e:MouseEvent):void
    {
    gotoAndStop(“scene_1,labelhome”);
    }

    Once again…Thanks!

  158. Joao, If you are using scene, the syntax of the goto statement is:

    gotoAndStop(“frameLabel”, “sceneName”);

  159. Hi Brian,i try to make as you told me but a continous error occurs this is the error:
    ArgumentError: Error #2109: Frame label Scene 1,frame123labelhome not found in scene Scene 1.
    at flash.display::MovieClip/gotoAndStop()
    at soft_proj_3_fla::MainTimeline/doClick()
    Can you tell what i´m doing wrong,please?
    or you can send me a mail with an example, such going from the page “home” to the page “Services”…once again,thank you very,very much!

  160. Joao, create a movie with 2 scenes, scene1 and scene2. At scene1, add in a button called my_btn. Then put in the following code at at a script layer in scene1, frame1.

    my_btn.addEventListener(MouseEvent.CLICK, doCLick);

    function doClick(e:MouseEvent):void
    {
    gotoAndStop(1, “scene2”);
    }

  161. Hi Brian, I am in the process of creating a subMenue list it consist of a mainmc that leads to a sub_mc that leads to a sub_sub_submc. The main mc works but sometimes it doesn’t go away when out of the main box and I don’t know how to make a sub_sub_submc. Can I send you the file?

  162. Hi Brian,

    I’ve spend 2 days trying to find a tutorial for making buttons in AS3, using MovieClips that stay in the down state when pressed. I’ve found all kind of unusefull and imcomplete astutorials and examples, but none as simple and usefull like youre’s. =)

    thank’s again and thanks to cristian for sharing and making “the” question

  163. hi Brian, could you send me the simple flash file with buttons that go from scene 1 to scene 2?
    I placed a button on scene 1, frame 1 and when I click on my button, it says “current selection cannot have actions applied to it”, many thanks.

  164. Michelle, as discussed before you cannot put script onto the button object itself. You would need to put script onto the timeline of the stage like the following:

    my_btn.addEventListener(MouseEvent.CLICK, doClick);

    function doClick(e:MouseEvent):void
    {
    gotoAndStop(1, “scene_2”);
    }

  165. I tried that also, could you send me the sample flash file from above on button? That would be greatly appreciated. Thanks.

  166. I got it to work, didn’t type in my scene name correctly. Thanks.

  167. hi, I am also having problems with buttons – can’t asign action, can use on release goto and play etc. If you could send me sth helpful I will be grateful:)

  168. Hello I keep getting a 1120: Access of undefined property error.

  169. Hi brianchau , I am also having button troubles and am not familiar with action scripting i have read all of these posts and created a movieclip with a stop action. all i want to do is have my button go to and play the next scene. Why does this have to be sooooooooo difficult? can anyone please tell me how to make a button or clip go the next scene? I have wasted my entire morning on this very simple procedure and have gotten no further than i was 4 hours ago please help. Can you send me the exemple ?
    erik@vilamobil.be

  170. Erik, read my second last post.

  171. Hi Brian, I’m working on a flash website that has an opening page animation that ends at frame 70. From frame 70-1000 I have a slideshow. How can I make the opening animation play once, then play the slideshow, and loop the slideshow only (from frames 70-1000?) I don’t want the entire timeline to loop… just the few frames that I choose. Is there some actionscript for that? I’m using Flash CS3.
    Thanks a lot

  172. Actually, I just figured it out… I converted the slideshow into a graphic symbol and looped it, and made it appear in the timeline after the opening page animation.

    Is there a way to create a search engine inside a flash website? or to embed a search engine from google, or using javascript, etc?

  173. Maybe it is not the right place to ask, but I give it a try:

    I’m making a website with a mc_2 in a mc_1 in a scene(home). And when I click on mc_2 I want the mc(timeline) of home to play. THAT WORKS!
    But when I add another scene (intro) for an intro, it doesn’t work anymore. I get the error:
    #2109: Frame label part1 not found in scene home.

    I gave 2 frames in the home timeline a label.
    here is the code in mc_2
    function startPart1(event:MouseEvent):void
    {
    MovieClip(root).gotoAndPlay(“part1”);
    }

    partProject1.addEventListener(MouseEvent.CLICK, startPart1)

    function startPart2(event:MouseEvent):void
    {
    MovieClip(root).gotoAndPlay(“part2”);
    }

    partProject2.addEventListener(MouseEvent.CLICK, startPart2)

    Can anyone help me out?

  174. sorry, this is the code:

    function startPart1(event:MouseEvent):void
    {
    MovieClip(root).gotoAndPlay(“part1”, “home”);
    }

    partProject1.addEventListener(MouseEvent.CLICK, startPart1)

    function startPart2(event:MouseEvent):void
    {
    MovieClip(root).gotoAndPlay(“part2”, “home”);
    }

    partProject2.addEventListener(MouseEvent.CLICK, startPart2)

  175. Hi, just wondering if you could help. I am building a file with many scenes, but i want to put some buttons (not on the first frame) on the 4th scene. how can i make these buttons work. the event handlers wont work, the easy button set up with over out down and hit wont work. i want to add a url to the button. i was hoping to make with with timeline, rather than instantiation because i am not that good a instantiation. just wondering if maybe you had any ideas. i did try this:
    stop();
    var url:URLRequest = new URLRequest(“http://www.citeltd.co.nz/”);
    stage.addEventListener(MouseEvent.CLICK, onStageClick);
    function onStageClick(event:MouseEvent):void {
    navigateToURL(url, “_blank”);
    }

    stage.addEventListener (MouseEvent.MOUSE_OVER, onStageOver);
    function onStageOver(event:MouseEvent):void {
    gotoAndStop(2);
    }
    stage.addEventListener (MouseEvent.MOUSE_OUT, onStageOut);
    function onStageOut(event:MouseEvent):void {
    gotoAndStop(1);
    }
    but with many buttons on the same frame it was doing the same thing for every button. but this one did work.

    any suggestions

  176. I have an issue where I make a button or clip hide (object.visible = false), but when I try to make them come back (object.visible = true), they don’t appear. They are still there and click able, they are just invisible.

  177. Hello Brian
    I am new at Flash, and hopefully not a complicated question. I want to create an interactive flash file that will be used on a touchscreen. My thought is having a main screen with 5 to 6 buttons ranging from a hangman game, video of a nature walk, Trivia game, weather info, history. Being new at Flash CS3, do I create these different files and link them as .swf files to buttons? And with each I am able to return to the main screen when done viewing or playing game. Not sure how to write script for this scenario. Still trying to learn how to even create the other elements (that will be linked to buttons) that I want to use in this file.
    Being new at this is it better to create this using AS2 or AS3? Any help would be greatly appreciated

  178. Brian
    It is me again, As I read through some of the blogs above. Do I understand that writing AS3 buttons doesn’t mean that all script goes in frame 1 on the stage? So, on main page there are five buttons. For example, all buttons on a button layer and on the stage but then I put a button on the frame(2) that needs to start the hangman game, have a back to home button so you then click on history button on frame (25) as well as having a home button to go back to main page. I take it that it would be easier for me being new at Flash to create all my script and functions in one flash file on one timeline. I am confused at what goes on the stage and stays in the library for AS3 to make things work properly. Any help would be greatly appreciated.

    • For a simple flash movie, you can put AS code on the timeline layer and scattered them across frames on that layer. Say Button 2 is on frame 10. You can put AS code that reference Button 2 on frame 10.

  179. Hello Brian

    Me again, So if I understand this on the stage have the buttons and any other graphic for the main screen. Then on put the script on the frame that you want to go to. Here is what I have written for code and my problem is, it is looping or continuously going from one frame after another. No control of the main screen and pushing a button. This is what my code looks like
    stop();
    //on frame 2 i have this…
    function goHome (e:MouseEvent):void
    {
    gotoAndStop(“Photos”);
    }
    photos_btn.addEventListener(MouseEvent.CLICK,buttonClicked);

    //on frame 3 i have this…
    function goAbout (e:MouseEvent):void
    {
    gotoAndStop(“History”);
    }
    history_btn.addEventListener(MouseEvent.CLICK,buttonClicked);

    //on frame 4 i have this…
    function goLinks (e:MouseEvent):void
    {
    gotoAndStop(“Regions”);
    }
    region_btn.addEventListener(MouseEvent.CLICK,buttonClicked);

    //on frame 5 i have this…
    function goContact (e:MouseEvent):void
    {
    gotoAndStop(“Rock Mary”);
    }
    rockmary_btn.addEventListener(MouseEvent.CLICK,buttonClicked);

    what am i doing wrong or missing in this code

  180. Brian… I am having the same trouble as many others have… I was using a much older version of flash and attaching the actions to buttons and movie clips… I am having a hard time understanding all of this now… could you please send me the file mentioned above and explain how/why we have to link things not on the buttons… it just doesn’t make sense to me right now and i am not strong w/ scripting… an artist here… not a programmer…

  181. hello Brian,
    I am trying to use some video converted to .swf with buttons to go from one to another. This is my code I am using.

    var Xpos:Number = 274;
    var Ypos:Number = 190;
    var swf:MovieClip;
    var loader:Loader = new Loader();

    var defaultSWF:URLRequest = new URLRequest(“swfs/history.swf”);

    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);

    // Btns Universal function
    function btnClick(event:MouseEvent):void {

    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest(“swf/” + event.target.name + “.swf”);
    loader.load(newSWFRequest);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    }
    // Btn listeners
    history.addEventListener(MouseEvent.CLICK, btnClick);
    cccstone1.addEventListener(MouseEvent.CLICK, btnClick);
    lakemurray1.addEventListener(MouseEvent.CLICK, btnClick);
    duckies1.addEventListener(MouseEvent.CLICK, btnClick);

    The problem is I keep getting error 1046: type was not found or was not a compile time constant. Using video in flash CS3, what do you suggest…
    Thanks for your input.

  182. dear sir

    i’ve made 2 scenes with multiple layers. iwant to play them without buttons. which action script i can use? kindly help me.

  183. Oqseoaab upiihaiz Discounted Prosolution Pills ruuoao.

Leave a reply to brianchau Cancel reply