Flash buttons link in external text file

Let’s say you have 3 buttons inside of flash that link to different web sites and you want to be able to update those links without having to open the .fla file to decompile and then upload the .swf file.

With the action script below you can easily open the external .txt file and edit the links without ever having to open flash.

//put this script on a frame where all your 3 buttons are located…

textFile = new LoadVars()
textFile.onLoad = function(){
buttonlink1 = this.link1;
buttonlink2 = this.link2;
buttonlink3 = this.link3;
}
textFile.load(“mylink.txt”); // mylink.txt is your external text file

//—actionscript for buttons
//—make sure you have all your buttons instance name added. btn1, btn2 and btn3.

btn1.onRelease = function(){
getURL(buttonlink1, “_self”);
};

btn2.onRelease = function(){
getURL(buttonlink2, “_self”);
};

btn3.onRelease = function(){
getURL(buttonlink3, “_self”);
};

Then this is what you put inside mylink.txt


&link1=http://www.yahoo.com
&link2=http://www.google.com
&link3=http://www.w3schools.com



That’s it..

More share buttons
Share on Pinterest
There are no images.
Share with your friends










Submit
If you enjoyed and find this article helpful please consider SHARING and LIKING it.

Author: k5


Hi, I’m Thom. I’m currently living in Thailand. I’m a artist, designer, travel blogger, and sometimes a YouTuber. I left my life in Toronto, Canada as a Web Designer to pursue my dream to become an independent artist.

Keyframe5 is not responsible for comments or reviews provided by external users for the accuracy, authenticity or reliability of the content. Read our Terms of Service.

8 thoughts on “Flash buttons link in external text file

  1. THANK YOU! After struggling with loadVariables or loadVariablesNum to get it to load the file and put a URL, I finally gave up. THIS IS THE ONLY SOLUTION THAT WORKED FOR ME! TY :)

    PS: Instead of doing the:

    btn1.onRelease = function(){

    getURL(buttonlink1, “_self”);

    };

    You can do the following also without specifying the button instance:

    on (release) {

    getURL(buttonlink1, "_self");

    }

  2. First of all, thank you for this, you've saved my life after a couple hours of losing my mind trying to figure this out.

    Quick question…when I use test this in a browser (Firefox and Safari), it's adding a "" at the end of the URLs, leading to a page load error.

    How do I fix this, or what might be causing it?

    My test link for link1 is copied exactly from your mylink.txt window.

    Thanks!

  3. figured it out, thought i'd post just in case anyone else has a similar problem. Not sure why, but it didn't work when creating the .txt file with TextEdit, but creating it in Pages and exporting as a .txt worked great.

  4. Hello

    thanks alot for this but i have small issue and realy hope find quick solution for my probelm the code works great in preview but when i export it and insert into HTML file the links not working at all any suggestions

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *