Login | Register
Compare Gas & Electricity Prices

Recent Posts

Recent Comments

By: k5 | posted in Flash, HTML/CSS, Tutorials, Web Design |
Date: October 28th, 2008

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

Do you like this article?

By: k5
Site:
Info: The information contained in this article is for general information purposes only. We endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to this article or the information, products, services, or related graphics in this article for any purpose. Any reliance you place on such information is therefore strictly at your own risk. In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this article.

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

There are 8 comments for Flash buttons link in external text file

  1. Light says:

    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. Jef says:

    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. Jef says:

    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. Thom says:

    Glad to hear you find this useful. Cheers.

  5. Troy says:

    Simple, to the point, and had it working in under a minute. Thanks for taking the time to make this!

  6. petersarkozi says:

    Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  7. ranin says:

    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

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

Post a Comment


Captcha (required)
Basic HTML tags are allowed: <blockquote> <a href> <strong> <em>