Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

making a flash button go to a url

Posted on 2008-10-10
12
Medium Priority
?
476 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 1500 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 1500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

604 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