Results 1 to 8 of 8

Thread: getURL from a external text file.

  1. #1
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default getURL from a external text file.

    hello guys!

    I'm building a flash site and needed some help.


    1) i have this buttons whereby when the user click it, it will bring them to another page of the site, however the link to the site need to be read from external text file. Meaning i need to load the address of the link from a external file like notepad or wad. (sorry, i do not know how to use xml, although i'm trying to pick it up now.)

    Can i know what is the script needed to do this? i know it's something like "loadVariablesNum("home.txt", 0);" but i just can't get it work!

    2) i also need to create a tooltip for some movieclip, however it just dont work. inside the MC the there is button moving from bottom to top non-stop, which i done it using motiontween. I make it stop when mouse over by placing this:

    on (rollOver) {
    stop();
    }
    on (rollOut) {
    play();
    }
    . However with this script, my tooltip function won't happened when i mouse over the mc.. arh..

    sorry for the long question! I'm really lost in this... i've been trying to solve this question for weeks and i just have no one to ask.

    sorry if this kind of question have been asked before as i can't seem to find what i need in the forums.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    1. Use XML. You'll find it more flexible in the long run in case you want to add something.

    XML:
    Code:
    <links>
         <link>http://www.dynamicdrive.com</link>
    </links>
    Actionscript:
    Code:
    var xml:XML = new XML()
    xml.ignoreWhite = true;
    
    xml.onLoad = function() {
          loadLinks();
    }
    
    function loadLinks() {
           var link:String = xml.firstChild.childNodes[0].childNodes[0]
           buttom_MC.onRelease = function() {
                getURL(link);
           }
    }
    
    xml.load("links.xml");
    The numbe in red is what you would change to access different nodes in the XML (if you had more than one link. Note: XML iteration starts at 0, not 1).


    2. In regards to the tooltip, it's hard to know what's going on from your description.

    First, check this tutorial: http://www.gotoandlearn.com/player.php?id=56
    If you still can't get it to work, post your source files.

    HTH

  3. The Following User Says Thank You to Medyman For This Useful Post:

    linjunxian (03-07-2008)

  4. #3
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Talking

    omg omg omg! thank you so much! haha! i've finally solved the problem that having been bugging me for weeks with your help! THANKS!

    I've managed to solve the tooltips problem too by pasting the code in other frame already.. so anyway still a huge thank for your reply!

  5. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Glad it worked out for you

  6. #5
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default External XML links

    Hi I know this thread Is well old but I found your answer really helpful.

    Are you able to tell me how I can write that script to include multiple buttons? I got the xml set up it's just the syntax on the script that's got me stumped.

    I'm using your suggestion:

    var xml:XML = new XML()
    xml.ignoreWhite = true;

    xml.onLoad = function() {
    loadLinks();
    }

    function loadLinks() {
    var link:String = xml.firstChild.childNodes[0].childNodes[0]
    button_MC.onRelease = function()

    {
    getURL(link);
    }
    }
    xml.load("links.xml");

    - - - - - - - - - - - - - - -

    I want to be able to set up 14 buttons:

    function loadLinks() {
    var link:String = xml.firstChild.childNodes[1].childNodes[0]
    button_MC.onRelease = function()

    etc etc

    Any help would be much appreciated indeed!
    Dave

  7. #6
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This code worked fine for me in a button, but I need to add more buttons.

    Medyman, could you please fix this code to allow more buttons to take the link from the XML file?

    XML:
    _____________________________________________
    <links>
    <link>http://www.dynamicdrive.com</link>
    <link>http://www.google.com</link>
    <link>http://www.apple.com</link>
    </links>
    _____________________________________________


    AS:
    _____________________________________________
    var xml:XML = new XML()
    xml.ignoreWhite = true;

    xml.onLoad = function() {
    loadLinks();
    }

    function loadLinks() {
    var link:String = xml.firstChild.childNodes[0].childNodes[0]
    btn_1.onRelease = function() {
    getURL(link);
    }
    }

    xml.load("links.xml");
    _____________________________________________

    How do you incorporate "btn_2" and "btn_3" in this code?

    Thanks in advance!

  8. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Code:
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    
    xml.onLoad = function() {
    	loadLinks();
    };
    
    function loadLinks() {
    	var link:String = xml.firstChild.childNodes[0].childNodes[0];
    	btn_1.onRelease = btn_2.onRelease=btn_3.onRelease=function () {
    		getURL(link);
    	};
    }
    
    xml.load("links.xml");
    Unless you want each button to open a separate file, or similar.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #8
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, here is what I did.

    I have all the animated icons in movie clip (mcCamera, mcGPS, mcMessages, etc.)

    XML (I used those well-known URLs for testing only)

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <links>
         <link>http://www.nec.com</link>
    	 <link>http://www.cnn.com</link>
    	 <link>http://www.ibm.com</link>
    	 <link>http://www.xerox.com</link>
    	 <link>http://www.samsungwireless.com</link>
    </links>
    Actionscript and the links didnt work.

    Code:
    var xml:XML = new XML()
    xml.ignoreWhite = true;
    xml.onLoad = function() {
          loadLinks();
    }
    function loadLinks() {
           var link:String = xml.firstChild.childNodes[0].childNodes[0]
           mcCamera.onRelease = mcGPS.onRelease = mcMessages.onRelease = mcQWERTY.onRelease = mcMPlayer.onRelease = mcWiFi.onRelease = function() {
                getURL(link);
           }
    }
    xml.load("config/icons.xml");
    Let me know what I did wrong.

    Thanks!

Bookmarks

Posting Permissions

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