Solved

making a flash button go to a url

Posted on 2008-10-10
12
473 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
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.

726 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