View Full Version : Simple Button Help
jmbones
04-10-2007, 02:50 PM
Hi Folks - New user here
Just trying to create a simple button from an image I have in my Flash 8 libary. I have converted the image to a symbol.
I want the button to load a URL in a new window when pressed, that is all.
When I try to publish, I get syntax errors. Here is my code for one button:
BBB_btn.onRelease = function(){
getURL("http://www.google.com", window="_blank");
};
What am I missing?
CyanBlue
04-10-2007, 03:17 PM
Howdy and Welcome... :)
That getURL() line should be written without the 'window' string like this... and the symbol should be either a button or a movieClip...
getURL("http://www.google.com", "_blank");
jmbones
04-10-2007, 03:22 PM
Thanks, I still get syntax errors when trying to publish. Is there any other code that needs to be with this?
**Error** Symbol=page, layer=Layer 2, frame=1:Line 1: Statement must appear within on handler
target_btn.onRelease = function(){
Total ActionScript Errors: 1 Reported Errors: 1
target_btn.onRelease = function(){
getURL("http://google.com", "_blank");
};
Howdy and Welcome... :)
That getURL() line should be written without the 'window' string like this... and the symbol should be either a button or a movieClip...
getURL("http://www.google.com", "_blank");
CyanBlue
04-10-2007, 03:44 PM
I think you are adding that code on top of the button itself...
Make sure that you are adding it to the frame not on the button...
jmbones
04-10-2007, 03:49 PM
That was the problem, thanks. Now I have two different buttons on the same page, but only the first button works. Do I need to have different code for two?
Here's what I have:
BBB_btn.onRelease = function(){
getURL("http://www.google.com", "_blank");
};
tgt_btn.onRelease = function(){
getURL("http://www.yahoo.com", "_blank");
};
I think you are adding that code on top of the button itself...
Make sure that you are adding it to the frame not on the button...
CyanBlue
04-10-2007, 03:56 PM
The code seems to be okay... Does your 'other' button have 'tgt_btn' as an instance name???
jmbones
04-10-2007, 04:40 PM
The code seems to be okay... Does your 'other' button have 'tgt_btn' as an instance name???
Yes..
Edit: apparently my button was messed up. I reimported the image and recreated it, works now. Thanks!
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.