FORUMS: list search recent posts

What am I doing wrong?

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nicole Glover
What am I doing wrong?
on Dec 20, 2010 at 4:04:21 pm

I am new to flash and have checked out a lot of tutorials. I thought I had the right code, but it will not work correctly and after trying many different things I cannot get my button to work correctly.

I have created a movie in flash and added the code below to change it into a button, my goal is, when flash button is clicked a new page opens, right now the page opens in a new window without being clicked:

box.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(""));

trace("I'm clicked");

I don't know if putting the code into an HTMl document can be causing any issues as well. I just want this to work correctly, if there is a better way of doing this please let me know.

Thank you so much for your help

Return to posts index

demetri tashie
Re: What am I doing wrong?
on Dec 20, 2010 at 5:09:34 pm

the code is actually just fine. just make sure you follow these, or similar, steps:

1- create your flash file.
2- create your movieclip to act as a button
3- turn this movieclip into a movieclip symbol, by selecting it and choosing Modify --> Convert to Symbol
4- give the symbol the instance name 'box' in the Properties Panel
5- place the code in the Actions Panel.
6- export your swf. try it out. it works.
7- create your web page/html document
8- embed the swf into the html page ( via swfobject 2, or if you use Dreamweaver, by choosing Insert-->Media-->Swf
9- make sure the correct javascript files are with the webpage ( swfobject.js , etc, depending on how you placed the swf into your html page)
10 - test your html page on your server. your swf should show up, and clicking the button should open the new page.

note- the actionscript code does NOT go into the html code, it stays in the .fla file only.

i hope that clears that up. if not, you can look at these files and inspect how they all work and relate to each other. feel free to ask more questions

Return to posts index

Nicole Glover
Re: What am I doing wrong?
on Dec 20, 2010 at 6:14:08 pm

Forgive me, but I must be doing the wrong thing or not asking the right question.

I have many different layers in the timeline, not all of them have the code(when I add code I get a ton of new error messages) so I have not added any code, could this be part of the issue?

Is the flash code correct if I want to click on the button and have a new html page open up in the same screen? so far, you cannot click on it, it will just open up a new window and continue to do so until you close the page with the swf file.

Thank you for your help

Return to posts index

demetri tashie
Re: What am I doing wrong?
on Dec 20, 2010 at 6:44:07 pm

that code is correct and will work for a click on a movieclip symbol with the instance name 'box'

ideally we try to have a 1 frame maintimeline with the code on a layer on that 1 frame.

if you must have a mult-framed main timeline, then all the code should still ideally be kept on the first frame.

in the case that you can't do that, then the code has to be placed on the frame where the 'box' movieclip is, otherwise you will get error messages about null references.

if this doesn't help, you will need to explain carefully how you have your file(s) set up in relation to the steps i gave in the first answer

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved