Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / November 2006



Tip: Looking for answers? Try searching our database.

loadVars and txt file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hengy - 02 Nov 2006 16:11 GMT
Hi,
    I want to load a simple variable (like a number) from an external text
(txt) file.

   This is the code I have:
loadVars("numimg.txt", "")
numimg = var_txt;

It seems a little too simple to work, and of course, it doesn't. It says my
computer will go very slow if I continue to run it and then it closes. I think
it might be because the file isn't loaded when I try to get the variable. So
then I tried this:

var loadnumimg = loadVars();
if (loadnumimg.percentLoaded = 100) {
     numimg = var_txt;
}
loadnumimg.load("numimg.txt")

But, seeing as how I am writing this post, you can safely assume that it
didn't work. :sad;

Can anyone help me?

Thanks, Hengy
PinoStyL - 10 Nov 2006 15:33 GMT
Your text file needs to include a reference variable in it.

Suppose a single line text file should read:

number=1234567890

You close that and save it as "numimg.txt"

On your stage, create a dynamic text field and call it var_txt  (per your
example)

Now the ActionScript:

var loadNumimg_lv = new LoadVars(); // the _lv suffix will help with Flash
giving you hints
loadNumimg_lv.onLoad = function() {
        var_txt.text = loadNumimg_lv.number;  // the suffix ".number" refers
to the reference variable inside the text file.
}
loadNumimg_lv.load("numimg.txt");  // if it's in the same folder as your swf

loadNumimg_lv.load("text/numimg.txt");  // if it's in a sub folder called
"text"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.