View Full Version : Need the script to load a text file from a folder..
chaudoufroid
12-05-2004, 07:51 PM
hi everyone,
I'm trying to load text (workComment.txt) that is in the folder (text) into my flash. The var name given for my dynamic text box is (workComment). I'd like to place the script on a button but coulnd't figure out how to load a text file from a folder..will be glad if someone can help me with this asap..thank you !
regards,
Jen
oldnewbie
12-05-2004, 08:13 PM
Online or local?
chaudoufroid
12-06-2004, 06:27 AM
hi, it's local. tHx!
CyanBlue
12-06-2004, 10:43 AM
Um... You've got to check out the LoadVars tutorial at this site for more information, but the code might look something like this...
some_btn.onPress = function ()
{
load_lv = new LoadVars();
load_lv.onLoad = function (ok)
{
if (ok)
{
trace(unescape(this));
}
else
{
trace("Problem loading the text file...");
}
}
load_lv.load("relative/path/to/file/workComment.txt");
}
Hey, oldnewbie... Why did you ask that local or online question??? I am not quite getting that question... What am I missing??? :)
chaudoufroid
12-06-2004, 03:20 PM
hi CyanBlue,
Thanks for the above code..but it didn't seem to work in my file? (says:Statement must appear within on handler).That means i need to place it within something else? Is there a one-line code which i can apply easily coz there are many buttons..:) Thanks again!
redruby
12-06-2004, 03:31 PM
Put CyanBlue's code in the timeline where your button named "some_btn" resides, not directly on the button.
chaudoufroid
12-06-2004, 04:13 PM
Hi, I've attached the file, the text is supposed to load inside the dynamic text box called workComments. Thanks :)
regards,
Jen
oldnewbie
12-06-2004, 08:56 PM
BBBOOOOOOOOOOOOOOOOOOOO!
A MX2004 .fla on a MX AND LOWER only forum? :mad:
Unexpected file format! Can't open your .fla.
You'd have a better chance of getting an answer if your .fla was in a MX only format.
You would have to save a copy of your MX2004 .fla, (using Save as...) and changing the Document type to MX only in the Save as... window.
Or post on a MX2004 forum!
chaudoufroid
12-07-2004, 05:58 AM
hey i thought this forum is under "ActionScript.org -- FORUMS > Flash MX 2004 > ActionScript 2.0..? :)
chaudoufroid
12-07-2004, 07:59 AM
What I have on the button-->
on (release) {
_root.imagesMc.loadMovie("portfolio_swf/STE.swf");
//Loads the external movie. The STE.swf sits inside the portfolio_swf folder.
loadText = new loadVars();
loadText.load("text/STE.txt");
//the STE.txt file sits inside the text folder
loadText.onLoad = function(success) {
if (success) {
trace(success);
_root.comment.html = true;
// var name of the dynamic box which in the
main timeline (_root)
_root.comment.htmlText = this.STE;
}
};
}
//------------------> In the output panel
**Warning** Symbol=graphic to scroll, layer=list of buttons, frame=1:Line 14: The identifier 'loadVars' will not resolve to built-in object 'LoadVars' at runtime.
loadText = new loadVars();
Total ActionScript Errors: 1 Reported Errors: 1
Don't know why it still can't work. I will need script that can apply on the buttons, instead of putting it in the frame...
Thanks everyone : )
Regards,
Jen
CyanBlue
12-07-2004, 01:46 PM
No, I have moved your post to the FMX 2004 forum not you... :p
FMX 2004 is case sensitive(at least AS 2.0 is)...
loadVars();
should be...
LoadVars();
chaudoufroid
12-08-2004, 04:45 AM
thank you CyanBlue, it's working now :)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.