Solved

making a flash button go to a url

Posted on 2008-10-10
12
468 Views
Last Modified: 2008-10-10
I have a  button bt_go and a movie instance bt_go_now. I want to send the user to a URL by a variable (linktopage), when the button is pressed. linktopage is set elsewhere...

How do I do this?


0
Comment
Question by:Wanderinglazyeye
  • 7
  • 5
12 Comments
 
LVL 4

Expert Comment

by:codezp
ID: 22688987
just add this to Actions

var js:URLRequest=new URLRequest();
js.url="javascript:window.open('image.html','popper1','scrollbars=1','width=400,height=360');newWindow.focus(); void(0);";

bt_go.addEventListener(MouseEvent.CLICK,openPopUp);

function openPopUp(evt:MouseEvent):void
{
      navigateToURL(js,'_self');
}
0
 

Author Comment

by:Wanderinglazyeye
ID: 22689754
Let me add that I am using Macromedia flash authoring tool. I added this to the movie clip (above) and got these errors:

**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 1: The class or interface 'URLRequest' could not be loaded.
     var js:URLRequest=new URLRequest();

**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 2: Statement must appear within on/onClipEvent handler
     js.url="javascript:window.open('image.html','popper1','scrollbars=1','width=400,height=360');newWindow.focus(); void(0);";

**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 4: Statement must appear within on/onClipEvent handler
     bt_go.addEventListener(MouseEvent.CLICK,openPopUp);

**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 6: The class or interface 'MouseEvent' could not be loaded.
     function openPopUp(evt:MouseEvent):void

Total ActionScript Errors: 4        Reported Errors: 4

0
 
LVL 4

Accepted Solution

by:
codezp earned 500 total points
ID: 22689783
In flash select the button you want to make go to url, then go to Window > Actions and insert that action, note that your button has to be tracked as button
0
 

Author Comment

by:Wanderinglazyeye
ID: 22690034
I went to Window->Actions
Action script opened up
I pasted the above code in
Got the error after running

What am I doing wrong here

Button is being tracked as a button
0
 
LVL 4

Assisted Solution

by:codezp
codezp earned 500 total points
ID: 22690148
make sure that button and actionscript is on same layer

for example if you have layer called BUTTON click on it and then go to Actions and paste the code

so just click on layer where the button is located and make sure button has same name,

which error did you get?
0
 

Author Comment

by:Wanderinglazyeye
ID: 22690262
I can't get to the button itself from the layers. I can get to the movie clip.

 I have to go to the library, find the object and edit it. And when I do, it says "current selection cannot have actions applied to it". The layer is not locked.

How do I add an action script to that button?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Wanderinglazyeye
ID: 22690272
The button layer says up, down over hit but I can't add action script...
0
 
LVL 4

Assisted Solution

by:codezp
codezp earned 500 total points
ID: 22690278
button has to be on a layer right?

do you have it placed somewhere on the stage?

if not then I am assuming the error you get is something to that extent, since button has to be part of the flash.
0
 
LVL 4

Expert Comment

by:codezp
ID: 22690287
The button layer says up, down over hit but I can't add action script...

OK you dont need to be there, do it on main screen not inside and make sure your button is modified
0
 

Author Comment

by:Wanderinglazyeye
ID: 22690337
Ok, the stage button property says "Instance of: bt_go_now"
But its a movie clip, not a button.
It has no instance name.
This is where I inserted the A script and got the errors. Am I in the right place?
0
 

Author Comment

by:Wanderinglazyeye
ID: 22690364
**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 1: The class or interface 'URLRequest' could not be loaded.
     var js:URLRequest=new URLRequest();

**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 2: Statement must appear within on/onClipEvent handler
     js.url="javascript:window.open('image.html','popper1','scrollbars=1','width=400,height=360');newWindow.focus(); void(0);";

**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 4: Statement must appear within on/onClipEvent handler
     bt_go.addEventListener(MouseEvent.CLICK,openPopUp);

**Error** Symbol=texts, layer=bt_go_now, frame=1:Line 6: The class or interface 'MouseEvent' could not be loaded.
     function openPopUp(evt:MouseEvent):void

Total ActionScript Errors: 4        Reported Errors: 4

0
 

Author Comment

by:Wanderinglazyeye
ID: 22692198
I got it. I just dragged the button on to the the stage and added

on (release) {
getURL("http://www.****.com", "_blank");
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I convert a CS4 FLA file to CS6? 1 864
free flash maker 5 206
Flash builder 4.13 list scroller does not work 1 37
File conversion question 5 85
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now