Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action Script error

Status
Not open for further replies.

qws

MIS
Jun 23, 2005
26
AU
Hello,

I think I have a problem with my action script in Flash 8 when I try and add a URL to a button.

I have tried a few different tutorials to teach me how to add a URL to a button, and the latest one I am using is:
Under section 7 it shows me how to add a URL. Section 8 however shows another pop up box where I should be adding URL details. I do not get the box shown in section 8, only some code in the action script box which is:

getURL();

I tried typing the code in manually as:

getURL(" "_blank");

but then I receive the following error:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler
getURL(" "_blank");

Total ActionScript Errors: 1 Reported Errors: 1

Does anyone know why this may be happening?
 
If it's the premade Button Component use:
Code:
on(click){
    getURL("[URL unfurl="true"]http://www.website.com","_blank");[/URL]
}

If it is a button that you created:

Code:
on(release){
    getURL("[URL unfurl="true"]http://www.website.com","_blank");[/URL]
}

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Hi pixl8r. Thanks for answering that so quickly. It was a button I made myself, but while I no longer get an error message when I use this new code you have given me, nothing happens when I click on the button.
 
Did you add the code to the button or to the timeline? Easiest way to tell is to click on the button with the actionscript window open. You will see the code if you attached it to the button (which is where it needs to be to work). Otherwise you will not see it. You can code a button on the timeline as well but the syntax is different.

Code:
//the button must have an instance name for this to work
buttonInstanceName.onRelease = function(){
    getURL("[URL unfurl="true"]http://www.website.com","_blank");[/URL]
}


Wow JT that almost looked like you knew what you were doing!
 
hi pixl8r. This still doesn't work for me. I didn't have an instance name on the button (which I have added now), but the button had been selected when the action script had been added. I tried using your adjusted action script as well with the instance name of "press" added.

So I had it displayed as:

Code:
press.onRelease = function(){
    getURL("[URL unfurl="true"]http://www.website.com","_blank");[/URL]
}

I did just notice thought that the frame does not have the little "a" that usually sits on a frame when there is action script in place. Could this be part of the problem?
 
i had/have a similar problem...
For me it was that i had a popup blocker and even though the button was working
getURL("
i didn't notice that the url page was opening all the time ...just getting blocked.

so.. is the next question how to by pass popup blockers...?

maybe something, maybe nothing
good luck

/Ramsey

-------------------------------------
Laughing out loud every day,
keeps the doctor away....
Question is ...What's so funny?
-------------------------------------
 
Hi RamseydaMoor. Unfortunately this isn't the problem as I have blockups allowed. Thanks though...
 
Can you post your .fla? I'm sure it's just a simple problem with where you have located your AS.

Wow JT that almost looked like you knew what you were doing!
 
Yep it's simple.

2 things. 1) press is a restricted name... call it something like "myButton" instead. 2) The code you are trying to use has to be on the main timeline (as opposed to on the button where you have it). Click off of the button and enter the code in the actionscript panel. (you should see the "a") over the keyframe when you are done.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top