Solved

making a flash button go to a url

Posted on 2008-10-10
12
467 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

758 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

19 Experts available now in Live!

Get 1:1 Help Now