ActionScript 3 Tutorial – What Happened to getURL?
Flash Tutorial April 17th, 2008For those of you who are new to ActionScript 3, you might be wondering what happened to the getURL() function. It used to be so easy to create outbound links in Flash with just a single line of code inside the onRelease event for your buttons. Which brings up another question...what happened to the onRelease event?
If you wanted to create a link to another website in ActionScript 2, here's what it would have looked like:
Ah, if only it were still so simple!
First of all, the way we handle events in AS3 is a little different. We're still attaching functions to event handlers, but we're doing it in a little bit of a different fashion. First we have to explicitly add an event listener to our button, and within that event listener, we tell Flash which function we want to respond to that event. Then we create that function separately. Like so:

Notice that inside the parentheses for the "addEventListener" function, the first thing we specify is the type of event we're listening for. In this case, we're listening for the CLICK event, which is defined in the MouseEvent class. The second thing we've specified for our event listener is the name of the function we want to run when our event listener is triggered. You can give this function any name you please, as long as the spelling and capitalization matches up with the actual name that you give the function. In this example, I've called the function onMouseClick. It's inside this onMouseClick function that we want to insert our code for navigating to an external URL.
Well, for those of you who are used to using getURL to take you to another website, it's time to introduce you to a new little method called navigateToURL. Sure, it's a little more verbose, but it seems to get the point across better.
But before you go out there and starting replacing all your getURL methods with navigateToURL, let me warn you about something--it won't work. At least not the way you're used to. When you call on the navigateToURL(), you might be tempted to type a URL inside the parentheses. But the navigateToURL method isn't looking for a URL string. Instead, it's looking for a URLRequest object. The URLRequest class is what allows us to communicate with other websites and external files. So, here's what your final code would look like:

In line 5, we're creating a new URLRequest object, in which we're storing the String containing our URL. We stored this URLRequest object in a variable named request. Then, in line 6, we call on the navigateToURL method, which points to the request object we just created.
Note: The "_blank" is optional. Include this only if you want the link to open in a new browser window.
I know this has been a long explanation for such a simple concept, but I've seen a lot of very brief explanations out there, and I wanted to make sure you understood not only what you were typing but also why you were typing it.



April 20th, 2008 at 8:22 am
Hello. Thanks for the tutorial but why did you put the script into an image file instead of giving us the plain text to copy and paste?
April 20th, 2008 at 2:06 pm
Actually, I DO have a good reason for it. If you type the code in yourself, it will stick in your memory better than if you just copy and paste it. Basically, I’m forcing you to practice! Does that make sense?
~Craig
April 24th, 2008 at 6:01 pm
What if you just want it to go to a url when the movie is over?
April 25th, 2008 at 5:04 am
Very Interesting!!!
April 25th, 2008 at 5:42 am
[...] navigateToURL. You might be asking why would the amount of lines increase for such a simple task. Craig Campbell just recently posted an in depth example and explanation to creating outbound links within [...]
April 30th, 2008 at 4:53 am
Ahhh I can’t believe Adobe took something so easy and just ruined it!
April 30th, 2008 at 7:21 am
it doese no work with me ..i have always a security error that i can not enter this web site..can i have some help please.. thanx
(SecurityError: Error #2028: Le fichier SWF local-système de fichiers file:/)..
May 4th, 2008 at 6:16 am
Hi all, I’m new to flash (but not new to programming) and I have a straight remark : how on earth is it possible that the most useful thing like clicking on a banner to be forwarded to a website is so complex in AS3? It should be a simple option of the movie in the publish settings. I simply want any click on my banner to forward to my website, I don’t want anything fancy of any specific text or button to do it, I want the entire banner to do it, and I’m now forced to create a hack with a large transparent button and “uncompilable” code… Pffffff… anyway, thanks for your help
May 4th, 2008 at 11:25 am
Craig, freand! Dear friend! It works!!!! Just unbolievebel!!!!!!!!!!!!!!!!!!
myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.prodesign.890m.com/index.html”);
navigateToURL(request,”_blank”);
}
May 11th, 2008 at 10:51 am
I have the following code published in html with an embed F9 AS3 swf file:
———————————————————–
myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest=new URLRequest(“http://www.in.gr”);
navigateToURL(request,”_blank”);
}
———————————————————–
When i click the button it doesn’t go to the link.
When i open the swf with flash player it does? why does this happen?
May 11th, 2008 at 8:04 pm
hi there! i am using several buttons to link to different sites. i was unsuccessful with the above code, but i think i found code to put on my buttons that will work:
navigateToURL(new URLRequest(“http://www.ccsf.edu”), “_blank”);
is this because I tried to declare the same variable twice? sorry, i’m new at programming.
May 13th, 2008 at 3:05 pm
ok but where do you put this script, if not on an object like in AS2
May 13th, 2008 at 3:37 pm
@dan: You add the script to a keyframe. I usually keep my actionscript in its own separate layer called “Actions.” Click on the keyframe in the Actions layer, open up your Actions Panel, and enter the code.
May 14th, 2008 at 8:16 am
I tryed that on a separeted layer but than for some reason
my txeff plugin (http://www.txeff.com/) action script or movie for some reson want work.. I thank you for your time, just this if you know something about
May 22nd, 2008 at 5:46 am
I have a full flash web template with 5 pages. Within those pages I have buttons and hot spots I want to link to pdf files and new pages associated with the content of that page–a kind of “More” button. The tutorials I find instruct for adding pages to the main timeline or as above linking to external URLs. Is there a script for linking within the fla files? By the way, I have bought two books and neither have ActionScript for what I am trying to do. I am working in CS3.
May 28th, 2008 at 7:08 pm
You can condense lines 5 and 6:
function onClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(“http://www.whatever.com”));
}
May 31st, 2008 at 9:52 pm
It worked, but keeps opening a new browser window even though I exclude the “_blank” ???
June 12th, 2008 at 1:27 am
I copied the code as explained:
button.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.msn.com”);
navigateToURL(request, “_blank”);
}
even used the condensed version as “Worked” posted. Both does not work. It keeps stating 1 error “Description: ‘{‘ expected; Source: function onMouseClick(e:MousEvent):void”
I tried placing this AS in it’s own layer, with the button, inside the button keyframe, etc. and none launched me to MSN.com. Please HELP. What the heck am I doing wrong?
June 20th, 2008 at 10:11 am
because the onMouseClick action is repeated so u have to rename it for example if in your first button you have this
mybutton_mc.addEventListener(MouseEvent.click,onMouseClick);
Function onMouseClick(e:MouseEvent):void
your second button must have the onMouseClick like this
mybutton_mc.addEventListener(MouseEvent.click,onMouseClick2);
Function onMouseClick2(e:MouseEvent):void
and so on, as far i understand AS3 does not allow repeated actions so thats why you have to find a way easy for you to work with this, hope this helps
June 24th, 2008 at 1:09 pm
Thank you for this…the “how” worked very well.
I still don’t understand why they did this and why it’s better to do it this way. Does it offer more flexibility for varying options? Does it allow for better browser integration? Please explain.
June 29th, 2008 at 5:51 am
I have the same problem as Vasser. I get a security warning about the swf trying to do something unsafe and a message about changing security settings, then it closes.
This is on Windows Vista.
Any way to get around this?
July 7th, 2008 at 9:59 am
My problem is a little different.
This thread the closest thing that I’ve found to a solution on the web so far…I’m hoping I can find help here.
I am creading a CD Rom website with Flash CS3 and I need my flash button to link to a PDF file, opening it in a new browser window.
I used the script above and replaced the URL address with the path to my pdf file ( //content/1100w.pdf ) to no avail.
Craig! Help me out please! I’ve lookied through all of the LeranFlash.com tutorials that I have and could’nt find the solution.
Any help would be greatly appreciated.
July 12th, 2008 at 2:16 pm
Mike,
Try your code without the extra navigation information. Just use “1100.pdf” in the request and make sure the file is in the same directory as your swf or exe file.
Keith
July 12th, 2008 at 11:09 pm
I am trying to do a slide sync in AS3.0 and have everything in order until I tried to add a button to refer to a URL. Please take a look at my code and I added the suggested navigate to a URL code at the end of my other scripts. When I do this my flv Component icon just flashes and the movie no longer plays and I can not access the intended URL either. I started off with this template and just hoped to be able to use the get url command from AS2.0 associated with a specific button and that no longer seems possible… what a bummer
Any suggestions would be most appreciated.
// *************************
// Stop the timeline
stop();
// *************************
import fl.video.*;
import flash.events.*;
// Button hilite graphic
var highlight_mc;
// *************************
// Navigation buttons call this function to trigger a change
// in the video and the view of the content
function seekToCuePoint( cueName ) : void
{
// Find the cue point in the FLVPlayback component, seek
// to time, and highlight the next button for a quick redraw
var c = display.findCuePoint( cueName );
display.seekSeconds( c.time );
findNextButton( c.name );
}
// *************************
// The natural flow through the video or jumping by seeking
// forward and backward will trigger the following function
function synchVideoToInterace( cueName:String ):void
{
// Play if needed
if(!display.isRTMP && !display.playing ){
display.play();
}
// Show associated content on screens or labeled frames
gotoAndStop( cueName );
// Update the higlight position
findNextButton( cueName );
}
// Layout the button highlight when requested
function findNextButton( cueName:String ):void
{
// Look for buttons named with the current cue point
// name plus the letters ‘_btn’ (i.e. studiomx_btn)
if( getChildByName(cueName+”_btn”) != null )
{
var cueBtn = this[cueName+"_btn"];
// Attach the highlight clip if needed
if( this["highlight_mc"] == undefined ){
highlight_mc = new ThumbOutlineSelected();
addChild(highlight_mc);
}
highlight_mc.x = cueBtn.x;
highlight_mc.y = cueBtn.y;
}
}
// *************************
// Create event handler functions to catch events from
// the video component and update the interface…
function cuePointHandler( evt:MetadataEvent ):void
{
// Get the cue name from the event object
synchVideoToInterace( evt.info.name );
}
display.addEventListener(MetadataEvent.CUE_POINT,cuePointHandler);
// *************************
myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest=new URLRequest(?http://www.smpwebvideo.com?);
navigateToURL(request,?_blank?);
}
July 14th, 2008 at 6:37 pm
Craig,
This navigateToURL code works great when I test the flash movie, but when I publish it to the web site and click on the button, it doesn’t work. What’s missing?
I get this error message in Flash: WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.
July 14th, 2008 at 8:31 pm
I’m fairly new to all programing and I’ve been learning from different posts online and with messing around. However I have not found a way to link to internal html files I have stored on a server. This is what i have
HOMEBUT.addEventListener(MouseEvent.CLICK,onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest=new URLRequest(“/index.em?pid=817786″);
navigateToURL(request);
}
Is there a different way for relative urls and is that even the right term for them? Any answer would be appreciated.
July 18th, 2008 at 11:45 am
Still can’t figure this out. I created a layer called “Actions” Now I’m supposed to create a keyframe, but where? In Up, Over, Down or Hit?. I tried it in Hit, but when I open the Actions panel, it says “Current selection cannot have actions applied to it”
July 19th, 2008 at 6:24 am
Sneed: The actions need to be placed in the timeline where the button is placed, not in the button’s timeline. For example, if you placed your button on the main stage, you need give your button an instance name, then create a new layer on the main stage’s timeline for your ActionScript. If your button is in frame 1 of the main timeline, then you don’t need to add an extra keyframe, because there’s already a keyframe in frame 1 when you create the layer.
Hope this helps!
Craig
July 22nd, 2008 at 1:02 am
There was an earlier post that pretty well framed my question – What if you just want it to go to a url when the movie is over? I don’t need a button, just want to have the user brought over to a new web page once the flash movie has finished. I’m very new to Flash and would appreciate any help on this. How is that done?
July 28th, 2008 at 3:15 am
why do i get an error message?
button.addEventListener(MouseEvent.CLICK, onMouseClick)
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.fedhealth.co.za”);
navigateToURL(request,”_blank”);
}
July 29th, 2008 at 10:09 am
You’re simply the best!! thanks a lot!
August 8th, 2008 at 1:55 pm
security warning is on local, you have to give permission for the .swf for local access to domains outside of your system… upload ftp to your server hosting directory and you shouldn’ thave problems.
someone had issues with (henny?) errors, turns out some quotes are forward double quotes or two single quotes used as a double quote and Flash isn’t reading the quote tags in the function calls correctly.
so use:
URLRequest(“http://www.google.com”);
not
URLRequest(”http://www.google.com”);
not
URLRequest(”http://www.google.com”);
the ascii code for ” is different then ”
not sure if this text box will convert the text for me…
August 9th, 2008 at 1:06 pm
Try not using the word – request – for your var name
the word ‘request’ turns blue in my ActionScript panel – This means ‘request’ is part of Flash’s pre-defined vocabulary.
try replace ‘request’ with a descriptive name like ‘whatWebPage’
August 10th, 2008 at 7:15 pm
Thanks Craig, worked for me.
I agree… what used to be so easy is now so much harder.
What some people might be missing from this tutorial and why it is not working for them is that you MUST name your button ‘myButton’ in the properties inspector for the above code to work.
You can name the button anything you like as long as it’s the same name in the first line of code. Also, make sure you convert the code to Plain Text if copying and pasting the code.
August 10th, 2008 at 11:22 pm
Craig,
if you want to use CS3/AS3 to update your site. it’s all very frustrating ~ and means recoding entire site ~ MAKES no sense and a BIG waste of precious time to redo older work.
I have tried all of the above to no avail ~ just won’t work??
1) if you have a main stage timeline and on that a MC with a Button inside that on another timeline WHERE do you put the code?
2) do you have to instance name the MC or the BTN inside the MC
I just don’t get it
it used to be so easy just to put the code on the BTN (which was inside a MC on the main stage)
i.e. please help translate this: code which used to be on BTN (which was inside a MC)
on (release) {
getURL(‘http://www.VERY_FRUSTRATED_with_ADOBE_ASS3″);
}
will appreciate all your help… I’m in a bind to get this done
jean roman
August 11th, 2008 at 6:28 pm
Found a CODE that works great (but only for one btn)
(http://www.mandalatv.net/fcny/)
however, just major problem: following code only allows one click.
Question: How would you REcode this to make it work
for multiple (x4) Buttons in same scene / page
function getLink(event:MouseEvent):void{
var request:URLRequest = new URLRequest(“http://www.happyCODE”);
navigateToURL(request, “”);
}
Button1.addEventListener(MouseEvent.CLICK, getLink);
August 11th, 2008 at 7:18 pm
ps…
also wondering why the code you provided (reverse on placement of the “addEventListner”) did not work unless placed after the FUNCTION }
FYI: my System: OS X 10.5.4 using CS3 Prod. Suite / FLASH AS3
any thoughts on that frustrating oddity? I mean for heavens sake I tried it every which way, until I found the above reverse code (note: as you say the function can be named anything… in this case “getLink” was the given name to the code I found that worked)
meanwhile… and still working on multiple CLICKS same code on different buttons / instance names… any help will be appreciated to make this deadline >.|
September 9th, 2008 at 11:39 am
My script below “contains no errors” says Script Assist, but I get the following error when I export:
1120: Access of undefined property myButton.
September 9th, 2008 at 11:40 am
Ok, for some reason the rest of my message was cut off…
myButton.addEventListener(MouseEvent.CLICK, callLink);
function callLink(e:MouseEvent):void
{
var url:String = “http://www.google.com”;
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, ‘_blank’);
} catch (e:Error) {
trace(“Error occurred!”);
}
}
September 24th, 2008 at 1:05 am
Wow, this is so frustrating. Why Adobe? Why? I’ve looked all over for a “multi button” tutorial or explanation on how to do this and it’s nowhere. Amazing. With all the experts out there no one has posted some code for everyone to learn from. I’ve used Flash for years, making basic websites (I never got into AS for complicated stuff) but buttons were easy. LAME MOVE ADOBE!!!! I hope we can get some support from all you out there that agree this was a boner move on Adobe’s part and now they should make something even easier. How about Adobe puts a simple URL parameter when creating a button! What a revolutionary idea… a button… and a URL! – Not 10 lines of code to make a simple link. WEAK SAUCE – I’M BUMMED THEY RUINED FLASH BY COMPLICATING EVERYTHING! WHO’S WITH ME?
October 25th, 2008 at 2:13 pm
For some reason I just can’t seem to figure this out. I get the following errors whenever I input the coding you provided:
1046: Type was not found or was not a compile-time constant: website.
1120: Access of undefined property myButton. myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
I only have two layers, one is an image for my background and the other is the button that I am trying to get to function properly. This new coding is so confusing! And it never seems to work. Any help would be much appreciated.
November 1st, 2008 at 7:16 pm
I have a question. I have my links and my actions in separate layers, and it is about 11 frames long. My Actions code is in the last frame above everything, and it there are two buttons. One need to link to an HTML page and the other a PDF. Neither are responding to any coding i am putting! argh. This is the code I am trying to use:
import flash.events.MouseEvent;
btn_htmlLink.addEventListener(MouseEvent.CLICK, bClick);
function bClick(event:MouseEvent):void{
navigateToURL(newURLRequest(“HTMLResume.html”));
}
btn_pdf.addEventListener(MouseEvent.CLICK, pClick);
function pClick(event:MouseEvent):void{
navigateToURL(new URLRequest(“DCResume.pdf”));
}
Please help. They were variables before, but I just added the new URLRequest to make it less ambiguous i guess…either way it doesn’t work!!
November 4th, 2008 at 9:11 pm
Thanks for this simple step-by-step… however, even if this works fine, you said that it explains “why” we are doing it… Does it really? I don’t understand why I’m doing it, I’m just blindingly copy-pasting your code in my project…
I’d like to understand why we have to use this urlRequest thing, that simplyh contains an URL… Can it contain something else? Why say “this is a var, it is a request, and it equals a new request of a urlRequest thingy”… isn’t all this a little redundant??
If you tell me we can do much more with all this, okay… but if urlRequest cannot contain anything else other then an url.. then why not just put our url directly where it goes, instead of putting it in some useless urlRequest thingy?
November 5th, 2008 at 2:00 pm
I’ve seen it asked twice here, with no response, unless I missed it.
I just want to send my page to a URL once the movie has played, no buttons to push, just right to the URL… anyone?
November 9th, 2008 at 1:49 pm
I have the same problem as Stan.
“I’ve seen it asked twice here, with no response…I just want to send my page to a URL once the movie has played, no buttons to push, just right to the URL…”
Can someone help us please
November 13th, 2008 at 12:02 pm
hi,
>>“I’ve seen it asked twice here, with no response…I just want to send my page to a URL once the movie has played, no buttons to push, just right to the URL…”<<
It’s simple in action script 2.0, attach this code to the last frame:
ActionScript Code:
stop(); // to stop the movie getURL(“http://www.domain.com/”); // to go to the new page
In case you want to open a new window, you need to specify the target:
ActionScript Code:
getURL(“http://www.domain.com/”, “_blank”);
November 21st, 2008 at 8:47 pm
Box: you have the energy to write a double-edged compliment but not the energy to write the code? Good job chief.
December 5th, 2008 at 10:39 am
Ok. I am not new to flash or programming and I am appalled at Adobe’s decision in this. Let me explain. I completely understand why they’re going this route from a programmer’s perspective, gives you much more control and possiblities are opened from this advanced layout. BUT, and that’s a big but, one of the biggest things for FLASH was it’s simplicity in AS. It allowed designers to create interactive elements for their site, all be it simple ones – but it was possible.
Now I know what your thinking, “Greg you can set your file to be AS2 and do exactly what you want.” But I ask you this, why would I want to stick my head in the sand and act as though Adobe won’t do away with AS2 in the future. Also, I can’t use the 3d settings or new motion/keyframe capabilities with AS2. So, I say that Adobe should create a Jquery of sorts, allowing programmers to create functions like this that you can tap into – and then you just include the .as file and designers can program with ease again.
Sorry for the rant – but thanks for the tut.
–
Greg
December 8th, 2008 at 12:33 am
so happyyy
it wooorks, now i get moneeey
sorry for my english
bejo me liga
December 8th, 2008 at 3:23 pm
mybutton01 = instance of button
onMouseClick = if flash says its duplicate, change the name for each button
Example:
mybutton, onMouseClick
mybutton02, onMouseClick02
mybutton03, onMouseClick03
…..
String = “yoursite.html”
mybutton01.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var url:String = “index.htm”;
var req:URLRequest = new URLRequest(url);
navigateToURL(req, “_parent”);
}
I COMBINED TWO CODES IN ONE, THE CODE OF THIS TOPIC PLUS THIS PAGE’S CODE
http://www.8bitrocket.com/newsdisplay.aspx?newspage=8055
DID THIS
myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest=new URLRequest(”http://www.in.gr”);
navigateToURL(request,”_blank”);
}
AND CHANGED THE STUFF IN THE { xxx }
var url:String = “catalog.aspx”;
var req:URLRequest = new URLRequest(url);
navigateToURL(req, ’seetoys’);
FROM THE OTHER SITE, AND IN THE END IT WORKED OUT LIKE LIKE THIS:
mybutton01 = instance of button
onMouseClick = if flash says its duplicate, change the name for each button
Example:
mybutton, onMouseClick
mybutton02, onMouseClick02
mybutton03, onMouseClick03
…..
String = “yoursite.html”
—-final code—-
mybutton01.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var url:String = “index.htm”;
var req:URLRequest = new URLRequest(url);
navigateToURL(req, “_parent”);
}
—-end—-
AND IT WORKEEEEEED
SOH HAPPY, THX MAAAN
REALLY COOL STUUF
December 15th, 2008 at 7:53 pm
can you just this?
import flash.net.*;
navigateToURL(new URLRequest(‘http://www.google.com’),”_self”);
December 18th, 2008 at 10:43 am
can you just this?
import flash.net.*;
navigateToURL(new URLRequest(’http://www.google.com’),”_self”);
IT WORKS?
December 23rd, 2008 at 12:29 pm
Anyone who is having problems with the code they “cut and pasted” from this page, replace the “” signs in the code and everything should work again
December 25th, 2008 at 2:40 am
Thanks for the great piece of science coz all U wrote was helpful to me.
By the way, do you remember the problem with just plain
on(release){
getURL(“/blablablablabla/bla.html”, “_self”)
}
in AS2.0 when it was working good for AS1.0? I’m still wondering was it because of 2.0/1.0 difference? Or it was any other reason?
December 30th, 2008 at 10:43 am
hey all
i’m using actionscript 3.0
please i need the exact code to link two swf file that are located in the same folder.
not to link the button into a website that already in the web
January 6th, 2009 at 8:55 am
Hi there. I have designed a banner and have so far spent the best part of a day trying to get one button to link to a URL. The button appears at the end. Although the info above is clear and as far as I can see I have followed the info but it keeps coming up with the SAME error.
**Error* Scene 1, layer ‘actions’, Frame 65
line 1: 1120: Access of undefined property my_button.
my_button.addEventListener
(MouseEvent.CLICK, onmouseclick)
My code looks like this:
my_button.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://rfs.seafish.org/”);
navigateToURL(request, “_blank”);
}
Also I want my banner not to loop but the stop(); ceases to work when i add in the link code.
HELP!!!
Thanks in advance!
January 6th, 2009 at 10:44 am
hey, i tried to codes and various other codes i got from this side but keep getting the error message saying
“The class or interface ‘MouseEvent’ could not be loaded”
What could possibly be wrong?
January 7th, 2009 at 12:45 am
In your button properties–give your button an unique instance such as myButton without _ in it and try the code below. And remember to add your action codes in it’s own layer. Example: Layer1–actions
Layer2–background
Layer3–buttons
Layer4–images
blah,blah,blah–u get the idea.
myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.yoursite.com”);
navigateToURL(request,”_blank”);
}
January 7th, 2009 at 12:47 am
The above code was for “goingmad”.
January 7th, 2009 at 3:33 am
Raymond – Thats for your suggestions and code. The actions layer is separate and I re-named the button myButton, as well as copying and pasting in your code but unfortunately I am still getting an error message. This time it says:
**Error* Scene 1, layer ‘actions’, Frame 65
Line 5: 1093: Syntax error
navigateToURL(request,”_blank”);
Cheers again
January 7th, 2009 at 2:22 pm
goinmad–
Here i’ve created three basic square buttons giving them names as follows: The action is placed in one of button layer and not an action layer–of course this is for example purpose and it works as well. But i would recommend putting the action in it’s own layer–simplicity thats all..
Button1 label–my_button; Instance name–my_button
Button2 label–my_button02; Instance name–my_button02
Button3 label–my_button03; Instance name–my_button03
Here is my code in action action window:
my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest(“http://www.adobe.com”));
}
my_button02.addEventListener(MouseEvent.CLICK,clickHandler02);
function clickHandler02(event:MouseEvent):void{
navigateToURL(new URLRequest(“http://www.msn.com”));
}
my_button03.addEventListener(MouseEvent.CLICK,clickHandler03);
function clickHandler03(event:MouseEvent):void{
navigateToURL(new URLRequest(“http://www.yahoo.com”));
}
Each button link to assigned it’s own URL. Remember to assign a different clickHandler for each button as i did with mine.
Hope it helps.
January 9th, 2009 at 5:16 am
Hi,
I’d really appreciate a bit of guidance here if anyone can spare the brainpower. I’ve used various methods and codes to get a animated button with a link on and this seems great.
The only problem I am encountering is getting my links to reload within the same window, what I had previously thought of as “_self”. If I put “_blank” or inothin at all t works just fine and pops open a new browser window but what I need is for it to open the link within the window the .swf is actually embedded in, not a new one.
Any thoughts or pointers would be really great and I can see a few people having had similar problems on this thread.
Thanks in advance,
Ross
January 10th, 2009 at 7:21 am
Hi I wonder if anyone can help ?
I am trying to get an external swf to open in a new window from a button on my main swf.
Currently i have which works but lays on top of the main swf.:
imageGallery.addEventListener(MouseEvent.CLICK,magPicture);
function magPicture(e:MouseEvent):void {
var imageRequest:URLRequest= URLRequest(“magPicture.swf”);
var imageLoader:Loader=new Loader();
imageLoader.load(imageRequest);
addChild(imageLoader);
}
It would be a really good help if someone could advise as it is for an assignment for uni and i am running out of time.
Thanks
January 12th, 2009 at 2:51 am
Hi, thanx for a good indepth tutorial.
I only experience the same problem as Ross and Melanie: I excluded the “,_blank” yet the URL still opens in a new window. How do you get it to open the URL on the same window?
Thanx.
R
January 12th, 2009 at 3:41 pm
Hi, Just wanted to say thanks to raymond for a good save on the instance name thing
‘In your button properties–give your button an unique instance such as myButton without _ in it and try the code below. And remember to add your action codes in it’s own layer.’
spot on all works well now!
January 20th, 2009 at 6:09 pm
Hello,
I am attempting to make a clickable image map which would link to a series of other pages.
I tried to apply your code to what I have but it doesn’t seem to be working.
This is what I have:
westernsahara.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick (e: MouseEvent):void{ var request:URLRequest = new URLRequest (“http://www.international.ucla.edu/africa/countries/article.asp?parentid=96696″); navigateToURL(request, “_blank”); }
And this is the error I keep getting:
1120: Access of undefined property westernsahara.
It’d be much appreciated if you could help…thanks!
January 21st, 2009 at 3:02 pm
Hey,
i have my whole entire code in place and a OUTPUT error comes up. Here’s what it says:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at riders2_fla::MainTimeline/frame144()
does anyone know what that means? or what i’m suppose to do?
here’s my code:
stop();
frank.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://doubledubco.tripod.com/frankkreyssig.html”);
navigateToURL(request,”_blank”);
}
andrew.addEventListener(MouseEvent.CLICK, onMouseClick2);
function onMouseClick2(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/andrewfowler.html”);
navigateToURL(request, “_blank”);
}
bobbyp.addEventListener(MouseEvent.CLICK, onMouseClick3);
function onMouseClick3(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/bobbyproctor.html”);
navigateToURL(request, “_blank”);
}
cory.addEventListener(MouseEvent.CLICK, onMouseClick4);
function onMouseClick4(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/corychampagne.html”);
navigateToURL(request, “_blank”);
}
frankie.addEventListener(MouseEvent.CLICK, onMouseClick5);
function onMouseClick5(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/frankieglawson.html”);
navigateToURL(request, “_blank”);
}
bj.addEventListener(MouseEvent.CLICK, onMouseClick6);
function onMouseClick6(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/bj.html”);
navigateToURL(request, “_blank”);
}
blackattack.addEventListener(MouseEvent.CLICK, onMouseClick7);
function onMouseClick7(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/bigblack.html”);
navigateToURL(request, “_blank”);
}
zach.addEventListener(MouseEvent.CLICK, onMouseClick8);
function onMouseClick8(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/zach.html”);
navigateToURL(request, “_blank”);
}
matt.addEventListener(MouseEvent.CLICK, onMouseClick9);
function onMouseClick9(e:MouseEvent):void
{
var request: URLRequest = new URLRequest(“http://doubledubco.tripod.com/mattbrown.html”);
navigateToURL(request, “_blank”);
}
some please help me, i really need to know why it has an error
January 25th, 2009 at 8:47 am
This is exactly what I am looking for, but want to have multiple buttons with URL links, how can I do this I have tried this:
myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.mmkiteboarding.com”)
navigateToURL(request, “_blank”);
}
+ copy and pasted it changing the “myButton” to “myButton_1″ etc etc but no luck could someone please help thanks
J
January 28th, 2009 at 9:22 am
If the video is just gonna go to an URL when the movie is over, just place this code at the last frame:
stop();
var request:URLRequest = new URLRequest(“http://yoururl.com”);
navigateToURL(request,”_self”);
January 30th, 2009 at 8:04 pm
Hey uh.. i used this code and it’s like perfect but it stops the animation (timeline). How to do i continue the timeline?
Here’s wat the code looks like on a separate layer i created for the actionscript on the first possible frame.
banner01.addEventListener(MouseEvent.CLICK, onMouseClick1);
banner02.addEventListener(MouseEvent.CLICK, onMouseClick2);
function onMouseClick1(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.yahoo.com”);
navigateToURL(request,”_blank”);
}
function onMouseClick2(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.google.com/”);
navigateToURL(request,”_blank”);
}
So… how do I continue playing the animations.
February 1st, 2009 at 7:17 pm
Being able to cut and paste the code would be a nice addition to the page.
Thank
you for the useful information.
February 1st, 2009 at 8:28 pm
i just started learning AS3 and from the looks of it, AS2 was better, why change it. i guess there must be something im not seeing. but i appreciate your time and effort
February 3rd, 2009 at 8:04 pm
im trying to make multiple links on one page and in flash it goes to both, but on the web it only goes to one….can someone help me?
here’s the code:
adminsbb.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.myspace.com/niztech”);
navigateToURL(request,”_blank”);
}
mikekern.addEventListener(MouseEvent.CLICK, onMouseClick2);
k
function onMouseClick2(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://www.myspace.com/mikekern”);
navigateToURL(request,”_blank”);
}
February 4th, 2009 at 12:39 pm
First, I hate you ADOBE. Really, I do.
I think I can answer everyones questions with my discovery, here we go:
//Top of page
var myFirstLink:URLRequest = new URLRequest(“http://mywebsitelink.com”);
//Button Action
buttonOne.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(MouseEvent):void {
navigateToURL(myFirstLink, “_self”);
}
Things you need to know: The action and the button must be on different layers. For those of you who want more than one button on the page with different links, the code would look like this:
//Top of page
var myFirstLink:URLRequest = new URLRequest(“http://myfirstwebsitelink.com”);
var mySecondLink:URLRequest = new URLRequest(“http://mysecondwebsitelink.com”);
// Button Action
buttonOne.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(MouseEvent):void {
navigateToURL(myFirstLink, “_self”);
}
buttonTwo.addEventListener(MouseEvent.CLICK, onMouseClick2);
function onMouseClick2(MouseEvent):void {
navigateToURL(mySecondLink, “_self”);
}
Things you need to know: All buttons MUST BE on the same frame number. Otherwise, only the first button on the timeline will work; you’ll just click on the other buttons and nothing will happen. If you need more buttons just C&P the code and be sure to change the “var myFirstLink…” to a different name and the reference it at the “navigateToURL…” line.
PLEASE READ: Check all the quote marks”". This site seems to change them. I spent 10 minutes trying to figure out why I was getting an error about my quote marks.
Hope this helps.
/RANT
For those of you (Craig Campbell) creating tutorials on how stuff like buttons work in AS3, you’re wasting your time and ours if all you’re gonna show is how ONE BUTTON works. Or how putting buttons on different keyframes don’t work. OR, even something as basic as wether you’re using a mc(MovieClip) or a an actual button component for a button(and that you have to name them).
/END RANT
February 7th, 2009 at 3:07 pm
Hello All…I am pulling my hair out…PLEASE HELP!!!
I am trying to add URL navigation to my menu buttons. I followed a tutorial to create a sliding menu bar (http://schoolofflash.com/2008/05/flash-cs3-tutorial-sliding-menu-bar/). Menu works great.
When I try to add the above script to add in the URL navigation I keep getting errors. I get the same errors if I add this script to the “Buttons” layer in the action panel or the “Actions” layer in the actions panel.
The errors I get are:
1093: syntax error (show up 3 times)
1084: syntax error: expecting rightparen before colon (shows up once)
Thanks…I appreciate any ideas you have
(Except from “dan”, sorry man but I can’t understand anything you write)
February 10th, 2009 at 3:55 pm
Thanks to no one but myself…this code works with NO ERRORS…I couldn’t tell you why this works for me and not the code in this tutorial…
If you need more URL’s add numbers (1, 2, 3 so on) to the “thumbDownHandler” or “thumbUpHandler” anywhere it appears. It will look like so…”thumbDownHandler2″.
Below is the code:
home_mc.addEventListener(MouseEvent.MOUSE_DOWN, thumbDownHandler);
function thumbDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(“http://msdn2.microsoft.com/en-us/silverlight/default.aspx”));
}
sports_mc.addEventListener(MouseEvent.MOUSE_DOWN, thumbUpHandler);
function thumbUpHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(“http://www.adobe.com”));
}
poker_mc.addEventListener(MouseEvent.MOUSE_DOWN, thumbDownHandler2);
function thumbDownHandler2(event:MouseEvent):void {
navigateToURL(new URLRequest(“http://www.hotmail.com”));
}
I hope this helps!!
February 11th, 2009 at 1:53 am
i want request for actionscript for flash menu like “home” “contact” “sitemap” to url links to web page in internal link like if i open “home page” it link to index.html & if i link to contact links to contact & same on sitemap also like it dynamic page please mention me script for detail of this……..
February 11th, 2009 at 6:50 pm
THANKS for this. I’m still figuring out as3, very slowly. Sites like this are making it possible to get things done. : )
I thought someone might find this helpful if you want the hand cursor. Put the following code after
myButton.addEventListener(MouseEvent.CLICK,onMouseClick);
// if you want a hand cursor
myButton.buttonMode = true;
myButton.useHandCursor = true;
Happy coding
February 13th, 2009 at 10:25 am
For those of you having problems with your URL’s opening up in a new window even when you delete the line of code, dont delete it! Instead, replace _blank with _self. I notice by default action script opens up URL’s in a new window. See if that works.
February 17th, 2009 at 9:49 am
I have the same problem as above, but maybe… your topic will help me.
February 17th, 2009 at 10:47 pm
Hi, I got the button to work, but want it to stay within the same browser instead of opening a new one
I tried leaving the “_Blank” part out as you suggested, but it still seemed to open a new window.
What am I doing wrong?
February 17th, 2009 at 10:50 pm
Ok i am an idiot, i just read the post above and it instantly solved my problem. Sorry and thank you.
February 27th, 2009 at 1:10 pm
Just wasted an hour and a half trying to figure something out that usually takes 5 seconds, and I still can’t get it to work! THANKS ADOBE!!!!!
March 1st, 2009 at 6:38 pm
How do I use this code for multiple URLs. In AS3 you use to be able to put as many links as you wanted to. But doing it now I keep getting errors that I’m duplicating code:
function onMouseClick(e:MouseEvent):void
March 2nd, 2009 at 3:57 am
I am making Flash file in Action 3.0.
This CD contains 5 PDF product files and 1 PDF profile file.
I want to open Profile PDF file in Flash SWF file itself
AND
Rest 5 PDF files I want to open in New Window above the Flash exe. I don’t want to close Flash Main file.
I want user to insert CD in CD Drive and It Automatically open through Auto-run file.
When viewer click on PDF button.
Then PDF file should be open above the Flash exe. After viewing the PDF, viewer close the PDF and View Another PDF file.
Pleas help me..
It’s a question of my Job.
March 2nd, 2009 at 3:58 am
Currently I am using this for opening PDF file:
PELpro_btn.addEventListener(MouseEvent.CLICK, pClick);
function pClick(e:MouseEvent):void
{
var url:String = “PEL-Profile.pdf”;
var req:URLRequest = new URLRequest(url);
navigateToURL(req, “_parent”);
}
Help me….
March 3rd, 2009 at 5:30 pm
When will Adobe realise that most people ‘trying’ to use Flash are not programmers with !st Class Degrees! A lot of Flash users are designer/artistic types who learn As1 and AS2 quite easily to build their projects/sites. AS3 is going to force these types of user to stick with AS2 for as long as possible, but the question is, how long will the Flash Player support AS2 ! ? What the heck are Adobe trying to achieve by making such mundane simple tasks, only accomplishable by programming types? Unbelievable!
March 4th, 2009 at 3:19 pm
HI,
Please can someone help!!!
I am trying to put a .flv import file onto a page of my website in dreamweaver and what i want to do is to get it to automatically navigate to a different page once the movie has finished playing. The movie is setup as autoplay and autorewind with no click or button commands.
I am a bit of a novice at actionscript 3 so i am looking for someone to guide me through the process (instances etc…)
Many Thanks to whoever may take this task
Duncan
March 4th, 2009 at 7:47 pm
“How to play Flash movie in a browser and then at end of movie go to specific URL [without loading new browser window].”
I am fairly inexperienced with Flash. This site has provided the answer for ActionScript 3 for me. Thank you guys.
This worked for me:
Create new layer. Go to end of movie/timeline and then Insert/Timeline/Blank Key Frame and attach action script to it.
Window/Actions.
insert the following:
stop()
var request:URLRequest = new URLRequest(“replace_this text_in_quotes_with_your_URL”);
navigateToURL(request,”self”);
Good luck.
ASHLEY
March 4th, 2009 at 11:11 pm
I just tested this code in Firefox. Bummer. If pop ups are set to block in Firefox then this code does not work.
March 5th, 2009 at 7:15 am
I get an error. What’s up? This is the same error commented above by Turin in June 2008, but I see no reply to that error message.
It says “‘{‘ expected” and points to the error in the line function onMouseClick(e:MouseEvent):void
The full code is here:
GoButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://nursing.umaryland.edu/admissions/open.htm”);
navigateToURL(request);
}
Can someone tell me what’s up?
March 12th, 2009 at 7:45 am
For those of you having this problem:
“1120: Access of undefined property myButton.”
I had the same problem, then I found out how to solve this one. Click on the Button you just converted to, look at the “Properties” Panel, then look for an input that has written “”. Rename it to whatever you want, like “myButton”, for example. This name will be readable by the ActionScript.
March 12th, 2009 at 5:17 pm
“How to play Flash movie in a browser and then at end of movie go to specific URL [without loading new browser window].”
Refer 83, above.
Alternative way of getting the action to work.
Create new layer. Go to end of movie/timeline and then Insert/Timeline/Blank Key Frame and attach action script to it.
stop()
Create another new layer. Go to end of movie/timeline and then Insert/Timeline/Blank Key Frame and attach action script to it.
var request:URLRequest = new URLRequest(“replace_with_name_of_your.html”);
navigateToURL(request, “_self”)
Unfortunately, Firefox still views this coding as a pop up.
Can anyone overcome this pop up issue in Firefox?
March 15th, 2009 at 6:41 pm
navigateToURL(request,”_top”)
worked for me.
March 16th, 2009 at 12:30 am
navigateToURL(request, “_self”)
I just tried the site again.
This does not create a pop up problem in Firefox any more. Has there been an update in Firefox or something?
The code at comment No.89 does work.
Refer http://www.buildingondesign.com.au for example.
March 27th, 2009 at 9:52 am
Having some trouble with this code:
theBTN1.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“http://designsearch.renze.com/”);
navigateToURL(request,”_parent”);
}
It works fine when I test the movie. But after I publish it, the link no longer functions. Help!
April 20th, 2009 at 10:58 am
<3 thanks so much for this. I am new to flash and I’ve been looking for this code for days!!! and it work!! TY!
April 23rd, 2009 at 2:51 pm
this was quite helpful. I wish I would have scrolled down to the comments so i could have just copy and pasted the code. oh well…
how to you make a comments section like this one anyway??
April 26th, 2009 at 2:02 pm
I think i am the newest here but here i go ,,,, i got this working and is fine but there is a way to make it more simple ……
banner_mc.buttonMode = true;
logo_mc.buttonMode = true;
mini_principal_mc.buttonMode = true;
mini_somos_mc.buttonMode = true;
banner_mc.addEventListener(MouseEvent.CLICK,clickHandler1);
function clickHandler1(event:MouseEvent):void
{
navigateToURL(new URLRequest(“index.html”),”_self”);
}
logo_mc.addEventListener(MouseEvent.CLICK,clickHandler2);
function clickHandler2(event:MouseEvent):void
{
navigateToURL(new URLRequest(“index.html”),”_self”);
}
mini_principal_mc.addEventListener(MouseEvent.CLICK,clickHandler3);
function clickHandler3(event:MouseEvent):void
{
navigateToURL(new URLRequest(“index.html”),”_self”);
}
mini_somos_mc.addEventListener(MouseEvent.CLICK,clickHandler4);
function clickHandler4(event:MouseEvent):void
{
navigateToURL(new URLRequest(“somos.html”),”_self”);
}
i keep reading but is hard sometimes to understand ,,,, sorry but i hope nobody get mad for this ,,,, thank you in advance ,,,,, hey craig you may recognize the address i got the beggining but can no purchase the others ,,,,, since the lost of the legs in accident is been hard to get some cash to spend ,,,, thank you for the good work,,,,,
April 28th, 2009 at 6:16 pm
I cannot get this code to work for the life of me. I have copied it EXACTLY and still I can’t get it to work? I have even been using the generic adobe URL just to try to get it to work? I have now spent several hours just trying to add a simple link! Someone PLEASE help this Flash newbie.
Here is my code…
this.navBar.navPortfolio_mc.rollDownPortfolio_mc.subMenu1.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest=new URLRequest(“http://www.adobe.com”);
navigateToURL(request, “_self”);
}
April 29th, 2009 at 11:42 am
i do not know much but i think you need to eliminate the first “this.” ,,,,, do not take my word but i will look into the CraigTutorials for it
May 17th, 2009 at 7:01 am
how do i link the page within the website
e.g: i want the home button to be linked to the home.aspx page in the same folder
home_btn.addEventListener(MouseEvent.CLICK, homeClicked);
function homeClicked(event:MouseEvent):void
{
/*???*/
}
May 29th, 2009 at 6:29 am
I am having the same trouble as Travis. Did you get this to work for you once the movie was published? I can’t figure it out.
My movie works while testing but not after it’s published. Anyone have any ideas?
May 29th, 2009 at 12:28 pm
This is to help out someone who also got stuck here: Flash movie links work during Test Movie but not after publication. I had to set the Global Security Settings panel (search for it online) to accept the folder on my PC. After I did that, closed and reopened the application, republished the Flash movie, all the links worked.
May 31st, 2009 at 4:29 am
Is there anyone who can tell me what exactly seems to be the problem with my script… keeps giving me an error ‘{‘ expected…??
btn1.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest(“https://www.russellcampbelracing.co.za”);
navigateToURL(request,”_blank”);
}
June 1st, 2009 at 8:10 am
Thanks for the tutorial. Your explanation was very good. thank you.
July 7th, 2009 at 7:53 am
Place this code in any frame at your movie clip timeline:
navigateToURL (new URLRequest(“http://www.domain.com” ), “_self”);
–> For making flash go to your URL when movie clip ends
—————————————————
Place this code in any frame at your movie clip timeline:
button.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest (“http://www.aterno.lv” );
navigateToURL(new URLRequest(“http://www.aterno.lv”), “_blank”);
}
–> For making your button (do not forget to name it “button”) go to your URL
July 14th, 2009 at 7:23 pm
Hi all, I’m new to flash so hopefully someone can please help me out.. Using Flash CS4 with Actionscript 3.0 and it seems to me that many people are having issues with it?
I’ve created a movie clip and added a button on the last keyframe (so that the button doesn’t appear until the end).
I have added the following code to the last keyframe (when the button appears)
enterbutton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(event:MouseEvent):void
{
var request:URLRequest = new URLRequest (“http://www.adobe.com”);
navigateToURL(new URLRequest(“http://www.adobe.com”), “_blank”);
}
Problem is, the little hand icon appears when i hover it over the button, but nothing happens when I click.. Been trying out all different codes but nothing works and I’m getting pretty frustrated now..
I’m sure there’s a Flash Guru who can help me out! =) Thanks in advance!
July 21st, 2009 at 11:10 am
Hey man, awesome website! I have more of a programming background and was just picking up on Actionscript 2 when I decided to dive into Actionscript 3. I’m glad I stumbled across your website as it’s answered a lot of my questions in a real short time! Thanks!
July 29th, 2009 at 4:04 pm
someone should post a fla with two functional links then we could all just reuse something that works as adobe couldn;t even offer us that much. Adobe messed up with this so that their program wont reach as many developers as it could have, once I find my cut and paste thats all im ever gonna do. there is no reason to understand the nonsense so long as its grappled to the point of functional manipulation
August 12th, 2009 at 10:11 pm
Hi and thanks Craig, found this very easy to follow and intuitive. Why? Because I already program in Java, and this is exactly how I expect this to be done. Sorry to everyone who finds this method long winded and difficult, but if you need a reason for your torment, then here it is. Basically a large subset of Flash Developers are Java programmers building Rich Internet Applications (RIAs) and this change caters to their need to have a flash scripting language that does not differ drastically from Java’s. Different for them means more errors, longer and more expensive develolment time. Adobe is just going where the money is, obviously.
August 24th, 2009 at 3:01 pm
Hi, Thank you so much!Really appreciate when someone takes the time to go and put up a really useful tutorial. Keep up the good work!
August 30th, 2009 at 11:00 am
Just wanted to say a quick “Thanks!” for such a straight forward tutorial about a very vital aspect of web design. I could have saved hours of my life had I just come here first instead of browsing all the ridiculously specific tutorials elsewhere. Thanks for helping my on my way to building flash sites!
September 24th, 2009 at 1:15 pm
This gave me exactly what I needed. Thanks!
September 28th, 2009 at 8:53 am
Wow, thx so much, this code is “fantastic” hauhau
thx again!
November 18th, 2009 at 11:56 pm
Hello everybody!
I have a serious problem with a code.
This is my code:
function makebtn(mc:MovieClip,aurl:String):void{
mc.aurl = aurl;
mc.buttonMode= true;
mc.addEventListener(MouseEvent.CLICK,gotoaurl);
}
function gotoaurl(e:MouseEvent):void{
var aurl:String = e.target.aurl;
navigateToURL(new URLRequest(aurl));
}
makebtn(btn1,’http://www.google.com’);
|
I have tried all codes to make it work for a simple button or movieclip have the task to open an URL in _blank window. This code wotks just fine, but when i put the swf in dreamweaver and publish in html, the code for the just simple doesn´t work!
The button and code is split into two windows (content), 1, Scene 1 -> ScrollContent -> content.
The buttons placed outside the ScrollContent with the same codes work. But the others in content area (wich have the scroll) doesn´t works!
Can anyone help me? please!
January 29th, 2010 at 1:39 am
HI i m satya.
I really hate AS3….
Please help me out for this..
In swf at last frame I want to open a url without any click
but right now its not working with following code.
—- as3 code ——
stop();
var request:URLRequest=new URLRequest(“http://www.villaisla.co.in/Villaisla.html”);
navigateToURL(request,”_self”);
PLease help me….
February 12th, 2010 at 9:39 am
Dears, i went throught all the conversation up so is it mean we can’t add more then geturl() link with the AS3 is there any other way to include more then one.
February 12th, 2010 at 10:06 am
Thanks for You All, No Need to Reply i fix it as below and it’s work fine:
a.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void
{var request:URLRequest=new URLRequest(“discover_course.htm”);
navigateToURL(request,”_blank”);
}
b.addEventListener(MouseEvent.CLICK, onMouseClick01);
function onMouseClick01(e:MouseEvent):void
{var request:URLRequest=new URLRequest(“open_course.htm”);
navigateToURL(request,”_blank”);
}
c.addEventListener(MouseEvent.CLICK, onMouseClick02);
function onMouseClick02(e:MouseEvent):void
{var request:URLRequest=new URLRequest(“advanc_course.htm”);
navigateToURL(request,”_blank”);
}
d.addEventListener(MouseEvent.CLICK, onMouseClick03);
function onMouseClick03(e:MouseEvent):void
{var request:URLRequest=new URLRequest(“efr_course.htm”);
navigateToURL(request,”_blank”);
}
e.addEventListener(MouseEvent.CLICK, onMouseClick04);
function onMouseClick04(e:MouseEvent):void
{var request:URLRequest=new URLRequest(“rescu_course.htm”);
navigateToURL(request,”_blank”);
}
f.addEventListener(MouseEvent.CLICK, onMouseClick05);
function onMouseClick05(e:MouseEvent):void
{var request:URLRequest=new URLRequest(“master_scuba_course.htm”);
navigateToURL(request,”_blank”);
}
February 20th, 2010 at 5:34 am
Thx a lot
February 20th, 2010 at 12:41 pm
Hello I am getting back into flash, I used to be pretty good at flash mx, but now with cs3 and action script 3.0 I cannot add a get url at the end of a timeline to work. Here is what I am doing:
I have greenscreened a video and imported it into flash cs3 with action script 3.0 for it to work, with a background and by looking at the code you have done, it should work but I get errors and my green screen video disappears? Any ideas?
February 25th, 2010 at 6:38 pm
I just wanted to say THANK YOU for this post, it was extremely helpful. THX
March 3rd, 2010 at 10:27 pm
I created a little getURL class for actionscript 3 that simulates as2 getURL here: http://www.as3blog.org/?p=40