Solved

making a flash button go to a url

Posted on 2008-10-10
12
469 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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
 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adobe Flash Player not supported on my Tablet 7 736
Adobe Flash Free Transform Tool 2 140
Flash content not working in IE 11 on Windows 8.1 3 168
Adobe Indesign CS6 4 121
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

831 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