…and especially enthusiastic about motion tweens in Flash…
So I used to monitor comments coming in from the CS3 Video Workshop, which contains a few hundred video tutorials on the CS3 products. Some of the comments that came in regarding the Flash videos was how people were having frustrations about how to set up button code with ActionScript 3.0. I thought that’s where I’d start out, with a simple example that compares the two. So I’ll show you how to make a button work in Flash CS3 or Flash CS4 using ActionScript 3.0.
Luckily, the set up is pretty much the same assuming you put code on the Timeline. If you didn’t, it will be a bit of a change and you’ll need to follow the steps below.
When you were using ActionScript 2.0, you would put code on the main Timeline. You’d have a button on the Stage with the instance name myBtn (set in the Property inspector). You would add code to frame 1 that reads:
myBtn.onRelease = function() { getURL("http://www.flashthusiast.com"); };
In ActionScript 3.0 it looks a bit different. And yes, it’s an extra line of code and it is a bit more complex looking. However - you don’t need to use classes or anything, set up is the same. Here are the steps you’d take to create an interactive button in Flash CS3.
monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); function mouseDownHandler(event:MouseEvent):void { navigateToURL(new URLRequest("http://www.flashthusiast.com/")); }
And that’s all there is to creating a clickable button with AS3. All you need to do is change the URL to make it work in your own document. Or, you can change that entire line to be something else, such as go to and play a frame number: gotoAndPlay(6);
You can also change the MouseEvent from MOUSE_DOWN to, say, MOUSE_OVER to change how the interaction works. Search Flash Help for MouseEvent, and look at the Class in the ActionScript 3.0 Language Reference.
MORE INFORMATION ON BUTTONS:
This blog specializes in the new motion model of Flash CS4, and is brought to you by team tween of Flash at Adobe. The blog will includes tips, techniques, and info on tweening in Flash using the Timeline and Motion Editor (as well as some stuff about motion runtime with code). From time to time, we might also talk about ActionScript 3.0. So if you're interested in tweens, this blog is for you. We also want to hear your feedback in the comments. All views expressed here are those of the authors, and do not necessarily represent the opinion or views of Adobe Systems Inc.

Vlad
February 26th, 2008 at 1:21 pm
I probably put a comment in the wrong spot … ups. I just made my first button using CS3 and can’t make it work because scripting 3 is like a whole new moster. I just need to go to the next frame. HELP!
Jen, a flashthusiast
February 26th, 2008 at 2:11 pm
Hey Vlad,
luckily you just need to modify the code above, and it’s pretty much the same as AS2 :) This should hopefully work for you, just swap out the frame number you need to stop at and change the button’s instance name to that of your button –
Chet
February 27th, 2008 at 10:14 am
Soooo… what I have three buttons and want them to go to different frames? I repeated the code you provided for each button but Flash says I can’t use the same function multiple times…
Jen, a flashthusiast
February 27th, 2008 at 12:23 pm
Hey Chet,
The quickest way would be to make the three functions for the three buttons, and point them at the three frames. So I just renamed the function for the three instances:
John
February 29th, 2008 at 9:05 am
OK, I am pretty much the wettest behind the ears guy around with Flash. I used your tutorial on Flash CS3, and almost understood it, but got all to work. I’m now playing with something else where I want 4 buttons, each re-directing to a new URL. I tried the following to start:
which makes sense to me, but get the following:
my first thought was to add a different action to a different layer, but I can’t figure out how to get more than one layer to appear in the action toolbar (or am I way off?)
HELP!
Thanks,
John
John
February 29th, 2008 at 9:11 am
OK, so I can’t even get my code here correctly. It’s more like this:
AND the error is:
Jen, a flashthusiast
March 1st, 2008 at 8:50 pm
Hi John,
It’s pretty much the same solution as Chets - the functions (function buttonClickHandler) need to have different names. Alsonitced that there was a little typo in the code (the first navigateToURL).
So the below code changes those two things, and it seems to work :)
Hope this helps,
Jen.
Kojin
March 5th, 2008 at 6:26 am
Hi there.
I’ve got quite similar example, the only difference is its about gotoandplay/stop action. It looks like this:
First button works fine, but second one doesn’t. Instead of going straight into frame 25 and stopping there, it begins animation from frame 2 and stops at the last frame (because of stop action in frame 30).
Kevin
March 6th, 2008 at 8:25 am
hi, i cnt seem to get the hang of this. i got 5 buttons in frame 1, and i want each button to to go to different scenes!! how do i do that.
because i tried to make the buttons go to different frames, but for some reason, the 1st button takes me to frame 20 but then all the rest of the button ALSO keeps taking me to frame 20?? heres the code i used:
Jason
March 8th, 2008 at 4:17 pm
When you make the function unique you need to changes it call too.
So in:
grinder_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2); <— You add you 2 here as well.
Jen, a flashthusiast
March 8th, 2008 at 7:16 pm
Thanks Jason! I should have definitely tried my code before typing it into wordpress :) Great catch there.
Jean-Francois
March 8th, 2008 at 7:25 pm
Hey, Everyone….
I am a newbie to flash cs3 and as3. I’ve been building a flash website for the past week or so and so far things are going ok. However, I have a navigation menu with buttons I’ve as’d to navigate to a new url. Currently when the buttons are clicked they open the url in a new tab in my net browser; I am using the code below for these buttons:
What I need to know is how I get these same button instances to open the new url in the same tab I’m already viewing. Any help would be much appreciated.
Thanks.
Kevin
March 9th, 2008 at 2:47 pm
Thanks Jason
D
March 9th, 2008 at 5:31 pm
I have a simpler question…I have a “Scene 1″ and a movie clip within the main timeline.
I have a button inside the movie clip and am trying to reference a “home” frame in the main timeline in “Scene 1″.
I have tried a number of things, but just can’t fuigure it out!
Please let me know and thanks in advance.
vips
March 11th, 2008 at 7:07 pm
Hi I m a newbie to flash cs3. I have worked on flash 5 b4. I need my button to take me to scene 2 from scene 1. Could u please help me with the code?
Thanks a ton!
marieta
March 13th, 2008 at 6:42 am
hi jen..Im pretty familiar with flash buttons and movie clips, unfortunately very little on scripting…i could get buttons to work but my question is ‘how to script a movie clip button within a movieclip? like where to include the actionscript whether in the movieclip, button or on the scene where the movieclip is’
enlightenment will be much appreciated…many thanks
Thomas
March 15th, 2008 at 10:52 am
Hello hello,
I’m new here so forgive me if I like askin stupid questions ;-) but I could really use some help on CS3 actionscript3 thing I’m tryin to work out.
For the BLOG page of my new website I made the top part in Flash and the thing is I need to get the three buttons that are in there workin…I copied the script:
and followed the instructions, of course I swapped monkey_btn for mixlawax_button and also renamed the url http://www.flashthusiast.com into http://www.mixlawax.com
AND IT WORKS!!!! :-)
Only thing now is I need the other two buttons to go to other URL’s as well and here’s where the problem starts.
When I copy paste:
into the ‘actions’ pane and add it to the first frame and then press TEST MOVIE I get the following error:
I hope there is someone who can help me out, and yes I know I’m not Einstein hehe
Thanks in advance.
Thomas
PS: In fact my question is how do I make three buttons get three different URL’s in actionscript3??
Thomas
March 15th, 2008 at 1:06 pm
Consider my last post as not sent, got it fixed :-) thanks to Flashthusiast > categories ‘buttons’ duh sorry for my stupidity ;-)
All buttons work now, nice and easy :-)
Thanks!
Peace
Thomas
Mark
March 15th, 2008 at 1:48 pm
Does anyone know how to code the following:
If I want one button to control which frame to go on depending on 2 different selections. Basically, if I choose the color red in one drop down then yellow in the other drop down, when I select the go button, how would I make it go to frame 4 which has the mixed color. I am having a brain fart.
Thanks
Jason
March 16th, 2008 at 11:37 am
D,
I had this same issue and this is what I assigned to my button and it worked for me. This takes my movie to the first frame outside the movie clip.
Chad
March 18th, 2008 at 8:36 am
I’m a Newbie to Actionscript 3.
I’m trying to do a photo viewer, each photo is on it’s own frame in order, 50 photos total.
I have two buttons, advance and rewind, and can’t figure out how to simply go to next frame with the advance button and go to previous frame with the rewind button.
This is the direction I’m going with the code, it doesn’t work right and I can already see that there must be a much simpler way but I can only find examples where a button goes to a specified frame not simply to next or previous.
Chad
March 18th, 2008 at 8:53 am
Sorry I just noticed the second event listener was wrong.
jennicandance
March 18th, 2008 at 12:33 pm
Get advice Jen!! Thanks soooo much, I’ve been looking for these answers everywhere!
Lou
March 19th, 2008 at 12:49 pm
HI ! a newbie to Flash and AS3. I want to control the LABEL on my button but I can not get the syntax correct.
works to make it visible … but the same code doesn’t work for .enabled or .label.
I get the following error:
Tried to IMPORT the class:
but then I get the error:
Any help greatly appreciated! THANKS MUCH!!
Carl
March 22nd, 2008 at 5:32 pm
Add a button to your stage and then delete it. This will add a button to your library.
Ruby
March 25th, 2008 at 4:31 am
I have five text buttons linking to 5 different states on a website(home, about, news etc).
i have added the following script:
i have the following problem:
When i click a text button(doesn’t matter which one) it works fine. Then none of the buttons work after that. Assumedly because the script has not been added to the other states on the timeline. When i add the script to the five corresponding states on the timeline, i get compiler errors (duplicate script).
what’s the correct action to take?
Ingrid
March 25th, 2008 at 3:22 pm
I was having the same trouble as Ruby above me, I could get to one page but after that the script went nowhere. I tried changing my MouseDown handlers to increment by one and double-checked my button names and that fixed it for me. My layers are set up so that the action covers all of the frames.
Hope that helps.
Scripting confuses me but this article is great. I’m almost there! Thanks :)
Edo
March 25th, 2008 at 6:58 pm
Hi guys i’m new to the flash cs3.
After i press the button I don’t want the url to open in a new window ( want to keep it in the same window) how can i do that.
I been trying to add “_parent” but i’m getting an error msg
Tnx
jennicandance
April 3rd, 2008 at 9:22 am
What if I wanted to change the rollover state:
This doesn’t work, but I’m confused on how to get it to work. Can anybody help me?
Esben Boye-Jacobsen
April 5th, 2008 at 11:01 pm
I was wondering if it is possible to somehow get the name of the instance from which the action came?
If I press the thisButton_btn, then it could be nice to get the instance name passed as an argument or something - is there some way to do that?
Thanks in advance :)
Braylon
April 10th, 2008 at 9:07 am
Braylon
April 10th, 2008 at 9:28 am
What is wrong with this? I just want to simply move down the damn timeline! Thanks
Jen, a flashthusiast
April 10th, 2008 at 10:38 am
Hi Braylon - make sure your mouseDownHandler’s match each other. For example for your last button it would be
More information in this post: http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/
Sam Browne
April 13th, 2008 at 5:03 pm
Hey i am an absolute noob at actionscript 3.0, and i want to make a button that works and links to another scene. Thankyou
Mary Anne
April 17th, 2008 at 4:11 pm
I really appreciate the lesson you have been giving here. I teach a section of a digital imaging class in which I teach students how to build animation, portfolios, and websites in Macromedia Flash. I use MX since that is what is available. I have a student in the class that uses Macromedia CS3. Is there a way to go into normal mode to add actions from preset action scripts like in Flash MX and 8? Also, we are having a hard time finding movie controls under Flash CS3. Any help on this would be greatly appreciated.
David Stephenson
April 19th, 2008 at 9:54 am
Thanks for putting up this tutorial Jen, I was struggling for over an hour trying to figure out how to create the previous and next buttons for a Flash CS3 presentation.
Ja
April 21st, 2008 at 8:08 am
Trying to get my buttons to work in CS3 using the new action script to no avail, my button code is this and it doesn’t for whatever reason move to frame 39.
Please help.
Jay
April 21st, 2008 at 8:09 am
Oh and I get this error message
Jay
April 21st, 2008 at 8:20 am
When I use this code the button has no effect.
this is the error message I get
Jen, a flashthusiast
April 21st, 2008 at 10:32 am
Hi Jay - Check that your publish settings are set to AS3. You would see that error message if its set to AS2. If that doesn’t do the trick, please let us know :) Thanks, Jen.
jc
April 22nd, 2008 at 12:29 pm
hey im a total newbie with flash cs3 and i am trying to make multiple buttons to link to several different sites i have tried the tutorial for the one monkey button to no avail seeing as the button didnt link at all i copyed everything word for word
i changed where the button would link to here is my actionscript:
let me now any problems i have with it and any and all tips would be appreciated
jkern
April 22nd, 2008 at 12:53 pm
I can’t find anywhere that explains how to program a button to fast-forward 5 seconds or rewind 5 seconds with AS3. I get the logic (from what I’ve seen similar to this,) that you somehow call the current frame “n,” and you make a function akin to gotoAndPlay(n+5) seconds. I just don’t know the code to do this.
This is the best thing I have found for AS2:
Can anyone AS3-ify this?
Jrose
April 23rd, 2008 at 12:32 pm
For those of you who are having problems jumping to difference scenes with a button, here’s how you do it.
obviously, you can also replace the frame number with a frame label as long as you use quotes, like this:
so you must use both the frame number and scene name with AC3.
JohnB
April 29th, 2008 at 2:08 pm
It tried this script and other variations but they do not work on Firefox, Opera on Windows, or Safari on Mac (and probably windows). I rolled back to Actionscript 2 (GETURL script) to get it to work, which it did except on Safari.
Is there a fix for this? I’ve done tons of research and have found none.
Turtle
April 30th, 2008 at 10:53 am
If I use AS2 - the first image in the slideshow works, the rest do not:
http://www.houstgrandopera.org
cornelius
April 30th, 2008 at 3:10 pm
to the flash gods,
i am using 2.0 and i am trying to link a drop down menu to my web pages.
my drop down menu is 4 buttons that i would like to use to load a movie clip into the main
contentMC. i have been trying to figure this out for myself but i am a little confused. i am using 2.0 and all the tutorials teach you how to link to an outside urlso my question…
menuBackis the movie clip name for the drop down menu.resumeBtnis the button inside the movie clip.contentMCis the movie clip that is on stage displaying the swf file.the code that i have does not work. the buttons drop own but do not allow the swf files to load into
contentMC.when i have the proper working code do i.? put the code into the page actions or the movie clip (
menuBack) actions?any help would be greatly appreciated, i really want to do this on my own but i have hit a road block and i need to get around it.)
cornelius
May 1st, 2008 at 1:24 am
ignore the above comment.. i got it! unles
i was not using the proper instance name… duh!
the above code is correct just make sure that the instance names are correct,
Jayson
May 1st, 2008 at 11:37 pm
I’ve been trying to get these buttons to work with no luck at all haha.
I’m using this code
I’m getting this error
please somebody help lol I am totally lost as to whats going on…thanks a bunch
B1
May 4th, 2008 at 6:28 am
I too am also a nOOb - especially AS3.
Have a simple 7 frame project - where we start with frame one, and after frame one is finished by clicking ENTER, the movie shoud got to frame two via: nextFrame ();
It does it for going to frame 2 and 3 and 4 and 5 - but it always skips frame 6, and goes on to the last frame 7.
It makes no sense. So want to know how we can change it so that if each frame has a Frame Label, we can do the same process of moving from frame to frame ( one frame at a time).
All help welcome ! Thanks !!! :)
webbedkitty
May 6th, 2008 at 8:02 am
Grrr, I’m new to Flash CS3 also, and I’m having difficulty with a flash banner template my client purchased. The flash file already has an action layer, i.e. falling dollar bills, and I have added the client logo, however, they want me to add a hotspot to be clicked and navigated to the clients home website, URL. Can I not have two actions layers?
Above the button (inv_btn) layer I made a separate actions layer. I put in the actionscript:
And I get an error:
What am I doing wrong?
Please help!
Jen, a flashthusiast
May 6th, 2008 at 10:52 am
If you see the error “The class or interface ‘MouseEvent’ could not be loaded” make sure your document is set to ActionScript 3.0 in publish settings.
webbedkitty
May 6th, 2008 at 11:09 am
Thanks, Jen. I think I’m writing 3.0 script for 2.0, whoops!
Does anyone know of any good Flash CS3 beginner tutorials?
Thanks!
Dwayne
May 13th, 2008 at 1:46 am
Hey Jen, what a lovely site you have here, I am a web developer/ designer but now I think I maybe a flashthusiats.
I am creating a computer game its a grand theft auto type thing, could you point me in yo some directions in which i can gather assets for me game.
Thank you
p.s webbedkitty this is a good flash beginners site
http://www.squidoo.com/Flash_Tutorial_hitTest
Enjoy
Super Dwayne
David
May 13th, 2008 at 2:35 pm
I’m having the exact same problem that Ruby did up above, that I’ll click a button, it’ll take me to another frame that has the same buttons on it but then the buttons no longer work. I’m assuming they should be buttons and not movie clips (?) I couldn’t quite understand what Ingrid did but if anyone can point out my errors, it would be SO apprecaited. Thanks.
Joe
May 13th, 2008 at 5:47 pm
Well, i have a template and it is flash 8 running on as 2.0. I used the
When I test my movie and click the button I get a new internet explorer window with my site. This is all on flash cs3 but when i open the file on internet explorer or mozilla, when I click the button my new window doesn’t pop up (not because of pop up bloker). If I use the cs3 code you gave me, then all the other code in the rest of the template would need to be changed and I do not have a clue on how to.
Andrew
May 13th, 2008 at 10:34 pm
Hi, I had same prob as Ruby but fixed with same mouseDownHandler number so thanks.
I have two button set up same as each other, but the second one when I test movie runs through its 4 states (up, over, down and hit) continuously like it can’t stop! Why would it do that but the first one doesn’t?
Andrew
May 13th, 2008 at 10:43 pm
Just fixed it - made a new button set up exactly as previous one and it stops now. Damn Flash - why does it do that kind of thing?
Andrew
May 13th, 2008 at 11:03 pm
Sorry another problem has come up. Button 1 goes to frame 2 (correct) then button 2 goes to frame 3 (correct) but if I press on button 1 again nothing happens. Shouldn’t it go back to frame 2 with this script?
David
May 14th, 2008 at 6:33 am
One other thing, I don’t know if this matters, but I was using gotoAndStop(10); on the MouseCLICK because if I used gotoAndPlay, it would cycle through to the end of the timeline. If I put a stop(); script on a different layer, it stays there, but the buttons still don’t work. Any help?
Matteo
May 16th, 2008 at 12:29 am
Hi, great work!
i’m using the code you’ve written in a flash intro, exactly for the button “skip intro” and it works well!
but is it possible to make the page open in the same window and not in a new one? where have i to modify the code?
many thanks!!!!
kipley
May 19th, 2008 at 6:34 am
Okay, I’ve spent hours on what used to be a 30-second task for me in AS2, and still no go. Any suggestions? I turned the word “Home” into a button, then changed the color for the Over and Down states, and then drew a rectangle for the hit area. Only problem is, every time I do this, only the hit area extending outside the text works. It’s almost like the text field masks the hit area. If I make a really big hit area, everywhere outside the text area works. But when I mouseover the text itself, the cursor doesn’t even recognize that it’s a button. What’s going on??? ANy help is much appreciated!
David
May 19th, 2008 at 8:28 am
In the button’s timeline, is the rectangle you drew in a layer above the button states? That should solve your problem.
pete
May 21st, 2008 at 10:52 am
If a button action said this before, what should it say now in CS3?
nat
May 22nd, 2008 at 5:44 am
Hi Jen,
I am also very, very new to flash actionScript 3.0, and I needed to know how to set up buttons correctly, I could get one to work but the others weren’t - thank you such much for your info, and for everyone’s posts, I worked out what I was doing wrong (not numbering my event handlers!!) and now it’s all working a-ok. thanks so much!!!
I do have a different problem now, I’ve been searching the net for ages and just can’t find what I am after, I want to make my swf play/pause via one button and I am completely lost! - any help/thoughts would be v much appreciated!!
Sarah
May 28th, 2008 at 3:25 am
Hii .. im new to AC3 … i wanted to creat buttons .. each one of them goes to different frame.. my buttons are in one layer and the content in another one … anyways .. wut does this error mean ??
i created a rectangle converted to button and gave it an instance name and wrote this code
this is my code :
ben
May 30th, 2008 at 5:22 am
Your instructions are so easy to follow. Thank you so many sites out there that make it really hard to understand. You are a champion !
Ben
James
May 30th, 2008 at 10:50 am
Hi I am really new (just few days) to Flash CS3. I am using a script to make a sliding menu bar. However, I could not make the buttons to function. I have tried different ways in using your script.
a. made a new action layer on the movie scene and attached the button script
b. go to edit button mode, made a new action layer and attached the script
The output gave me this message:
The following is the script:
The sliding menu bar script works fine without the button function (I know this sounds silly.. a menu bar without button function). Million thanks for your help! Really appreciate it!
the_other
June 5th, 2008 at 2:14 pm
CS3/AS3 is very different from version 4. I’m lot at this point and need some help.
I have a map with 50 buttons plotted on it. I would like for each individual buttons to launch either a new scene of another swf. I’ve given an instance name for each button “button_13″ and “button_14″ etc. How and where do I add these on the buttons?
Any help would be really appricated.
the_other
June 5th, 2008 at 8:01 pm
I forgot to mention that when I try to add any scripting below stop(); it gives me error and plays all scenes continuously without stopping at the begining of each scene.
Parker
June 12th, 2008 at 8:52 am
Ok, I just started actionscript 3 and im making a website. the top of each frame has HOME ABOUT BLOG PORTFOLIO CONTACT buttons. so on each frame i put this (of course for each frame the buttons had diff. instance names)
cs3 says i can not repeat the same function. i saw that someone named chet made a comment like this earlier, but the answer to his problem didnt even change the code. please help!
Chris K
June 17th, 2008 at 7:45 am
Hey. My problem is that I have a movie clip in ‘Scene 1′. It has a button in it that needs to navigate to a frame label that is not within the movie clip, but within ‘Scene 1′.
I saw some suggested script that could solve it above:
However, my adaptation of it didn’t work for me. My button instance is ‘nextBtn1′, the frame label that it needs to direct to is ’song menu 2′ and the movie clip is called ‘Songbook Menu 1′ if that is of any relevance. Any help is much appreciated!
Thanks
Michael
June 17th, 2008 at 10:26 am
I am experiencing the same problem as Andrew… when i click button 1 it takes me to frame 5 (correct), when I click button 2 it takes me to frame 16 (correct) but when I click on button 1 again, nothing happens. I have tried everything I can think of, double checked everything, and the actionscript looks correct:
Any suggestions on anything to try to fix this? Any thoughts are appreciated. Thanks!
goldie
June 22nd, 2008 at 3:38 pm
How do you create a back button in AS3? It all seems like common sense but it is killing me!! My next buttons and my home button both went smoothly.
Dave
June 25th, 2008 at 1:43 pm
Ok so Im a first time user of Flash and Im trying to create a simple training program for some co-workers. Some simple buttons with some simple video clips. I was excited until I found out that I have to use code for button functions. Can anybody please tell if there is another way to use buttons with having to input code?
Dave
June 25th, 2008 at 1:47 pm
Is there any way to create simple buttons with out inputing code?
Ezza
June 26th, 2008 at 8:02 pm
I am creating a game on flash, but having trouble with trying to make a button move from one place to another. I tried using a tween but it wouldn’t move when I played it! All i want it to do is move up and down, but it wont work! All my frames have actions applied to them. Do I have to change the button to a graphic or a movie clip, and what actionscript will i need?
Delatoni
June 29th, 2008 at 11:03 am
>How to link in normally in actionscript 3.0.
*note: for “hacks_nav” you can put what ever you want in its place just make sure they are both the same.
*note: and on “hacks_btn” you just have to put the name of your button you are trying to link.
*note: and on “hacks” you can either use frame anchors like I did or you can use frame numbers. BUT if you use frames numbers just make sure you enter it like this (12) not like this (”12″).
*note: also if you want it to play instead of stop replace “gotoAndStop” with “gotoAndPlay” and it will start playing at that frame instead of going to and stoping.
—————————————————————————–
>How to link to fames on the main timeline from a button nested in a movie clip in action script 3.0.
*note: for “trail_nav” you can put what ever you want in its place just make sure they are both the same.
*note: and on “trail_btn” you just have to put the name of your button you are trying to link.
*note: and on “home” you can either use frame anchors like I did or you can use frame numbers. BUT if you use frames numbers just make sure you enter it like this (12) not like this (”12″).
*note: also if you want it to play instead of stop replace “gotoAndStop” with “gotoAndPlay” and it will start playing at that frame instead of going to and stoping.
—————————————————————————–
>How to make a movieclip dragable in actionscript 3.0.
*note: for “tabledrag” and “tabledrop” you can put what ever you want in its place just make sure they are both the same.
*note: and on “tableMC” you just have to put the name of your movie clip you are trying to make dragable.
Delatoni
June 29th, 2008 at 11:31 am
>Sorry also note that if you are linking from a button that nested in a movie clip that’s nested in another movie clip you have to alter the code to look like this.
*You are going to want to add another “parent” after MovieClip(parent.parent) like that.
——————————————————————————
>For a Transparent Background And Fullscreen Video’s
In Dreamweaver after you add your .swf file to your page click on the flash movie and in you properties panel look for “parameters” button and click on it and then type…
and then click ok and your done.
*note: or if you have a video in .swf that you want to have the fullscreen function work on it just enter this instead…
allowFullScreen = true
—————————————————————————–
Well that’s it I hope this help you guys. :)
Jose
July 4th, 2008 at 7:37 am
What is the function for making a “next” and “previous” button?
AChristi
July 12th, 2008 at 7:19 pm
I need to have a code that works with my next and previous button.
I have a flash CS3 slideshow, but I want people to see wich button belongs to wich photo by making the button glow. How can I do this?
Jo
July 14th, 2008 at 4:46 pm
My code is as follow for Action Script 2, I need to change it because I have realised that this relates to Action Script 3. Can someone please help me
The errors are The class or interface ‘MouseEvent’ could not be loaded.
Kevin
July 15th, 2008 at 7:04 am
Thank you for these clear and FUNCTIONAL explanations of how to to make a clickable banner. After hours of searching for the answer, I finally found it here. Again, thanks!!
Julie
July 17th, 2008 at 5:55 am
I was wondering if you could help. I used your code for a button I created in Flash. My button resides on an intro animation. I created a skip button so that when the user clicks on it, the user will go to the homepage. The only problem is that the intro continues to play in a different window then the homepage. The idea is that when the user clicks on the skip button, the intro stop and disappears and then a new window pops up with the homepage. Here is the code on the skip button.
Debbie
July 22nd, 2008 at 1:04 am
Hi Jen
Great post. I am also a newbie to Flash and your tutorial came along at the right time.
But I also have to sound the “how do you get the link to open in the same tab/window” horn.
Please help.
Debbie
July 22nd, 2008 at 1:18 am
Actually I have found the answer. For the record, the last line needs to read:
Add the _self after the URL and that works fine.
Sorry to intrude Jen. ;)
Josh
July 24th, 2008 at 11:16 am
Hello everyone,
I am trying to make revise my portfolio website in Flash CS3. However, things are not as easy as I would have hoped. For some reason when I ‘test movie’ my buttons all work as rollovers but once you click the ‘about’ button to go to the ‘about’ page you’re stuck there! Once you’re on a page I can’t click another button to go to any other page. Does anyone have any suggestions for this frustrated Flash user? Thank you!
Kohaku Hiita
July 25th, 2008 at 7:35 am
Hey. I have to be the worst person at understanding CS3…EVER…so I was wondeing if I could get some help. I am trying to make a flash movie with an opening scene that loops untill my button is clicked and it starts the movie. My problem is the button- I’ve tried using some coding from other posts and formatting them to work with my flash, but none of them have worked for some odd reason. Now I have nothing to work with. Can someone help? All would be appriciated. Thanks. :)
LOST in AS3
July 29th, 2008 at 8:55 am
I am completly lost… I am trying to create a flip book with a foward button and reverse button foward that moves to the next frame and stops, the reverse moves to previous frame and stops.
I have 9 images on the image layer
then the button layer where on the first frame I have the buttons. I have named the instances I can (using this tut) get the frame to go foward one frame and back one frame using this code…
I am sooo lost can anyone HELP
R
josesenra
July 29th, 2008 at 4:32 pm
hi Kohaku
maybe you should try this:
1 - the “loop” animation goes into a separate movieclip running on frame one (must have a stop there)
2 - place a button in frame one and write the following code on the frame’s actions panel (IMPORTANT!!! don’t select the button to write the code.. select the frame)
well… what have we got here?? simple actually… you got a movieclip on frame 1 that’s just there doing it’s thing… you got a button wating to be clicked and when it gets cicked it sends the main timeline to frame 2 and stop there, after stoping the movieclip on frame 1.
good luck ;)
josesenra
July 29th, 2008 at 4:34 pm
hi Josh.. can you be more specific as what you mean by going to another page???
Laura G
August 13th, 2008 at 6:38 pm
Hi Jen, I tried using your script for my button:
And I get: syntax error: extra characters found after end of program - which refers specifically to line of script starting with “english” - what am I doing wrong??
Jonathan Jason
August 15th, 2008 at 7:40 am
You People are using AS3 in a really primitive way specially for the use of multiple buttons writting function after function after function and the same with event handlers that’s to much work guys why not use the power of Arrays and Loops to assign one function to all your buttons?
let me explain
first off create all your buttons and there functionality I prefer to use MovieClips to make my buttons for the flexibility.
Give them simple names for example you can name them the same as the sections of let’s say a website like (home, aboutUs, contactUs) you will be surprised how much easier this makes things later when you can use the names of your buttons to do a lot of other things using AS3’s classes
Now create an Array with all your buttons names in it like so;
We will loop through the array later using a (for Loop) to access the buttons by the index number of the array.
Then write your on click, over and out functions and issue the instruction to the event target button instead of a particular button, this makes your function reusable and that is one of the biggest advantages of OOP languages like AS3. If this doesn’t make sense keep reading
Leave them blank for now!
now the For Loop this is where the magic happens !!!
Let me explain!
write a loop that uses a variable give it the name of a single letter I will use the letter (i) make it an integer and give it the value of 0, then compare that variable with the array’s length property by setting it less then the array.length property of the array class, and finally increase the variable by one by using the ++ method of AS3.
inside the loop we add the button functionality by assessing the button through the arrays index by using our loop variable to access it like so “btnArray[i]“,
and if you use MovieClips for your buttons 2 little bits of code to make them work like true buttons the buttonMode and the mouseChildren property’s of the MovieClip class they both get a Boolean value so there really easy to set.
now add your functionality to your functions if the buttons are going to do totally different things the use if and else if statements to assign the functionality if they are for navigation to a url then use the navigateToUrl property of the flash.net class and if it is for navigation in the flash file then go back to your flash file and at the beginning of each section put a frame label with the same name as the button that will navigate to that section then use the event.target.name property to go there like so;
I hope that was clear enough for the smart ones lol any how the complete code is a lot more clean and short the writing ten functions and ten event listeners here it is
Jonathan Jason
August 15th, 2008 at 7:48 am
Laura G
try it like this
you error was you didn’t put assign function to the event handler at the end of your line of code.
Jonathan Jason
August 15th, 2008 at 8:21 am
LOST in AS3 here is the code I think you need for your project when trying to flip from one frame to another you can use really simple math and the “Read Only” property of the MovieClip time line “currentFrame” and by using if statements you can loop from the first frame to the last with out running out of bounds.
Jonathan Jason
August 15th, 2008 at 8:25 am
Josh
take a look at where you placed your code it sounds like the code is in the wrong place
try putting it on a frame that can be read through out the whole movie
if that doesn’t work post your code so we can take a look at it.
Steve
August 15th, 2008 at 12:52 pm
Why on earth would they make it more complex? You would think that they would make the code shorter or something instead of twice as LONG!
Laura G
August 16th, 2008 at 7:43 am
Jonathan - i got the same error message referring to the first line of script
James
August 25th, 2008 at 10:37 am
Help! I have created a Flash CS3 Home page. I have a preloader on Frame 1 of my Actions layer. I have a stop action on Frame 32. I have 7 rollover buttons that animate as the come into the page. If I test the movie, it plays and stops on Frame 32. Each button is on its own layer. Where in the heck do I add the scripts that I want to add a URL script to each button? I have tried several places. If I add it to Frame 32, after the “stop();” the movie just keeps looking instead of stopping. This is so much of a pain than AS2. Why can’t you add a script to a button directly? Any advice would be much appreciated. - James
eric
September 4th, 2008 at 7:38 am
What if you want to create a map and you have multiple buttons that you want to have the same behavior on them but don’t want them to do anything other than display a pop-up next to the object being used as a button?
Ana
September 5th, 2008 at 6:41 pm
I need some help with more than one button on a page. One button works fine. When I add the script for two or more buttons, the flash movie just starts from the beginning again.
I did add a stop(); in the beginning, what am I missing?
Andrea
September 8th, 2008 at 1:15 pm
I’m really new at this whole AS3 thing. I know how to make a button in AS1 & 2, but AS3 is not so easy. I used the code from above and also used a code to go directly to a scene (I’d prefer the latter)
This is my code:
This is the error message:
Alex
September 12th, 2008 at 5:13 am
I have imported a video(AVI) and I need it so when anywhere on the page is clicked it goes to another scene and frame. I have tried many things and none seem to work! if any one can help please let me know!!
Thanks in advance
Phil
September 28th, 2008 at 11:52 am
Hi I’m trying to do the simplest of things a simple button hyperlinked to another page everytime I do i get this error.
This is my code.
Any help will be appreciated thanks
marie
October 6th, 2008 at 12:54 pm
hi. i was wondering if anyone can tell me how/ why a button with a rollover function within a movielip in the main timeline does not work?
thanks!
Cristina
October 16th, 2008 at 6:20 am
Thank you for this tutorial. I am a graphic designer not a programmer and it is been so frustrating to transfer between FLASH MX and FLASH CS3 it was a whole new monster. Your tutorial was so easy and understandable I think I can move on now and start playing with more stuff in flash thanks for all your help =)
Michael
October 17th, 2008 at 8:54 am
I have a question, I need help. What I want to do is make a button that when you click on it it opens a SMALLER pop up window, that doesn’t have a nav bar or anything.
Like when you’re shopping online and you click on a pair of pants and a pop up window pops up that has a larger image and description and price of the pants.
This is in AS3.
I understand how buttons work but I’m not sure of the code on this. Any help would be immensely appreciated.
Thanks
Rob Johnson
October 20th, 2008 at 6:34 am
Hi there.
I’m not overly new to Flash but I have created some buttons from text and the text appears with a box around it showing it as a button….BUT when I test the movie, the button only registers if the mouse is hovered over the text directly and has no hitbox around it. This has never happened before, any ideas?
thanks,
Rob
GABRIEL
November 5th, 2008 at 9:55 am
U R GREAT!!! THAT´S RIGHT!!! I HAVENT CLUE OF ACTIONSCRIPT 3.0…in fact, i speak spanish, so its double hard for me. but u……..yes u!!!!!!! i love you! hahaha
thanks a lot, for real!
HelpMe
November 6th, 2008 at 5:01 am
BUTTON DOESN’T WORK AFTER CLICKING TO NEXT FRAME
Hi
I have a problem with my button navigation. I would like my buttons to work after being clicked, but it seems that my buttons works fine but if I want to reclick them again they stop working. I have each frame name in instances and have my actions on a different layer. Also, they I have made sure that the instances are also copied and named. There are no errors but I do not know why it is not working. This is my code:
PLEASE HELP! Thanks!
HelpMe
November 6th, 2008 at 5:02 am
BUTTON DOESN’T WORK AFTER CLICKING TO NEXT FRAME
Hi There
I have a problem with my button navigation. I would like my buttons to work after being clicked, but it seems that my buttons works fine but if I want to reclick them again they stop working. I have each frame name in instances and have my actions on a different layer. Also, they I have made sure that the instances are also copied and named. There are no errors but I do not know why it is not working. This is my code:
PLEASE HELP! Thanks!
Skeet
November 6th, 2008 at 4:33 pm
Hey guys,
I got my 4 buttons working by using if and elseif statements.
The below action script is added to layer 1 in the main scene. The buttons are added to layer 2 and there is a holding movie called main_mc which is added to layer 3 - within main_mc is where all the main website content goes, and what the ‘gotoAndPlay’ frame numbers refer to (remember to put the stop(); function at the frame within main_mc that you’ve told it to go to). The buttons will work every time you click on them :-
I understand why Adobe have made AS 3.0 like this but it is a pain is the arse to have to write code to do what was previously a very simple task!
Cheers,
Skeet
Eric Valdi
November 13th, 2008 at 1:39 pm
Hi everyone - I am having trouble making a movie clip called SJH_1 invisible on the stage. The movie clip plays a short slide show as the page loads - but when a site visitor clicks on a button, a video plays and I want to hide the slide show movie clip.
When I test the movie, a compiler error appears stating that an undefined property (SJH_1) is being accessed. SJH_1 is on stage by the time the function is called (and of course it is in the library).
Does anyone know why Flash considers SJH_1 to be undefined?
And, is there a different/better way to remove something from the stage than setting visible to false?
Thanks for any help!
LepyTheDinosuar
November 15th, 2008 at 8:08 pm
Hey everyone.
I don’t have a problem or anything, but I just wanted to know:
Why did they complicate AS?
I used to be able to click on a symbol, open the action panel, and write:
but now… I just don’t know.
Doug
November 17th, 2008 at 5:08 am
Any help with this code would be appreciated. I’m trying to get mouse to turn into crosshair and to have it work on a linked butoon. Each code works sepaerately but not together.
Dave
November 17th, 2008 at 4:42 pm
So I understand the whole button deal in AS3. My question/concern is a bit different here. I’m trying to do the following -
Let’s say i have 2 buttons ( to make this simple) The buttons are movie clips, inside a movie clip and this MC is placed in the main timeline.
So the user hits button 1, this makes the main timeline go to and stop at frame 5 where a little animation of a menu unfolds and pops out. If the user hits button 2, it makes the main timeline go to frame ten and have a like MC play.
What i am trying to do here is this - let’s say i’ve hit button 1, im at frame 5, my little menu has popped out. I want to be able to hit button 2, have the movie in my current frame reverse and then proceed to the new frame designated by button 2.
I have the reverse animation built into the movie clips. I just need to figure out how to make button 2 tell the movie clip in the current frame (given there will be more than two buttons in the real project) to tell the MC to gotoAndPlay a frame and then when it gets to it’s last frame proceed to the new frame designated by button 2 in the main timeline.
Any ideas?
Anonymous
November 28th, 2008 at 7:56 pm
EVERYONE MAKE SURE THAT FLASH KNOWS THAT IT IS LISTENING FOR AN EVENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
place this code at the top of your actionscript:
Harry
November 30th, 2008 at 3:23 pm
I have a button the same size as a banner ad I’ve created. I’ve used the following action script (borrowed from you).
when I test my movie I get this error in Flash player 8:
Harry
November 30th, 2008 at 3:36 pm
Sorry…
The error is:
peterd
December 3rd, 2008 at 8:03 am
Harry,
The code you’re using is ActionScript 3.0, which isn’t supported in Flash Player 8 (only Flash Player 9+).
Peter
Natalie
December 3rd, 2008 at 8:50 pm
I seem to have a problem with adding actionscript to a button…in previous version of flash i’d have no problem but with CS3 whenever I make or draw a button, it doesn’t allow me to add actionscript to it even though i have it selected. It says in the Actions window that the current selection cannot have actions applied to it. I have no idea what to do. any ideas?
Bianca
December 4th, 2008 at 7:15 pm
I’m new at this and am having HUGE issues with making any of my buttons work. I’ve been trying to link my buttons to other web pages and my first issue is that when i do test movie, even though I have a stop(); at the last frame, the movie loops over and starts again once i add any coding into the actions layer. Also when i put the codes in,
i keep getting these errors -
carly
December 5th, 2008 at 6:36 pm
i honestly don’t understand why mine isn’t working.
help!
that’s what i have
i copied exactly what you have, changed monkey_btn to btn1, and changed the url!
what’s going on!
Jen deHaan
December 5th, 2008 at 8:57 pm
@Natalie: If you’re using the ActionScript 3.0 in this post, you need to add the AS to a frame instead of attaching it to a button. Give the button an instance name (select it and add the instance name in the Property inspector), and then add the code on a frame (select the frame instead of the instance and add the code in the Actions panel).
@Bianca: Make sure that you have added the instance name for the button.
@Carly: Do you see errors? If so, which ones? The code looks fine. Maybe make sure that you have ActionScript3.0 in your publish settings. Also make sure that there are no funky quotation marks or similar the code (after pasting from the web) - you might want to copy and paste from notepad, etc.
Bianca
December 6th, 2008 at 4:49 pm
that is the instance name that i gave it.. am i using a wrong format for the instance name? in lynda.com thats how they explained an instance name could/should be. and also regarding your response for natalie’s, do you add the script to the frame that the button is on in the actions layer? and what if i have a tween for the button, do i add the script into the last frame that the tween is on? or the first?
sorry i have soooo many questions
Bianca
December 6th, 2008 at 7:11 pm
I fixed the issue the with instance name, but I also put a stop action in so the page wouldnt loop over and its still looping over and over when i test movie. WHYYY?? i have the button set as anti-alias readability, what should it be instead?
also, im getting an error that says:
Jen deHaan
December 6th, 2008 at 10:52 pm
Can you put your FLA somewhere for download so I can take a look? or send it to flashhelp (at) gmail
Bianca
December 7th, 2008 at 5:22 pm
i just emailed the FLA i also have another question - hopefully this one is more simple.
im trying to import an external word file into a text field to make it scrollable. I made the file in word and added a .txt ending to it so actionscript can read it and when its saved it shows up as coding and after my coding is up i just shows a little bit of coding as the word file instead of the words. here is my actionscript - but i think the problem is moreso with my text-file…
Bianca
December 7th, 2008 at 5:37 pm
..or is there a way to just copy/paste the text and have it dynamic and have it work that way? when i did that before.. it loaded but once I tried to scroll, the text disappeared… SORRY!! I know this is a lot of coding and stuff!
thanks
Bianca
December 7th, 2008 at 6:35 pm
i figured out the txt… thank you though. i still need help with the web page linking.
Bianca
December 7th, 2008 at 8:31 pm
actually… with the coding i left earlier.. the text i imported as an external file loaded properly now and in the SWF and HTML files, once i drag the scrollbar, the text scrolls, but I loaded the page onto the FTP server and when i hit the scroll bar button, the text disappears. I dont know if its something in the publishing settings, or in the coding… i also loaded the external txt file and the same thing happened.
HELP
Jen deHaan
December 8th, 2008 at 10:59 am
OK, so in the FLA file you want to put a double equals in your if statement (the second error in the Compiler Errors panel). Change
if( pEvent.target = younghottBtn )toif( pEvent.target == younghottBtn )and then the stop action and the button code should work as expected.Rob
December 8th, 2008 at 2:46 pm
I’m trying to make a button link to a downloadable file, but right now I can’t even get it to link to another web page. Here is the code I have in the action bar for frame 158 (the last frame in the clip):
Now when I run the movie in test mode, I get this error message in the output bar (not the compiler errors bars)
What does this mean and how can I fix it?
Thanks.
Bianca
December 8th, 2008 at 6:36 pm
OMG thank you thank you :)
Bianca
December 8th, 2008 at 6:49 pm
sorry i keep bothering you… i tried copy/pasting that code and changing the names for the rest of the buttons I have on that page, but i keep getting these errors:
Peter deHaan
December 9th, 2008 at 6:53 am
Rob,
What is
vcflink1? Are you creating it in ActionScript, or is it an instance on the Stage?My wild guess is that you’re creating it in ActionScript and have something like
var vcflink1:MovieClip;but didn’t addvcflink1 = new MovieClip();. Complete random guess, but the only thing I can think of based on the code snippet/error.Peter
Rob
December 9th, 2008 at 6:56 am
vcflink1 is the instance the button on the stage.
Rob
December 9th, 2008 at 7:15 am
Okay, I got it to work (though I’m not sure how exactly), but I added on some frames at the end of the clip and moved up the keyframe on the action layer, so perhaps that was it. Either way, thanks for all the useful info on your site here.
Jen deHaan
December 10th, 2008 at 9:30 am
@Rob: Glad you got it to work :)
@Bianca, you need to have different function names for each button (you may be able to simplify your code too) - check out this entry for some code you can use and an explaination: http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/
Uday
December 13th, 2008 at 1:38 pm
Hi All,
Any one can convert the following AS 2.0 code into AS 3.0?
btnDisplay.onPress = function(){
trace(”start Show”);
}
// I am calling the action of btnDisplay by another button…
btnShow.onPress = function(){
btnDisplay();
}
I need the same functionality in AS 3.0. so please any one can tell me predifined buttton’s action from other action
Thanks,
Uday
laloka
December 16th, 2008 at 4:44 am
Hi_going crazy with AS3, pretty sure I’ve done everything you guys recommend, but this is my problem:
I want 2 simple text buttons to take me to 2 different urls and another simple image button to have a mailto link.
I can make 1 button work, no problem but as soon as I add scripting functionality for the other 2 the first one stops working and the rest don’t work either. I have tried adding numbers after the mousehandlers and am sure my instance names are correct.
Is this a mac safari/firefox issue? Is there a workaround?? Here is the code and I will email you the fla file just in case you can give me a hand. Any help super appreciated!
eng_bot.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.yogamountainyogasea.com/index.html”));
}
esp_bot.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.yogamountainyogasea.com/esp/index.html”));
}
laloka
December 16th, 2008 at 8:45 am
oh…sorted it out– i wasn’t naming instances on the stage but on the TIMELINE! duh!
Lisa
December 18th, 2008 at 8:19 am
I’m a super newbie to Flash CS3. I have imported a graphic into Flash, converted it to a button symbol, but when i click on the button in the stage, it says “Current selection cannot have actions applied to it’.
I have imported both a gif and jpg. I have clicked on the button itself and gotten the ‘up,over,down,hit’ frames, but still cannot apply any scripting. The nav bar I’m trying animate has a left arrow, #’s 1,2,3 and a right arrow. My intent is to have the numbers go to a specific graphic. For the arrows I want them to go to the previous graphic (if user is on #2, and clicks on the arrow, he should see #1.
Any help would be MUCH APPRECIATED!
Lisa
Calvin
December 19th, 2008 at 3:45 pm
Hi! I just started working with CS4 pro, AND I HAVE NO IDEA HOW TO MAKE THE BUTTON GO TO THE NEXT FRAME!!!!!!!!!! Please help because I aslo need It to stop at all frames.
Michael Horne
December 23rd, 2008 at 4:36 am
Thanks for helping me to get this work - it was driving two of us in our office up the wall.
btnSpecialOffers.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.microsoft.com”)}
Squidge
December 29th, 2008 at 7:42 am
Hey,
I’m making an animation, and it was working fine until I put a movie clip on one of the frames. When I tested the movie, the button went back a few frames instead of going to the next one. It worked fine before, but now I can’t fix it. Can anyone help?
This is what it says in the output when you get to the frame:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at WelcometomyChristmas_fla::MainTimeline/frame12()
at flash.display::MovieClip/gotoAndStop()
at WelcometomyChristmas_fla::MainTimeline/mouseDownHandler10()
Thanks
sPlatterKep
January 7th, 2009 at 1:39 pm
Hello,
I nearly have this, could use a nudge! Using suggestions from Skeet (11/6), as well as Jonathan Jason (8/15) I have the following code, which works great, except that in the MC containing the content, when it goes to the frame it’s supposed to, when clicking the same button makes it jump to the next frame, as though the btnName value is lost,
-btns are on a layer in scene 1
-AS is too
-mc with content is too
-stops(); are in the MC where needed
AS from scene 1, frame 1:
stop();
home_btn.addEventListener(MouseEvent.CLICK, navigate);
about_btn.addEventListener(MouseEvent.CLICK, navigate);
map_btn.addEventListener(MouseEvent.CLICK, navigate);
donate_btn.addEventListener(MouseEvent.CLICK, navigate);
function navigate(event:MouseEvent):void
{
var btnName = “”;// creates an empty variable to hold the button/label name
btnName = event.target.name;// grabs the name of the button
main_mc.gotoAndPlay(btnName); // applies the name of the button as the gotoAndPlay target
}
eD sOLO
January 11th, 2009 at 5:40 am
stop();
import flash.events.MouseEvent;
button1.addEventListener(MouseEvent.CLICK,
rMOVE);
function rMOVE(event:MouseEvent):void{
gotoAndStop(2);
}
i get a message saying 1120:Access of undefined property button1.
i dont know what im supposed to do to define the property of the button - or even what that means!
please help
sPlatterKep
January 12th, 2009 at 5:34 am
FYI: I think I got it working, changed the line to read:
main_mc.gotoAndStop(btnName); // applies the name of the button as the gotoAndStop target
Thanks for all the ideas, etc. on this page!
Smory55
January 12th, 2009 at 11:13 am
enter_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent): void {
navigateToURL(new URLRequest(”http://www.tadreebhr.com/”));
}
it didn’t work for me I got an error massage
Nadi Z
January 15th, 2009 at 4:40 pm
Hi Jen,
How do I link my buttons to another .html page within my own website? I tried the URLRequest function and it works, but the web browser opens up a new tab every time you click a button in the navigation bar! I don’t want that. Help!!!!
JoeG
January 19th, 2009 at 4:03 pm
Hey Some Great Tips here, I was wandering if you could help an amateur like me!? I have a button in my script that when clicked will display the contents of a text file :
/*
var req:URLRequest = new URLRequest (”content.txt”);
var loader:URLLoader = new URLLoader();
function clickMouse(event:MouseEvent ):void
{
text_btn.addEventListener(MouseEvent.CLICK,fileLoaded);
}
function fileLoaded(event:Event):void
{
content_txt.text = loader.data;
}
loader.addEventListener(Event.COMPLETE, fileLoaded);
loader.load(req);
*/
However when this is uncommented and run, the text is already loaded, without the button having been pressed? What silly oversight have I made.
Kind Regards,
Joe
SiuMing
January 24th, 2009 at 3:54 pm
To make this open the link in the same window, here’s the code:
monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.flashthusiast.com/”), “_self”);
}
Sahafi
January 25th, 2009 at 9:32 am
I’m trying to work with CS3 after working with Flash 8 and am trying to get 5 buttons to navigate to different frames. Although I am not getting any errors but it still isn’t working.
I tried two things so far and in both attempts only my bio button navigates. help please
attempt #1
stop();
import flash.events.MouseEvent;
homebtn.addEventListener(MouseEvent.CLICK, powerClick);
function powerClick1(event:MouseEvent):void {
gotoAndStop(1);
}
biobtn.addEventListener(MouseEvent.CLICK, powerClick);
function powerClick(event:MouseEvent):void {
gotoAndStop(2);
}
designbtn.addEventListener(MouseEvent.CLICK, powerClick);
function powerClick3(event:MouseEvent):void {
gotoAndStop(3);
}
photobtn.addEventListener(MouseEvent.CLICK, powerClick);
function powerClick4(event:MouseEvent):void {
gotoAndStop(4);
}
videobtn.addEventListener(MouseEvent.CLICK, powerClick);
function powerClick5(event:MouseEvent):void {
gotoAndStop(5);
}
Attempt 2:
stop();
import flash.events.MouseEvent;
homebtn.addEventListener(MouseEvent.CLICK, oneClick);
function oneClick(event:MouseEvent):void {
gotoAndStop(1);
}
biobtn.addEventListener(MouseEvent.CLICK, twoClick);
function twoClick(event:MouseEvent):void {
gotoAndStop(2);
}
designbtn.addEventListener(MouseEvent.CLICK, threeClick);
function threeClick(event:MouseEvent):void {
gotoAndStop(3);
}
photobtn.addEventListener(MouseEvent.CLICK, fourClick);
function fourClick(event:MouseEvent):void {
gotoAndStop(4);
}
videobtn.addEventListener(MouseEvent.CLICK, fiveClick);
function fiveClick(event:MouseEvent):void {
gotoAndStop(5);
}
tavi
January 25th, 2009 at 10:18 am
ummm…i tried what everyone said but then it said this
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/frame1()
what does that mean?
Michael Parker
February 1st, 2009 at 12:07 am
Thanks for the great tutorial - Flash CS4 takes a little while to get used to.
Muhammad Kashif Nayab
February 2nd, 2009 at 1:15 am
Hi all
I’m trying to create links/buttons in Flash CS3 with ActionScript 3.0.
It’s working fine when there is only one link/button, code reference below:
myButton.addEventListener(MouseEvent.CLICK, MouseDownHandler);
function MouseDownHandler(event:MouseEvent):void
{
navigateToURL(new URLRequest(”URL”), “_self”);
}
But when I try multiple links/buttons I keep getting this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Here is the code reference:
DealOne.addEventListener(MouseEvent.CLICK, onClickDealOne);
DealTwo.addEventListener(MouseEvent.CLICK, onClickDealTwo);
DealThree.addEventListener(MouseEvent.CLICK, onClickDealThree);
DealFour.addEventListener(MouseEvent.CLICK, onClickDealFour);
DealFive.addEventListener(MouseEvent.CLICK, onClickDealFive);
function onClickDealOne(event:MouseEvent):void
{
navigateToURL(new URLRequest(”http://www.tuttibambini.co.uk/index.php?main_page=product_info&cPath=&products_id=461″), “_self”);
}
function onClickDealTwo(event:MouseEvent):void
{
navigateToURL(new URLRequest(”http://www.tuttibambini.co.uk/index.php?main_page=product_info&cPath=&products_id=462″), “_self”);
}
function onClickDealThree(event:MouseEvent):void
{
navigateToURL(new URLRequest(”http://www.tuttibambini.co.uk/index.php?main_page=product_info&cPath=&products_id=463″), “_self”);
}
function onClickDealFour(event:MouseEvent):void
{
navigateToURL(new URLRequest(”http://www.tuttibambini.co.uk/index.php?main_page=product_info&cPath=&products_id=464″), “_self”);
}
function onClickDealFive(event:MouseEvent):void
{
navigateToURL(new URLRequest(”http://www.tuttibambini.co.uk/index.php?main_page=product_info&cPath=&products_id=465″), “_self”);
}
I try but I can’t figure out what that is…
Any help is always appreciated.
Thanks with Best Regards,
Muhammad Kashif Nayab Uddin
Janders
February 6th, 2009 at 1:38 pm
I am teaching students how to create a puzzle game. I am worried that if there are going to be 30 puzzle pieces, that there will be A LOT of code in order to get each piece drag-able. Each piece is going to be a button. I have one piece that I can drag and I see from this site that I need a new function name for each new button. Is there a more efficient way of programming 30 different buttons that are each click and drag-able?
Thanks!
square_btn.addEventListener(MouseEvent.MOUSE_DOWN,mouseDOWN);
function mouseDOWN(event:MouseEvent):void {
startDrag();
}
square_btn.addEventListener(MouseEvent.MOUSE_UP,mouseUP);
function mouseUP(event:MouseEvent):void {
stopDrag();
}
Wojo
February 8th, 2009 at 5:54 pm
I have a menu problem i have this script on frame 1 of my timeline in an actions layer. The first script pans out to frame 30 where everything on the timeline ends. Script works perfectly.
function gotoHome(evt:Event):void {
gotoAndStop(”home”);
}
function gotoPartsandrims(evt:Event):void {
gotoAndStop(”rims”);
//<—- I am trying to get this menu to jump to frame 31 of my //timeline to goto the other menu.
}
function gotoGallery(evt:Event):void {
gotoAndStop(”gallery”);
}
function gotoLocation(evt:Event):void {
gotoAndStop(”location”);
}
function gotoContact(evt:Event):void {
gotoAndStop(”contact”);
}
function gotoStorehours(evt:Event):void {
gotoAndStop(”storehours”);
}
home_btn.addEventListener(”click”,gotoHome);
partsandrims_btn.addEventListener(”click”,gotoPartsandrims);
gallery_btn.addEventListener(”click”,gotoGallery);
location_btn.addEventListener(”click”,gotoLocation);
contact_btn.addEventListener(”click”,gotoContact);
storehours_btn.addEventListener(”click”,gotoStorehours);
then on frame 31 of the time line i have a similar script for another set of buttons.
function gotoRims(evt:Event):void {
gotoAndStop(”rims”);
}
function gotoTires(evt:Event):void {
gotoAndStop(”tires”);
}
function gotoLighting(evt:Event):void {
gotoAndStop(”lighting”);
}
function gotoInterior(evt:Event):void {
gotoAndStop(”interior”);
}
function gotoExterior(evt:Event):void {
gotoAndStop(”exterior”);
}
function gotoPerformance(evt:Event):void {
gotoAndStop(”performance”);
}
rims_btn.addEventListener(”click”,gotoRims);
tires_btn.addEventListener(”click”,gotoTires);
lighting_btn.addEventListener(”click”,gotoLighting);
interior_btn.addEventListener(”click”,gotoInterior);
exterior_btn.addEventListener(”click”,gotoExterior);
performance_btn.addEventListener(”click”,gotoPerformance);
This script works fine as well. Although when i run the whole time line the two scripts dont work with each other.
i get the following error :
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FocusMainPageTemplate_fla::MainTimeline/frame31()
at flash.display::MovieClip/gotoAndStop()
at FocusMainPageTemplate_fla::MainTimeline/gotoPartsandrims()
I could use all the help i could get i am just a beginer i dont understand why it is doing it due to probably lack of knowledge. I have many books and i cannot find an answer.
k
February 17th, 2009 at 6:25 am
hi im just a beginner at flash and seem to be having some trouble. i had followed the steps exactly and when i come to test the button i get error 1021: Duplicate function definition.
could you help in this
thanks
Aditya M P
February 17th, 2009 at 9:01 am
Thanks a lot for the great tutorial… :)
Aditya M P
February 17th, 2009 at 9:02 am
And @k:
He has explained about the “Duplicate function error” in the first few comments, lazy ass, just check them out!
Cyprian
February 18th, 2009 at 8:22 am
Hi Guys, hope someone can help. I have a simple banner made in F CS3 and the website where i want to upload it to requested to add button which i did and then add:
on (release)
{
getURL(_level0.Tag,”_blank”);
}
Unfortunately after adding this scrip the movie starts looping although it has stop(); in the top layer.
My questions are: how to make this clickTag work and stop the movie from looping?
Any help would be appreciated
sandra
February 20th, 2009 at 10:02 am
hi there,
I’m just trying to do simple buttons with the following code:
stop();
bplay.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function startBall(event:MouseEvent):void
{
gotoAndPlay(2);
}
but it just wont work..
1120: Access of undefined property bplay.
1120: Access of undefined property mouseDownHandler.
why this is appening?
tanks
Wednesday
February 22nd, 2009 at 5:45 am
The code supplied to open the URL in the same window (rather than new window all the time which looks messy) doesn’t seem to be working???
monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.flashthusiast.com/”), “_self”);
}
I have my buttons working but added the “_self”); and got an error message? Any help much appreciated as this is really bugging me now! :)
16 Buttons
February 24th, 2009 at 3:18 pm
I’m working with an interactive map graphic in Flash CS3. I want to create 16 buttons that will react when the mouse moves over the hit area. I’ve got that part working. But I need help with the action script to load an external text file. I want each button to trigger dynamic text to display in a popup. Can I use one text file for the whole project? Or do I need 16 diff txt files, one for each button? Can you help?
Ana
February 25th, 2009 at 9:06 am
I am new to Flash so this is a simple one for you - but not so much for me: I just need my button to link to URL which would open in a new window. How do I do that?
Holly
February 27th, 2009 at 5:32 am
How do i link my button to another webpage that i have made on flash?
Ryan
March 2nd, 2009 at 12:01 pm
I am having trouble making a button link to the next frame. I am getting this #1009 error message ” TypeError: Error #1009: Cannot access a property or method of a null object reference.
at website3_fla::MainTimeline/frame2()
at flash.display::MovieClip/gotoAndStop()
at website3_fla::MainTimeline/enterSite()”
this is my code for moving from the first frame to the second:
stop();
import flash.events.MouseEvent;
button.addEventListener(MouseEvent.CLICK, enterSite);
function enterSite(event:MouseEvent):void {
gotoAndStop(2);
}
Any reason why that shouldn’t work?
Thanks a lot
Colin Santos
March 3rd, 2009 at 9:19 am
This totally worked. Your tutorial rocked my face. Thanks with every fibre of my being.
Angela Bittner
March 15th, 2009 at 11:42 am
Hi I’m new to flash and CS3 I’m working on a flash project and my scene has three buttons which are presents the viewer should be able to click on each present which then takes the viewer to the next scene which its not doing right now. Then when should be at the next scene the are two more buttons which is suppose to allow the view to click on and take them back to the beginning of the first scene which is the intro of the movie which I put the timeline location and then the second button takes the viewer back to another location on the timeline.
My five scenes are Intro, birthday, firetruck, bulldozer, and dog. I am trying to get one button to go from the dog scene to the Intro scene and the other button to go from the dog scene to the birthday scene.
Here is the error message I’m receiving:
ArgumentError: Error #2109: Frame label Intro not found in scene Dog.
at flash.display::MovieClip/gotoAndStop()
at final_project_2_Dog_fla::MainTimeline/boneClick11()
Here is my actionscript code:
stop();bone.addEventListener(MouseEvent.CLICK, boneClick11);function boneClick11(event:MouseEvent):void {
gotoAndStop(”Intro”);
}
stop();dogbowl.addEventListener(MouseEvent.CLICK, dogbowlClick12);function dogbowlClick12(event:MouseEvent):void {
gotoAndStop(”birthdayscene”);
}
Any suggestions would be greatly appreciated.
Justin Putney
March 16th, 2009 at 10:21 am
Angela,
The format of the gotoAndStop command reads like this:
gotoAndStop(frame, scene);
The first parameter is the frame. So
gotoAndStop(”Intro”);
will look in the current scene for a frame labeled “Intro”.
Your code should probably look like this:
gotoAndStop(1, ”Intro”);
That will send you to the first frame of the “Intro” scene.
ben
March 24th, 2009 at 5:29 am
hi — just wanted to say THANKS! been trying to get my head around AS3 all morning and just about to give up and go back to 2 then found this page, excellent!!!
Thank you thank you thank you!
Bryan
April 5th, 2009 at 2:02 pm
I am trying to get three buttons to work. I have defined all three buttons and they states work.
I wrote scripts for each button with the unique instances and unique function names.
stop();
b_treks.addEventListener(MouseEvent.MOUSE_DOWN, treksDownHandler);
function treksDownHandler(event:MouseEvent):void {
gotoAndStop(35, “Scene 1″);
}
b_tours.addEventListener(MouseEvent.MOUSE_DOWN, toursDownHandler);
function toursDownHandler(event:MouseEvent):void {
gotoAndStop(60, “Scene 1″);
}
b_cruises.addEventListener(MouseEvent.MOUSE_DOWN, cruisesDownHandler);
function cruisesDownHandler(event:MouseEvent):void {
gotoAndStop(60, “Scene 1″);
}
But, I am getting the following error messages:
1120: Access of undefined property b_treks.
1120: Access of undefined property b_tours.
1120: Access of undefined property b_cruises.
What am I doing wrong?
Bryan
April 6th, 2009 at 10:19 am
Is anyone listening?
lehoa
April 7th, 2009 at 2:59 am
You are amazing! Thanks for helping all us newbies to AS!!!!
Drachorn
April 9th, 2009 at 2:05 pm
This worked great!! Thanks so much!!! ^_^
karrem
April 13th, 2009 at 3:19 am
btn1.onRelease = function() {
getURL(”E:\desktop\Documents\Unnamed Site 2\home page.html”);
};
i want to load HTML file from my disk in flash cs3
can any one help me plzz
Steve
April 14th, 2009 at 6:03 am
how could I add a simple text on mouse_over that says Click for Model Gallery them on MoUSE_out the text goes away
would I use the gotoAndstop on a different frame or is there a command that let me do it over the button
thank you
AA
April 16th, 2009 at 12:49 pm
Just wanted to say thank you! Reading through the comments has helped me to figure out the tasks I needed to accomplish in my current project. It is so nice to see answers to the questions in the comments b/c so many are the exact same ones I had.
Some guy
April 18th, 2009 at 6:37 am
Err, could you explain to me how to make a button that just moves on to the next frame?
Dee
April 18th, 2009 at 7:30 am
Hello. I tried using one of the codes above. But my second button won’t work.
Here’s my action script
stop();
button1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndPlay(2);
}
button3.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler3);
function mouseDownHandler3(event:MouseEvent):void {
gotoAndPlay(93);
}
and on my output I have an error that says
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at myprojectname_fla::MainTimeline/frame1()
my first button works perfectly fine. But my second button deos not go to frame 93.
Help?
Bryan Amburgey
April 21st, 2009 at 10:32 am
Error #2109: Frame label bio not found in scene Scene 1
This is the code:
//handle events for buttons…
bio.addEventListener(MouseEvent.CLICK, clickSection);
function clickSection(evtObj:MouseEvent) {
//trace shows whats happening..
trace (”The bio button was clicked”)
gotoAndStop(”bio”);
I am copying and pasting my initial working code and I continue to get this error. With some buttons it works, with others it does not.
Thanks for your help.
Marcia
April 30th, 2009 at 9:14 am
Hello all:
I am having a REALLY hard time figuring out how to get buttons on my (masked) roll-down menu to function (URLRequest). I can only seem to get the buttons to go to the URL if I move the roll-down layer up a few levels above the mask. Of course, then I now longer have a masked roll-down. I have spun and spun my wheels on this and I can’t find ANY solutions. Can anyone help on this?? I will be eternally greatful :))
K
May 1st, 2009 at 8:11 am
Hi. I am working on a project. There are six buttons in it. I have all of them working except the exit button. I can not figure out the right code. Does anybody know how I can do this?
T
May 2nd, 2009 at 10:42 am
I need to get buttons to increase or decrease a score. Any ideas?
Reikko
May 2nd, 2009 at 11:23 am
Hi. I am an avid fan of flash really, though am newbie, i still know the basic fundamentals in flash but when it comes to scripting, I suck…
I am creating a slideshow with 5 pictures (or 5 scenes) and at least 6 seconds before it’ll change into the next pic.. I have tried to create a next button that will act as a skip if viewers dont wanna wait for few seconds to view the next pic. What code shall i use??
I saw this kind of slides in yahoo… last year i guess. And I really love it.. Can somebody please help me?? pls….
LEe
May 5th, 2009 at 4:21 am
Hi all I am working on my code and are looking to set a height and width command on the open urls dose anyone have an example of this I can use?
Tom
May 12th, 2009 at 1:35 pm
Am trying to allow for 4 buttons in one flash file to link to separate URLs and have them come up within in the same window. The current action script that I thought was right only allows for the banners to open just the first url for all of them and when I try to add _self nothing works.
——————————-
stop();
button1.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://169.254.87.7/joomla/index.php/pc/california-region-news”));
}
button2.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler2(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://169.254.87.7/joomla/index.php/pc/mid-atlantic?start=2″));
}
button3.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler3(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://169.254.87.7/joomla/index.php/nonprofit”));
}
banner1.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler4(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://169.254.87.7/joomla/index.php/liquor”));
}
alina12
May 14th, 2009 at 7:13 am
thanks i didi it and it worked with me
but i need the the link open in the same page how the script will looks like
Erin
May 16th, 2009 at 3:11 pm
I’m trying to create a simple image viewer, where the next button advances to the next frame of the timeline and the back button advances to the previous frame. How do I write AS3 to go to the next or previous frames, when this is a variable event? i.e., I can’t tell it to just go to frame 2… it needs to be something like x+1 or x-1. Here is the code I have so far:
stop();
function imgAdvance(event:MouseEvent):void {
gotoAndStop(2);
}
nextbtn.addEventListener(MouseEvent.CLICK, imgAdvance);
function imgRewind(event:MouseEvent):void {
gotoAndStop(1);
}
backbtn.addEventListener(MouseEvent.CLICK, imgRewind);
Mike
May 19th, 2009 at 6:34 am
I have been messing and researching this for over a week and I’m finally going to ask for help. I have a series of buttons for a nav bar. They each work fine when coded like this:
newsbtn.addEventListener(MouseEvent.CLICK,buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void
{
navigateToURL(new URLRequest(”News.html”));
}
The problem is that I don’t want the pages to open in a new window. If I add the , “_self” target the buttons don’t work at all. Please help I need to get this sight up and running soon.
FlashSpec
May 19th, 2009 at 2:04 pm
Mike, try this:
Parameters request:URLRequest — A URLRequest object that specifies the URL to navigate to.
window:String (default = null) — The browser window or HTML frame in which to display the document indicated by the request parameter. You can enter the name of a specific window or use one of the following values:
“_self” specifies the current frame in the current window.
“_blank” specifies a new window.
“_parent” specifies the parent of the current frame.
“_top” specifies the top-level frame in the current window.
Here’s some flash of mine: http://bit.ly/CtVgv - http://bit.ly/10Th0S
Mike
May 19th, 2009 at 2:29 pm
I tried it your way and yes it is working. The problem is that once I insert it into my page it doesn’t work. As a stand alone button it works and opens the page just fine but loaded into the site being built in Dreamweaver it doesn’t work at all.
PragmaticStatistic
May 20th, 2009 at 12:11 pm
I am new to Flash CS4 and am having problems with stop and goto button functions. I added the following code:
stop();
DurabilityBtn.addEventListener(MouseEvent.CLICK, buttonClickHandler1);
function buttonClickHandler1(event:MouseEvent):void {
gotoAndPlay(2);
}
PerformanceBtn.addEventListener(MouseEvent.CLICK, buttonClickHandler2);
function buttonClickHandler2(event:MouseEvent):void {
gotoAndStop(3);
}
If I use Actionscript 2 publsih settings the movie stops but function lines won’t load. If I use ActionScript 3 publish settings the movie won’t stop and I get the same won’t load function statements.
What am I doing wrong? Please help!
Chris Bolton
May 23rd, 2009 at 3:38 am
After literally searching for hours on the web re how to do this. Yours was the only solution I found that work. Thanks.
parisa afshin
May 25th, 2009 at 2:55 pm
thanks for sharing that Jen, great job! just what i was looking for : )
Layn
May 28th, 2009 at 4:52 am
Thanks for the awesome tutorial ! It helped, until the part where ihave to change the code. I’m a starter and I have NO idea what code you could possibly mean. Should I use the name of my button or something ?
Also, the way you named things, like “monkey”, made me confused, do I have to keep it or is it just fine to use exactly that what you wrote ?
I’m sorry if someone asked you this before, but I didn’t have enough time to look through all of those reply’s/
Thanks for your time :)
Gü Bosch
June 7th, 2009 at 5:35 am
THX for the awesome tutorial. It helped a lot.
Snap
June 7th, 2009 at 8:04 am
Need help with startDrag(true); on a MovieClip with mask inside it.
code:
N7.x=newX;
N7.y=newY;
N7.addEventListener(MouseEvent.MOUSE_DOWN, drag);
N7.addEventListener(MouseEvent.MOUSE_UP, drop);
// M7.MovieClip.mask(true);
function drag(event:MouseEvent):void {
event.target.startDrag(true);
}
function drop(event:MouseEvent):void {
event.target.stopDrag();
}
The problem seem to be that N7 is an instance of a MovieClip that contains a single frame, of two layers (one image and one shape that create a mask), if I only use the shape it is fine, but as soon as I use the mask function inside the N7 movieclip it give the error:
ReferenceError: Error #1069: Property startDrag not found on flash.display.SimpleButton and there is no default value.
at circle09_004a_fla::MainTimeline/drag()
I have searched everywhere, but can not find a way to make the drag function worked with a ‘masked’ bitmap inside a MovieClip. hope someone can help.
Berko
June 8th, 2009 at 2:31 pm
Why, oh why have they change this?! I was till now working in older version of flash with AS 2, and that method was in my opinion much better then this one; you have one button with script, and if you copy it, you have also copy that script with it, and then you just have to change some values in script and that new button had different function. Now you have to rename each button, and create separate script for each, and the dumbest thing is fact that you CANT PUT SCRIPTS ON BUTTONS!!! STUPID, STUPID, STUPID!!!
I think that I will delete this stupidity and return to old Flash….. Adobe, you have manage to ruin perfectly good software!
Michael
June 12th, 2009 at 5:41 pm
Great tutorial, but I’m wondering how to do this: I’ve created a movieclip inside of which is my menu, and inside of my menu are my buttons - my question is this. How do I get the buttons inside of the menu to link to frames in my original scene?
oliver
June 16th, 2009 at 12:38 pm
I’m working with this code
stop();
reel_btn.addEventListener.(MouseEvent.CLICK, onReelClick);
samples_btn.addEventListener.(MouseEvent.CLICK, onSamplesClick);
about_btn.addEventListener.(MouseEvent.CLICK, onAboutClick);
contact_btn.addEventListener.(MouseEvent.CLICK, onContactClick);
function onReelClick(e:MouseEvent):void
{
gotoAndStop(”reel”);
}
function onSamplesClick(e:MouseEvent):void
{
gotoAndStop(”samples”);
}
function onAboutClick(e:MouseEvent):void
{
gotoAndStop(”about”);
}
function onContactClick(e:MouseEvent):void
{
gotoAndStop(”contact”);
}
Whenever I run the SWF no error messages come up, but the buttons do nothing when click, everything else works fine, whats going on here can anyone help?
Mark
June 16th, 2009 at 10:32 pm
Hello Jen- I love your button script here:
monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.flashthusiast.com/”));
}
but how do I set a target to be “_self”? As it is, this only opens a new window. I want to remain in my same window/tab. Any ideas? Thanks, Mark
Mark
June 17th, 2009 at 10:05 am
How do you get the CS3 script to target a particular window? It seems the default is to open a new window, but I want it to remain in the same. If I add: , “_self” I get an error.
monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.flashthusiast.com/”));
}
Mark
June 17th, 2009 at 10:06 am
sorry for the double post! I thought my original one didn’t post yesterday. :(
Jen deHaan
June 17th, 2009 at 1:26 pm
Hi Mark,
Try something like this:
monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, thumbUpHandler);
function thumbUpHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.adobe.com”), “_self”);
}
Does that help?
Jen.
Jen deHaan
June 17th, 2009 at 1:27 pm
Also, make sure that you check the quotation marks and replace them in the script editor with fresh ones - sometimes copying and pasting from the interwebs adds funky quote marks which can lead to errors.
Elfriede Kruger
June 19th, 2009 at 1:39 am
I’m struggling to make a simple animation in flash where I have to switch between scene 1 and scene 2 by the use of a button. Thus when I click on button in Scene 1 it must redirect me to Scene 2. What is the actionscript for this simple task.
Matty P
June 19th, 2009 at 8:51 am
I’m using the code:
function gotoOrderPage(event:MouseEvent):void {
var targetURL:URLRequest = new URLRequest(”order.html”);
navigateToURL(targetURL);
}
order_btn.addEventListener(MouseEvent.CLICK, gotoOrderPage);
I want to get my order page to open in the same tab. what should I do?
Jen deHaan
June 23rd, 2009 at 12:35 pm
@MattyP: Check the code in the comment 3 entries above - you can target windows using that format. (I think I need to do a separate entry on this one!)
@Elfriede: Linking to different scenes is covered in this blog entry here: http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30 There is also a FLA available for download that does that very task.
SlamerX
June 26th, 2009 at 12:43 pm
Hi, i´m trying to close a movieclip and go to movieclip that i wan´t but how can i close a movieclip with code in as3.
my code is:
stop();
closestaff.addEventListener(MouseEvent.CLICK,clickSection);
function clickSection(evtObj:MouseEvent) {
//trace shows what’s happening.. in the output window
trace(”The “+evtObj.target.name+” button was clicked!”);
gotoAndStop(evtObj.target.portfolio_mc);
}
……..
i´m using name directly in teh but instance that work perfect but teh code to close i don´t know.
Adrian
June 28th, 2009 at 4:10 pm
10X A LOT, MAN!!!
Sam
July 1st, 2009 at 10:28 am
Hey chaps, I’m trying to make a basic small video play from a flash button. All I’m trying to do is have the video (”psp”) play when I click my button. I’m such a newb I know, but this is driving me nuts! Any help would be appreciated!
ana
July 13th, 2009 at 7:29 am
Great help, but i ran into a problem when i went to publish my document, the publish document sends me an error and doesnt send me to my page even though when i played the movie it did work, am i doing something wrong when i publish the file or is there something im missing?
theodoros
July 14th, 2009 at 1:20 am
hello,
i want to make a link button but open in the same window. this code open in a different window. what can i do?
thanks!
Legun
July 15th, 2009 at 7:55 pm
Is there a way on a mouseover on a button to change the background image of the scene and also have a hyperlink if a user clciks on the button?
Bobby
July 24th, 2009 at 10:10 am
I’m new to flash and having trouble picking the coding side of things. When I make symbols I end up not being to apply
code as it says “current selection can’t have actions applied to it”
any idea what it going on?
Jen deHaan
July 24th, 2009 at 12:50 pm
@ana: What error does it say?
@ theodoros: Please see this post about that topic: http://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/
@Legun: You could add a mouseover event which targets a movie clip that makes up the background (simplest way could be to gotoAndPlay a new frame that contains the new image, or you could load it).
@Bobby: For ActionScript 3.0, you need to have the code on a frame instead of attaching it right to the instance (you presently have the instance selected instead of a frame). Select a frame on the timeline, then you’ll be able to add your code in the Actions panel.
JPunisher
July 28th, 2009 at 8:29 pm
I don’t know much about AS3, but this really help me with the loop problem. Make sure you give your button an instance name! When you select it go to properties and then name it in the instance name block… Just thought it would help people in my predicament ;-D
Gresh
July 29th, 2009 at 1:51 am
I am a newbie. This stops my sound:
layer actions (frame 1):
stoper.addEventListener(MouseEvent.CLICK, stopMusic);
function stopMusic(e: Event) {
SoundMixer.stopAll();
}
but how am I to restart the sound from the place I stopped it?
I want to stop and start the animation as well as sound and I have two buttons: startBtn and stopBtn named starter and stoper.
Could somebody pleaeaease help!
Rodrigo
August 1st, 2009 at 3:35 pm
My problem is that#
/*import flash.event.MouseEvent;
import fl.controls.Button;*/
import fl.transitions.Tween;
import fl.transitions.*;
menu_bloque.x = home_bt.x;
underline_mc.x = home_bt.x;
products_bt.addEventListener(MouseEvent.ROLL_OVER,moveUnderline);
function moveUnderline(event:MouseEvent):void
{
underline_mc.x = event.currentTarget.x;
/*new Tween(underline_mc,”x”,Strong.easeOut,underline_mc.x,e.currentTarget.x,12,false);*/
}
and I have this
The class or interface ‘MouseEvent’ could not be loaded.
help mi please
function moveUnderline(event:MouseEvent):void
Alexander
August 4th, 2009 at 3:03 am
Hi I am designing a flash cs3 website and I want to include an intro that ends with buttons that will lead to the different pages (frames like home, about us, contact…) of the document. How do I write the actionscript for the buttons to lead to the various labelled frames in Scene 1, since the buttons are in the intro movie symbol? The code I tried is below, nothing happens after I click it.
stop()
Home2.addEventListener(MouseEvent.CLICK, clickHome2);
function clickHome2(event:Event):void {
trace(”home”);
gotoAndStop(”Home”);
}
Aboutus2.addEventListener(MouseEvent.CLICK, clickAboutus2);
function clickAboutus2(event:Event):void {
trace(”Aboutus”);
gotoAndStop(”Aboutus”);
}
Membership2.addEventListener(MouseEvent.CLICK, clickMembership2);
function clickMembership2(event:Event):void {
trace(”Membership”);
gotoAndStop(”Membership”);
}
Jen deHaan
August 7th, 2009 at 9:35 am
@Rodrigo: It sounds like your document is set to ActionScript 2.0 - try changing it to ActionScript 3.0 and you shouldn’t see that error.
@Alexander: For information on targeting different scenes, see this post: http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/ (there’s a FLA file linked there too).
ruth
August 10th, 2009 at 2:01 pm
Hi,
I followed the instructions you laid out (or at least i think i did), and the button shows up fine, but when I click on it, the website doesnt actually pop up and it gives me an error. I named the button bu1 and changed the code so that it’s acting on bu1, but it still says this: “access of undefined property bu1″ and it says the error is occuring in this line: bu1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
any idea what im doing wrong? I’m super new at this, so please explain to me in as plain english as possible.
please help me!! thanks!
Jen deHaan
August 10th, 2009 at 2:08 pm
@Ruth: The first thing to check is if you have an instance name on the button (perhaps you named the button symbol when you created it but not the instance that’s on the Stage?) That’s the error one would see when there’s a problem with the instance name.
Make sure when you select the button on the Stage, that the text box in the Property inspector (Window > Properties) says bu1.
Hope that helps,
Jen.
ruth
August 10th, 2009 at 2:12 pm
thanks jen! it worked!
and for the speedy response… it normally takes me days to get answers online
Juan Pablo
August 18th, 2009 at 8:22 pm
hey there…
I am running into a little problem.
You see my buttons are inside a movie clip or navigation bar.
Somehow I am getting the following error message and I cannot seem to be able to fix it…
Alas the error message!
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Index3_fla::MainTimeline/frame 1()
What do you recommend I do to fix it?
Good site, it’s taught me a lot throughout my flash career.
JP
stephen gonzales
August 23rd, 2009 at 8:32 am
Hello,
I’m new to cs3 and I am attempting my first full website in flash. I’m at the point of buttons and navigating within the web site. I created my buttons, but how do I make it when I click the button, it then goes to another place and makes the initial page disappears after that? Does the new location have to be on a new timeline, layer, scene, or what? Might you assist me with this, thanks?
Graham
August 24th, 2009 at 12:53 pm
Hi ,
I was wondering if you had any issues with this working in Internet Explorer. It works with FF ok.
Any ideas??
Ayesha
August 28th, 2009 at 8:46 am
What is a Handler?
stefan
August 31st, 2009 at 10:47 pm
Hi everyone, thx Jen for this post, i think i spend 2 hours figuring out how to do this in as3
Now i got another trouble in my quest to beat as3
i use this code to load text from php in as2 but in as3 i don’t have any idea how to do this.
a=new LoadVars
a.load(”myphp.php”)
a.onLoad=function (){
text_txt.text=this.var_name
}
And i think maybe you could help, help me please jen! you rule! Thanks in advance
Stacey
September 1st, 2009 at 6:19 am
Hi there.
I’m trying to link one scene to another.
It works correctly on one but when I copy and paste it gives me errors. It’s just a button to link to a scene (same on all pages).
Here’s the code:
stop();
allOn_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(106, “allOn”);
}
Here’s the error:
1021: Duplicate function definition.
Please help I only have this to finish!!!!
stefan
September 1st, 2009 at 12:58 pm
Try this Stacey
stop();
allOn_btn.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
function mouseDownHandler(e:MouseEvent):void {
gotoAndStop(”106″);
}
stefan
September 1st, 2009 at 1:05 pm
If you’re using this in other places you don’t have to define again the function ’cause you already did it, i think this is why it gives you that error.
stefan
September 1st, 2009 at 2:17 pm
stop();
allOn_btn.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler2);
function mouseDownHandler2(e:MouseEvent):void {
gotoAndStop(”106″);
}
Jen deHaan
September 4th, 2009 at 1:51 pm
@stefan (re: loadvars) - Peter Elst has a good post about the difference between AS2 and AS3 here: http://www.peterelst.com/blog/2007/11/28/actionscript-30-wheres-my-loadvars/
hope that helps,
Jen
Krysie
September 8th, 2009 at 12:23 pm
I’m using CS4, I tried using the above script and changed the name to my name (BTN), and the below is what I have, and its not working (not clickable) in IE, although it works fine in Firefox….
BTN.addEventListener(MouseEvent.MOUSE_OVER, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.flashthusiast.com/”));
}
Any thoughts or suggestions?
Nessie
September 10th, 2009 at 4:41 am
Finally! After hours of searching someone finally explained how to create a freakin’ button that works with AS3. Thanks!
.Adi.
September 11th, 2009 at 10:39 pm
Great tutorial, thnx!
CS3 is really wird: In the old versions of flash you don’t have to be an Actionscrip geek to add a hyperlink to a flash button. you could do it by few mouse clicks;(
stefan
September 17th, 2009 at 10:20 pm
Thx a lot for the link Jen, i guess that solve my problem, thx again.
Robert
September 23rd, 2009 at 6:46 am
Hello everyone! I have a problem. When I click the MovieClip called “chicken_hotspot” it should go to the frame called “news”. But in fact it does not do it but the other functions become unresponsive. What’s wrong?
THIS IS THE CODE:
chicken_hotspot.buttonMode = true;
chicken_hotspot.useHandCursor = true;
chicken_hotspot.addEventListener(MouseEvent.MOUSE_UP, gotoNews);
chicken_hotspot.addEventListener(MouseEvent.MOUSE_OVER, startChickenMotion);
chicken_hotspot.addEventListener(MouseEvent.MOUSE_OVER, StopMusic);
chicken_hotspot.addEventListener(MouseEvent.MOUSE_OVER, chickenOn);
chicken_hotspot.addEventListener(MouseEvent.MOUSE_OUT, stopChickenMotion);
chicken_hotspot.addEventListener(MouseEvent.MOUSE_OUT, chickenOff);
chicken_hotspot.addEventListener(MouseEvent.MOUSE_OUT, StartMusic);
function startChickenMotion(event:MouseEvent):void {
gotoAndPlay(”chicken2″);
}
function gotoNews(Event:MouseEvent):void {
gotoAndStop(”news0″);
}
function StopMusic(Event:MouseEvent):void {
mtrans.volume = 0;
channel1.soundTransform = mtrans;
}
function chickenOn(Event:MouseEvent):void {
channel2 = chicken.play();
}
function stopChickenMotion(Event:MouseEvent):void {
gotoAndStop(”chicken1″);
}
function chickenOff(Event:MouseEvent):void {
channel2.stop();
}
function StartMusic(Event:MouseEvent):void {
mtrans.volume = 1.0;
channel1.soundTransform = mtrans;
}
Robert
September 23rd, 2009 at 7:51 am
Actually, i found the problem. FINALLY!
Bruno Morello
October 1st, 2009 at 7:39 am
Hi guys,
I’m using CS4 with AS3 and have a little problem with my rewind and forward buttons. For the play and stop buttons it works fine with this script:
playButton.addEventListener (MouseEvent.CLICK, playButtonClick);
function playButtonClick (e:MouseEvent):void
{
play();
}
But then I tried this for the forward button:
forwardButton.addEventListener(MouseEvent.CLICK, forwardButtonClick);
function forwardButtonClick (e:MouseEvent):void
{
this.gotoAndPlay(this.currentframe + 50);
}
I get error messages.
All I need is to rewind and forward the movie about 50 frames and keep playing without stopping.
Any help would be appreciated,
thanks
Azraai
October 1st, 2009 at 6:53 pm
Hi,
Does anyone here know how to create form to send to an email address on CS3 using AS3.0?
Liesl
October 4th, 2009 at 10:19 am
I am a beginner and need a step by step instruction to convert images to button and then use these buttons to link to an url while the images are showing one after the other in a fade in fade out movie clip. Each image must link to another url…
Anyone out there who can help me in flash CS4 using actionscript 3?
ArleyM
October 5th, 2009 at 7:15 am
@Nadi Z and @Jean-Francois to make your button NOT open in a new tab add the target of “_self” like so:
navigateToURL(new URLRequest(”page.html”), “_self”);
Liesl
October 6th, 2009 at 1:39 am
Ignore my query, got it right, next problem is that it works in flash but not when input in Dreamweaver?? movie comes up but will not navigate to urls and pages setup.
JustaGuy
October 6th, 2009 at 12:36 pm
@ Bruno: I think it’s this._currentframe
diana
October 11th, 2009 at 6:54 pm
i’m new to flash. i want to know, is it possible to create a mulitple link from a single button?i’m trying to create a quiz using flash. what i plan to do is, whenever the user click on the right answer, they will see a “congratulations” frame. from that frame, i want to put the “next” button so it will lead the user to go to the next questions in the next frames. so is it possible to do that? that the button can go to multiple frames?
Godbar
October 16th, 2009 at 12:43 am
Hi Vlad,
This is the closest I have got to getting my button to launch my flash player. I was trying to use your geturl command but it just loads en empty window.
What I’m trying to do is emulate a function that I currently have applied to html buttons on my web page. My buttons have the simple ahref of javascript:Play(’120′,’arabian_breaks_v1_demo_mix.mp3′)
and this calls up some js which launches my flash player.
When I try to use that same link ref on a button in a flash movie it fails because I’m obviously missing something.
So how do I word the code so that i calls up my flash player in the same way that a text link or button would?
Sorry for my ignorance.
Cheers
Godbar
Sandra
October 19th, 2009 at 6:26 pm
I’m new at ActionScript 3.0. and though I see a lot of information about a link to a URL with the click of a button, I’ve got an Introduction movie that I want to redirect to another URL when it is done playing. Any suggestions?
Sandra
October 20th, 2009 at 7:26 am
Never mind. In answer to my own question, I got it to work with this:
var url:String = “http://www.site”;
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, ‘_blank’);
} catch (e:Error) {
trace(”Error occurred!”);
}
I also had to add another action (a stop action) so that the movie wouldn’t keep looping, which would have the URL keep reopening every time it looped.
Adam
October 20th, 2009 at 1:34 pm
Flash is an abortion. Have you seen the terrible things Adobe has done to the UI in CS4? I can’t see how they make an amazing app like After Effects, and then the worst app I have ever used, as is Flash.
Please, HTML 5, put a stop to this scourge!
Sandra
October 21st, 2009 at 8:15 am
I can remember the good old days when things were simpler.
As for my, “never mind,” I take it back. I thought I had it working, but now I can’t get the URL to open in the same browser window. I thought it would be to simply replace the navigateToURL(request, ‘_blank’); with navigateToURL(request, ‘_self’); but it’s not working. Even the simple links within my flash movie open in a different browser window despite my indicating that they should open in _self.
Anyone have any ideas?
Jen deHaan
October 21st, 2009 at 9:38 am
Hi Sandra,
Have you followed the steps from this post for controlling the target window? http://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/
Sandra
October 22nd, 2009 at 12:23 pm
Thanks Jen,
I just looked it over.
The thing is, I’ve got an Introduction movie that I want to redirect to another URL when it is done playing. So, there is no button, just a key frame at the end of my timeline.
And, I made the other links by going to properties, under options, where you can just type in the URL and target it.
In both cases, I indicated _self. But, the links still open in a new browser window.
It’s a mystery.
Tiff J
November 2nd, 2009 at 7:43 am
Hey guys! So I’m not so new to Flash, but this question is blowing my mind! If you could help me asap, I have this portfolio project due today (11/2 @ noon MST). So I have a button on my main time line and can’t get it to work throughout my whole website. I do not have the code on my actions layer, but on the button itself. Is that the problem? Here is the code
stop();
mainbut.addEventListener(MouseEvent.MOUSE_DOWN, mainplay);
function mainplay(event:MouseEvent):void {
gotoAndStop(3);
}
mainbut means my button on all of the frames to bring it back to the part on my time line where I labeled it “main” The button only works for “resume”, which is another label on my time line, frames 20 through 30. Label “main” goes from frames 9 to 19. I need this button to always go back to frame 9 on my timeline. But it only works when I am in my resume section, not from frames 31 to 90. What can I do? When I created different buttons on different layers, CS3 told me there was a duplication error. Even though I renamed all the buttons and their instance names mainbut01, mainbut02, mainbut03 etc.
So that’s all the info to make my problem clear. Anyone know how to make my button work on all frames from 19 to 90?
Thanks so so so so so much!
Tiff J
christine facella
November 8th, 2009 at 10:23 am
I’m trying to create a webpage that has two buttons (arrows) that will navigate the page left and right. Both buttons will have to be used multiple times: If I press the right arrow, the page “pans” to the right and stops . If I press it again, the page continues to pan to the right (and vice versa for the left button).
I have programmed other simple buttons that navigate me between scenes and link me to url’s, and have gone through several tutorials in my quickstartguide, but with this task
I can’t figure where to even start: Should the graphic on the page actually be a movie clip, that “plays” to the right if the right button is pressed? How would I move in reverse?
I don’t think I want to change the x axis of the page/clip, as I want it to be a smooth move. Or is there a way to make the transition smooth?
Can I script a single button for several events?
If anyone can help with anything (an example script would be awesome!) that will get me out of this flash-rut, I’d be super happy.
Thanks,
Christine
marcel
November 11th, 2009 at 5:50 pm
please help m
Kit Umscheid
November 12th, 2009 at 12:51 pm
Thank you for saving me from tearing the rest of my hair out. I’m sure they decided to make coding a simple actionscript like a URL button more complicated for a reason that I will probably come to appreciate as I use it more (I hope), but for now THANK YOU for posting this. : )
Bobby
November 13th, 2009 at 2:08 am
Hi! I have a minor problem with some actionscript-buttons. My button is supposed to be animated ad different animations should start and stop when the mouse is over and when its moves away. I had a code for that, but how do I get it to work in Actionscript 3?
The code is:
on (rollOver)
{
_root.Button.instance1.gotoAndPlay (2);
} on (rollOut)
{
_root.Button.instance1.gotoAndPlay (11);
}
Jayson
November 13th, 2009 at 8:23 am
Hi,
Im just learning flash in school and unfortunately i have the newest cs4 flash while my school computers all have macromedia flash player. Anyways, how can i make a button work that brings you to frame 2. I have tried your code from the first couple of posts, and it gives teh error access of undefined property my_btn. Any help you could give would be very helpful. Thanks in advance,
Jayson
Jayson
November 13th, 2009 at 8:27 am
One other thing it is saying, is that when i select the layer with my button on it and i try to open the actions, it says “current selection cannont have actions applied to it”
Thanks once again,
Jayson
JohnS
November 16th, 2009 at 11:16 am
Hi, thanks for the example. I have 6 buttons, which shows up all at the same time. Depending on which one is clicked, it takes you to either frame 2, frame 3, frame 4, frame 5, frame 6, frame 7 with all buttons shown for each frame. What I would like to do is show the down state for the button I pressed at frame one to show the down state of that button for frame #. Any AC3 code to allow that? BTW, I have all four-states per button. I would just like to show the down state per button for each. Thanks for your help!
Eric
November 19th, 2009 at 6:30 am
I’m trying to set up a “Movieclip _mc” style button and I can’t seem to find a tutorial on how to point this action to an external website.
I used the example above but changed the _btn class to a _mc and it didn’t work.
I’m relatively new to Flash so please be kind. :)
Every article I read is about the _btn class!
Frustrated Eric
Eric
November 19th, 2009 at 7:32 am
I figured out my issue above. I just had the code in the wrong frame.
Jennifer
November 20th, 2009 at 8:48 am
I am a college student trying to work out what needs to be.
I have to create an invisible button, and two other buttons. I know that all buttons are going to be a part of navigation, which will allow the user to navigate to each frame in the pace that they need.
So, I have a few keyframes with their labels. If I want to be able to have the user start from the first frame that is labeled, then move onto the next labeled frame, and then to the next labeled frame, and so, how do I do that for the frame labels?
This is how I think it should go, but not too sure at all.
stop();
function onAll_Below_IntroTextClick(evt:MouseEvent):void }
gotoAndPlay(”All_Below_IntroText”);
}
intro_btn.addEventListener(MouseEvent.CLICK, onAll_Below_IntroTextClick);
Now I want to inform you that my first Label, for my First Frame is titled All_Below_IntroText, my instance button name would be intro_btn. Now…what is going on here, is this correct? Is this wrong? Please help me because I only have another 3 days to complete everything needed for college assignments because of my program being a trial and have only 3 days left to complete a total of 4 or 5 more weeks of assignments.
itzel
November 20th, 2009 at 10:57 am
hello i’m building a website with flash buttons, I had use the code as is posted and everything works fine the only thing is that every time i click a button it opens the page on a new tap. Anyone knows what to do, in order to open the different url in the same tap?
Peter
November 24th, 2009 at 10:06 am
Ok, I’m also totally new to Flash (I’m using CS4, Version 10.0) and Actionscript 3. I have an html page with a link that loads a popup window which includes a simple Flash movie. Some javascript code produces the popup window.
What I’m trying to do is have a button in the Flash app close the popup window. I would think this would be fairly simple, but I can’t get anything to work. Any suggestions?
Thanks
Cruz
November 24th, 2009 at 4:49 pm
so i’ve figured out how to do the whole thing. but let’s say i’m working on an animation. i have my first screen as the ‘play’ button. but once i click play, the animation starts but the play button stays on the screen. anyway to have the play button disappear once it’s pressed?
Jeff
November 27th, 2009 at 9:57 am
I am trying to make a menu function for my game and my code is
stop();
btnPlay.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(2);
}
and i am getting this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Spaceinvadors_fla::MainTimeline/EnterFrame()[Spaceinvadors_fla.MainTimeline::frame2:126]
i dont know what to do can anyone help
Lisa
November 30th, 2009 at 1:43 pm
Maybe I made a dumb assumption that I could create each page of my website as different .fla files and link them (the way it works in Dreamweaver), but after making the buttons and all the files, I can’t figure out how to make them interactive. I feel so stupid! How does this work??!!
My code is:
home_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.lisaruffmanweiss.com/index.html”), “_self”);
}
port_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler2(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://www.lisaruffmanweiss.com/Portfolio.html”), “_self”);
}
resume_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler3(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://www.lisaruffmanweiss.com/Resume.html”), “_self”);
}
contact_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler4(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://www.lisaruffmanweiss.com/Contact.html”), “_self”);
}
After I publish and test the swf file it opens a blank home page no matter which button I click. I’ve been trying to figure this out for months but I get conflicting information and, if any. THIS IS SO FRUSTRATING!!!
Jen deHaan
November 30th, 2009 at 2:44 pm
@Lisa: You’re getting the same link opened, because all of your buttons are targeting the first function. You just need to rename your second through fourth click handlers to point to the respective functions.
For example, this line: port_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
Should be:
port_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler2);
That will point at the function buttonClickHandler2 you have below that line, instead of your first buttonClickHandler.
I hope that helps solve it for you,
Jen.
Michael
December 1st, 2009 at 2:34 am
Hi, sorry if I am repeating what others have written before, but I have the code on one layer (no keyframes etc, layer runs from start to finish of timeline) for two buttons; button 1 makes the movie run from frame 2 and stops on frame 10. button 2 runs from frame 11 to the end (so far only 20 frames).
i am getting the error of “TypeError: Error #1009: Cannot access a property or method of a null object reference.
at site_fla::MainTimeline/frame1()” when i run the movie. button 1 works, takes me to frame 10 then stops. the “close” button (button 2) doens’t work, and i get that error.
my code is as follows:
stop();
photo_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndPlay(2);
}
close_btn1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
gotoAndPlay(11);
}
button1 is “photo_btn” and button2 is “close_btn1″. Could someone please please help me?? It is driving me mad.
Michael
December 1st, 2009 at 5:55 pm
Nvm I got it to work .. I split the code so that the code for “photo_btn” was on frame 1 (start of movie), and code for “close_btn1″ was on frame 10. works!
Lisa
December 2nd, 2009 at 7:19 pm
THANK YOU! THANK YOU!
Jen,
I now feel like I’m a step closer to getting my site up. I’m still having some weird issues, though. I saved all my .fla files as swf and html and have both uploaded to my host site. When I check the index.html file it comes up blank.
And when I look at my portfolio page, it doesn’t play the whole movie; it plays scene 1 and then jumps to my Contact page. I’m sure this is something to do with my code, but I’m still new at this and I can’t figure it out.
Thanks again for your help!!
Federico Echeverria
December 4th, 2009 at 3:49 pm
Hello, i have a problem. i have this
stop();
btn1.addEventListener (MouseEvent.CLICK, onClick);
function onClick( event:MouseEvent):void
{
event.target.gotoAndPlay.(”page1″)
}
btn1.buttonMode = true;
but when i press on my button everything goes ok exept taht if i click on the image on the frame (Page1) it happens the same thing so is there a way to Modify it to just happen on the first frame? idk if you can understand what im saying. please i really need help im making a webpage. Thanks
general
December 6th, 2009 at 7:10 pm
stop()
btn1.addEventListener(MouseEvent.CLICK,Play1);
function play1(event:MouseEvent):void {
gotoAndStop(”leaves”);
}
btn2.addEventListener(MouseEvent.Click,Pla1y2);
function play2(event:MouseEvent):void {
gotoAndStop(”MODELING”);
}
btn3.addEventListener(MouseEvent.Click,Play3);
function play3(event:MouseEvent):void {
gotoAndStop(”child”);
}
addEventListener(MouseEvent.Click,Play4);
function play4(event:MouseEvent):void {
gotoAndStop(”tats”);
}
general
December 6th, 2009 at 7:13 pm
well im trying to make a photo gallery in flash becuase i cant get the right code in shadowbox either. well i made thumnails and when u clic on it the jpg shows i cant get it to work someoner help
stop()
btn1.addEventListener(MouseEvent.CLICK,Play1);
function play1(event:MouseEvent):void {
gotoAndStop(”leaves”);
}
btn2.addEventListener(MouseEvent.Click,Pla1y2);
function play2(event:MouseEvent):void {
gotoAndStop(”MODELING”);
}
btn3.addEventListener(MouseEvent.Click,Play3);
function play3(event:MouseEvent):void {
gotoAndStop(”child”);
}
addEventListener(MouseEvent.Click,Play4);
function play4(event:MouseEvent):void {
gotoAndStop(”tats”);
}
ria
December 7th, 2009 at 6:56 am
hi, does anyone know how to create a button in flash that enables the user to change the value of a number?? thank you
sam
December 7th, 2009 at 7:25 am
Hi I’m taking a class on flash but I got stuck making a start button! I have no idea why I’m having such a hard time because normally I think it’s really easy but for some reason the I keep getting a message that says “Current selection cannot have actions applied to it”
I converted the image into a symbol and it is a button because when I put the page in the brower in dreamweaver, it makes the little hand when I go over the flash image.
Please help.
Sam
Lisa
December 7th, 2009 at 2:09 pm
I still have a few problems that I can’t figure out. Is there any way you can look at my files or if I could send them to you? I tried to post the code but that section of my post didn’t seem to show up.
I’m getting a bit desperate. Nobody is as willing to help as you seem to be (and your advice is excellent). I feel like I’m completely stuck.
Please help!
Lisa
frank
December 7th, 2009 at 8:11 pm
hi, i’m new in actionscript and i have this problem. i am creating a web project. on my scene 1, i have this movie clip called classes located on frame 5 and on frame 15 i have this movie called math. i try to create a button on the classes movie clip to goAndStop on frame 15 and play the movie clip called math.
Jen deHaan
December 8th, 2009 at 10:25 am
@Lisa: If you can link your FLA file I’ll download it and try to take a look and see what’s up. Also if you can post a link to your site where it’s showing up blank that might help figure out what’s going on. It’s likely there’s an issue with the embed code / SWF it’s targeting.
Jen deHaan
December 8th, 2009 at 10:26 am
@Sam: For AS3, you need to put your code on a frame instead (you have the button selected instead of a frame). Make sure a frame is selected before putting code in the Actions panel.
Lisa
December 8th, 2009 at 10:54 am
Jen,
Thanks so much. You are a blessing!
My files are at:
http://us.1.p6.webhosting.yahoo.com/filemanager?directory=&dispopts=+
I’ve uploaded my swf, fla and html files there, as well as some image files and anything else that might need linking. My website is at: htp://www.lisaruffmanweiss.com.
Thanks again!
Lisa
Oli
December 11th, 2009 at 1:45 pm
Hi Jen, just wondering if you could help me out here. All three of my buttons go to frame 2, where my game is. Here is my code:
stop();
play_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(2);
}
moregames_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler2(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.kongregate.com/accounts/EpilogueGames”));
}
howtoplay_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler3(event:MouseEvent):void {
gotoAndStop(3);
}
See if you can spot anything odd.
Cheers,
~Oli
Oli
December 11th, 2009 at 1:53 pm
Sorry, I forgot to mention that the buttons are supposed to go to the actual game, the instructions frame, and my game Studios website. They all still go to my gameplay frame.
Oli
December 12th, 2009 at 2:03 am
Never mind, i managed to fix it. Just changed the code to:
stop();
play_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(2);
}
moregames_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.kongregate.com/accounts/EpilogueGames”));
}
howtoplay_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler3);
function mouseDownHandler3(event:MouseEvent):void {
gotoAndStop(3);
}
Remaning the mouseDownHandlers with numbers after.
Carlos Defilippi
December 13th, 2009 at 1:06 pm
Hey, Everyone….
I am a new web site 15 pages to flash cs4 and as3. I’ve been building a flash website for the past week or so and so far things are going ok. However, I have a navigation menu with buttons I’ve as’d to navigate to a new pages Currently when the buttons are clicked do not open my pages or navigate the pages
thanks
Jan
December 13th, 2009 at 11:13 pm
Hi,
Maybe you guys can help me with this.
I need to create a flash activity worksheet for little children.
Basically, the children has to click on the wrong answer and press on the delete key button (key code : 46) on the keyboard to delete the wrong answer. When the wrong answer is being deleted, a pop up movieclip will appear saying something like, “Well done!”
Every question has two answers, one correct and the other wrong. I intended to make each answer into buttons but then flash somehow does not let me input actions into the buttons. I have no idea why.
If you guys do have any other possible solutions for me to do this, please help me here.
Lisa
December 14th, 2009 at 3:59 pm
Hi Jen,
Have you had any luck in finding out what I did wrong?
Lisa
Margaret
December 15th, 2009 at 6:00 am
http://www.twincling.org/node/742
bruno Morello
December 16th, 2009 at 6:00 pm
Hi everybody,
Need a little help on loading external swf movies. I have a main menu page with 4 menus and when I click on a menu it loads an external movie and plays right on top of my menu page.
Is there a way to hide the main menu contents while the external movie plays ?
Any help would be great.
Bruno
Jen deHaan
December 17th, 2009 at 2:27 pm
@Lisa: Sorry, I forgot to post that I’m not able to grab the file(s) from the Yahoo site - when I log in it says that I don’t have permission to see the files. Could you send it to me at kidderton ( at) gmail.com?
Regarding the home page, it looks like the home.swf file isn’t in the directory the home page is pointing at. You will either need to update the links in the index.html to point at home.swf, or move home.swf into the root directory of your site.
Hope that helps! I’ll watch for the file.
Thanks,
Jen.
Riddhi
December 29th, 2009 at 11:46 pm
Hi!! trying to brushup my flash..but having a lot of problem with as3. please help. i followed your how to make a button and link it to a particular frame; say from 1 to 2. it worked initially.
Now i have added 4 button to the frame 2 which are also moveclip buttons like my initial button. I added the script in the same action layer as the earlier button but on frame 2, as my initial script was on frame 1. now the error i get is;
1046: Type was not found or was not a compile-time constant: product_ball.
Riddhi
December 29th, 2009 at 11:49 pm
stop();
event_ball.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
gotoAndStop(3);
}
product_ball.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler3);
function mouseDownHandler3(event:MouseEvent):void {
gotoAndStop(4);
}
graphic_ball.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler4);
function mouseDownHandler4(event:MouseEvent):void {
gotoAndStop(5);
}
Exhibition_ball.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler5);
function mouseDownHandler5(event:MouseEvent):void {
gotoAndStop(6);
}
Riddhi
December 29th, 2009 at 11:50 pm
that was the script on frame 2
and
this is on frame 1
stop();
monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(2);
}
Riddhi
December 30th, 2009 at 12:37 am
hi!! got it..just changed the instance name to something else and not same as the button name.
hope it is correct. works for me.
thanks
Martin
January 2nd, 2010 at 11:12 am
some one help have no idea on how to make a button work. Just want 2 buttons forward & rewind, this is just to skip to the next keyframe or rewind to the previous, this is for a slideshow
thanks in advance
Lisa
January 3rd, 2010 at 10:45 am
Hi Jen,
Happy New Year!! Have you had any luck figuring out why my Home page is blank and my Portfolio page jumps to my Contact page after scene 1?
thanks, lisa
Jen deHaan
January 4th, 2010 at 6:15 pm
Hi Lisa,
Sorry, was on holidays :) I took a look at the Portfolio page and don’t see any obvious reason why it’s progressing to the Contacts page. I’ll take a further look tomorrow - just wanted to let you know I’m taking a look. I’m gathering that at the end of the scene would be some URLRequest to the Contacts page, but I’m not seeing anything like that. I’d double check that you have the latest version of the Portfolio.swf up there, perhaps an older version is up? As for the home page, I’m still not seeing the home.swf up at the address its pointing to, which I’d gather to be the problem there.
francois
January 5th, 2010 at 6:36 am
I love you - Thanks
I can sent the banner now..
Jen deHaan
January 5th, 2010 at 10:53 am
@Lisa: Try re-uploading the Portfolio.swf. I viewed the code in the SWF on your site and it seems different than the FLA you sent (there are some navigateToURLs outside of functions - I think it may be taking the last one, Contact, and jumping to it). I don’t see this in your FLA file, so re-publishing/uploading it may do the trick.
Lisa
January 6th, 2010 at 6:22 am
Hi Jen,
Thanks so much for your help. I did what you said, and believe it or not, all the files did exactly the same thing. The home page still comes up blank and the portfolio page still jumps to the contact page. This is quite the puzzle!
Lisa
mandy
January 12th, 2010 at 3:22 pm
Okay well i’m making a flash movie with a start button, but everything i enter turns out in an error my last attempt was almost right but flash said that } was unexpected and when i deleted it they said that it was an unexpected ending and that it needed this } so i’m al lost. the video i made just starts with the button but it automaticly plays the vid instead of waiting for instructions or a simple click with my mouse.
Monica
January 13th, 2010 at 5:41 pm
Thank you so much Jen! This really helped me a lot.
Monica
January 13th, 2010 at 5:44 pm
I have an animation that plays when the button is clicked then goes to a url. I used MouseEvent:MOUSE_DOWN for the animation and then MouseEvent:CLICK to go to the url. It works, but the only problem is that no one is going to hold down the mouse long enough for my animation to finish (even though it is only a few seconds) before lifting the mouse button and it jumping to the url. It gets about half way through and then it has already loaded up the page. Any suggestions on how to remedy this?
Thanks again for your great tutorial!
Brian
January 14th, 2010 at 7:14 am
Great site, Jen. Very informative. I wonder if you can help me with a website I’ve built in CS4. The site consists of about 100 “pages”, each an individual .swf file, which load in a single flash movie embedded in an html page. Navigation is achieved with buttons that use a loadMovie function. I have no problem loading specific files, so forward navigation is working. But I need a way to load the PREVIOUS file for backward navigation. Is it possible using actionscript to tell flash to load the previous .swf? Can the flash player store user history? (BTW, I am using Actionscript 2.)
I’ve scoured the internet for solutions to this and haven’t found a single mention of true backward navigation with flash. If you can help me solve this problem, I’ll be MOST grateful.
Brian
newbie
January 14th, 2010 at 9:43 am
Hi i am a newbie in flash, i need your help. I just want to link from a page to another page in flash. But I am stuck. Can you help me with the codings and send it to my mail.
Deeply appreciated.
Marshall
January 18th, 2010 at 8:39 am
Hello,
I am working on a video project and am having some serious issues and it is making me almost miss my deadline. the problems that i am having are with code.
My project is an interactive video for the web. There are two films the first film is quite dull and not very interesting when it plays there is also a button that you can click to go to the next film which is more interesting. the trick is when you click the button you can only watch the second film for the same ammount of time as you watched the first film. there are also credits that should run when the second movie is finished but that could be after 3 seconds or a minute so i need it to be able to adjust when it runs
I have no idea what i should do to make this work i need help with making the button work. i also need help with having the second video load while the first one is playing also i need it to be able to measure the length of the first film and play the second film for that exact time. and finally the credits will be difficult to work out
if there is anyone who thinks they can help please reply it would help save me from ruining this project
many thanks
Len
January 22nd, 2010 at 7:30 am
OK,,Im trying my first foray into buttons in flash and I failed on step 1. I built a test using CS4. One slide with a simple image defined as a button. Second scene is just a simple text box for now. I have the script assigned as
stop();button_1.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);function mouseDownHandler(event:MouseEvent):void {gotoAndStop(1, “Scene 3″);}
Yes, the 2nd scene is Scene 3, and the button is named button_1
When I TEST MOVIE, i get a compiler error–1120: access of undefined property button_1.
HELP???
Steve
January 23rd, 2010 at 12:58 pm
Hi, another mindlessly stupid Flash newbie here. Ok, I’ve constructed a simple picture viewer, with each picture on its own keyframe. I just need my forward button to navigate to the next keyframe, and the back button to go to the previous keyframe. How the bloody hell do I do this, c’mon, there’s gotta be SOME way to do this! what import command do I use at the beginning, and what event listener do I use???!!! And one more thing… why the bloody hell couldn’t they make this goddam program more like Director, with easy to find prefabricated action for just about everything you would need to do, with the OPTION to write a script if you want???!!!??? Someone, please help me out here…
Steve
January 23rd, 2010 at 1:06 pm
Ok, (deep breath) here’s the code I’m using so far, with “goforth” being the forward button:
stop();
import flash.events.MouseEvent
goforth.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
}
Now I think to advance to the next keyframe, I do something like:
gotoAndStop(next (Keyframe))
How do I fit that into the above code to make it actually work?
Steve
January 23rd, 2010 at 3:02 pm
Please disregard previous panic attack; problem solved! :D
stop();
goback.addEventListener(MouseEvent.CLICK,backward);
goforth.addEventListener(MouseEvent.CLICK,forward);
function forward(event:MouseEvent){
if(this.currentFrame == this.totalFrames){
gotoAndStop(1);
}
else{
nextFrame();
}
}
function backward(event:MouseEvent){
if(this.currentFrame == 1){
gotoAndStop(this.totalFrames);
}
else{
prevFrame();
}
}
Darko91
January 24th, 2010 at 9:35 am
thanks people you helped me much here just ceap the good work :))
you are the best !!!!!
David
January 25th, 2010 at 10:58 am
Hello everyone. I am using Flash Cs4. I have a problem were I want a button that is clicked to take the user to a new, different URL, and have that window open up minimized, without closing the current window they were in. In other words, I want a new webpage to open upon clicking this button, and at the same time, allow them to just click the original windows panel to go back, thus getting rid of the back button feature. Is this possible?
Kleinbaas
February 1st, 2010 at 4:28 am
FIXED: Multiple Buttons/Links
For those of you trying this with multiple buttons, you need to make sure that the “MyHandler” functions dont have the same names.
Your code for two buttons with links should look like this:
button_1_instance.addEventListener(MouseEvent.CLICK,button_1_ClickHandler);
function button_1_ClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”/button-1-page.html”), “_self”);
}
button_2_instance.addEventListener(MouseEvent.CLICK,button_1_ClickHandler);
function button_2_ClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”/button-2-page.html”), “_self”);
}
The button graphics must be converted to symbols and must have instance names assigned to them that match (that is button_1_instance and button_2_instance.
See http://www.adobe.com/designcenter/flash/articles/flacs3it_firstflash_pt2_06.html
and
http://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/
and
http://www.brightvisions.co.uk
Hope that helps! :-)
Ryad
February 1st, 2010 at 12:42 pm
Hi guys, am very new to flash and as3. am building a basic website with four buttons ( Home, About, History, Contact Us), a text holder (myText_txt) and a movieclip to hold pics (bigPic_mc). so my question is how do i load external .txt files (home.txt, about.txt…) when each one of the buttons are pressed while also getting the bigPic_mc to display four different pics (pic1,..pic4) ???? am really stuck with this and have tried a number of things.
Levi
February 2nd, 2010 at 12:17 pm
I am having trouble making a button on frame 1 that goes to frame 2 and one on frame 2 go to frame 3. I have tried this code “stop();
start.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(2);
}
run.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
gotoAndStop(3);
}”
But I still get the error message “TypeError: Error #1009: Cannot access a property or method of a null object reference.
at windows_fla::MainTimeline/windows_fla::frame1()
“
Lisa
February 2nd, 2010 at 12:26 pm
Hi Jen!
My Home page is finally fixed! (I had the html pointing to my local files instead of the files I had uploaded.) Thanks again for your help! As for my Portfolio page, I decided to consolidate it into one scene, hoping it would solve that jump-to-the-Contacts-page that it does. Still no luck. I looked over the html and saw no sign of it jumping there. It doesn’t do this in the swf. THIS IS DRIVING ME CRAZY!!! My code looks like this:
home_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”http://www.lisaruffmanweiss.com/index.html”), “_self”);
}
port_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler2);
function buttonClickHandler2(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://www.lisaruffmanweiss.com/Portfolio.html”), “_self”);
}
resume_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler3);
function buttonClickHandler3(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://www.lisaruffmanweiss.com/Resume.html”), “_self”);
}
contact_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler4);
function buttonClickHandler4(event:MouseEvent):void {
navigateToURL(new URLRequest (”http://www.lisaruffmanweiss.com/Contact.html”), “_self”);
}
Lisa
February 3rd, 2010 at 12:05 pm
Sorry, I take that back. It’s finally fixed!!! Removing the scenes solved the problem. Thanks so much for your help!
Red
February 4th, 2010 at 12:52 pm
Re Levi, above. I am having same problem. Had something that worked in AS2 but not now in AS3. I had an app that had buttons moving forwards or backwards to frames. Now in AS3 I get error 1009. Button on first frame works but no others do.
EvenA
February 5th, 2010 at 2:54 pm
i have a (maybe) stupid question about buttons,
how can i disable a button from another button inside of a movieclip with as3?
=(