Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts

    getURL - does it need a full path?

    Hello,

    I am writing a flash application to go into a Ruby on Rails site. I'm only learning both languages, so I'm just messing around with things.

    I was getting Ruby to create an xml file with images and a url in it. I've written a script (by following a few tutorials) to show the images. When someone clicks on an image, I want it to go to a url.

    This is my code:

    Code:
    //when clicked on screen go to URL
    listen  = new  Object();
    Key.addListener(listen);
        btn.onRelease = function() {
            gotoUrl();
        };
    
        function gotoUrl() {
            getURL(url[i]);   
      }
    i is a counter so it knows which url the image is related to. A url is passed to getURL ok, but it doesn't go anywhere. Does it need a full path? The path I am sending to the file is relative, and if I type it into a browser then it takes me right to the page I want to go to.

    I guess a simple solution would be to add the base part of the url to the (url[i]) bit automatically - how would I do this? I'm not sure of the exact syntax.

    Thanks!

    Nicky
    Last edited by nickyfraggle; 09-04-2008 at 10:55 AM. Reason: title incorrect

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Try this. It shouldn't require a full URL, but it sometimes helps. Also, I added a second parameter to the getURL function, which tells the browser to use the same window for the link.
    Code:
    //when clicked on screen go to URL
    listen  = new  Object();
    Key.addListener(listen);
        btn.onRelease = function() {
            gotoUrl();
        };
    
        function gotoUrl() {
            getURL("http://www.somewhere.com/"+url[i], "_self");   
      }
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • Users who have thanked gnomeontherun for this post:

    nickyfraggle (09-04-2008)

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    Thanks Jeremy! I'm going to have a go tomorrow but thanks again for all your help!

    Nicky


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •