View Full Version : getURL from a external text file.
linjunxian
03-05-2008, 02:48 AM
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.
Medyman
03-05-2008, 05:21 PM
1. Use XML. You'll find it more flexible in the long run in case you want to add something.
XML:
<links>
<link>http://www.dynamicdrive.com</link>
</links>
Actionscript:
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
linjunxian
03-07-2008, 05:28 AM
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! :D
Medyman
03-07-2008, 05:51 PM
Glad it worked out for you :)
davemandoo2
05-07-2010, 08:30 AM
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
Kurtz
05-14-2010, 07:21 PM
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!
BLiZZaRD
05-14-2010, 09:05 PM
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.
magnix
05-25-2010, 07:58 PM
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)
<?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.
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!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.