ActionScript 3 Tutorial – What Happened to getURL?

Author : Craig

Author's Website | Articles from

For 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:

code

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:

code

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:

code

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.

Like this post? Share it!

  • Tweet
  • Facebook
  • Diggit
  • Delicious
  • Diggit
  • Diggit
  • Diggit
  • Diggit
  • Diggit

Related Posts


User Comments


  1. DiegoDx
    December 18, 2008

    can you just this?

    import flash.net.*;

    navigateToURL(new URLRequest(’http://www.google.com’),”_self”);

    IT WORKS?

    Reply

  2. Xak
    December 23, 2008

    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

    Reply

  3. Alessandro Flasher
    December 25, 2008

    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?

    Reply

  4. nikzouly
    December 30, 2008

    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

    Reply

  5. goingmad
    January 6, 2009

    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!

    Reply

  6. sophia
    January 6, 2009

    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?

    Reply

  7. raymond
    January 7, 2009

    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”);
    }

    Reply

  8. raymond
    January 7, 2009

    The above code was for “goingmad”.

    Reply

  9. goingmad
    January 7, 2009

    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

    Reply

  10. raymond
    January 7, 2009

    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.

    Reply

  11. Ross
    January 9, 2009

    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

    Reply

  12. Rachael
    January 10, 2009

    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

    Reply

  13. Rudolf
    January 12, 2009

    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

    Reply

  14. Jon
    January 12, 2009

    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!

    Reply

  15. srawr42
    January 20, 2009

    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!

    Reply

  16. Mike
    January 21, 2009

    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

    Reply

  17. JEz
    January 25, 2009

    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

    Reply

  18. Benny
    January 28, 2009

    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”);

    Reply

  19. Brian
    January 30, 2009

    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.

    Reply

  20. Robert
    February 1, 2009

    Being able to cut and paste the code would be a nice addition to the page.

    Thank
    you for the useful information.

    Reply

  21. wallpaperama
    February 1, 2009

    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

    Reply

  22. mike
    February 3, 2009

    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”);
    }

    Reply

  23. Hector
    February 4, 2009

    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

    Reply

  24. Danielle
    February 7, 2009

    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)

    Reply

  25. Danielle
    February 10, 2009

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

    Reply

  26. srinivas_dikonda
    February 11, 2009

    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……..

    Reply

  27. Jan
    February 11, 2009

    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

    Reply

  28. valt
    February 13, 2009

    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.

    Reply

  29. Pinoy Gamers
    February 17, 2009

    I have the same problem as above, but maybe… your topic will help me.

    Reply

  30. LH
    February 17, 2009

    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?

    Reply

  31. LH
    February 17, 2009

    Ok i am an idiot, i just read the post above and it instantly solved my problem. Sorry and thank you.

    Reply

  32. Ed
    February 27, 2009

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

    Reply

  33. Bernie C
    March 1, 2009

    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

    Reply

  34. KD
    March 2, 2009

    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.

    Reply

  35. KD
    March 2, 2009

    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….

    Reply

  36. James
    March 3, 2009

    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!

    Reply

  37. Duncan
    March 4, 2009

    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

    Reply

  38. Ashley Voigt
    March 4, 2009

    “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

    Reply

  39. Ashley Voigt
    March 4, 2009

    I just tested this code in Firefox. Bummer. If pop ups are set to block in Firefox then this code does not work.

    Reply

  40. bryan
    March 5, 2009

    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?

    Reply

  41. Alexandre de Oliveira
    March 12, 2009

    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.

    Reply

  42. Ashley Voigt
    March 12, 2009

    “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?

    Reply

  43. stas
    March 15, 2009

    navigateToURL(request,”_top”)

    worked for me.

    Reply

  44. Ashley Voigt
    March 16, 2009

    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.

    Reply

  45. Travis
    March 27, 2009

    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!

    Reply

  46. Michelle
    April 20, 2009

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

    Reply

  47. doug
    April 23, 2009

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

    Reply

  48. Chago
    April 26, 2009

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

    Reply

  49. Marcia
    April 28, 2009

    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”);
    }

    Reply

  50. Chago
    April 29, 2009

    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

    Reply

Leave a Reply

 
  Twitter Followers

Stock Flash Files Web Development Tutorials

Stock Graphics Video Files


Your Ad Here