-
bringing in text from files
How do I bring text from an external text file (text.txt) into a dynamic text box at for eg frame 6 (f6) in a movieclip (textMc) . I have researched this topic in 3 manuals and can't figure it out.
-
FK'n_dog
Main timeline -
lv = new LoadVars();
lv.onLoad=function(){
_level0.myVar = lv.myVar;
};
lv.load("text.txt");
text.txt - myVar=hello&
movieclip frame6 -
myTextfield.text = _level0.myVar;
something like that ?
-
Moderator
Here is a .fla I put together a loooooooooooong time ago !!
Zip File
-
Between Flash & Flashkit
it really depends on what type of external txt file your loading into the flash txtField..
if your txtFile has &%#"! > and other characters then you can elimate URL encoding these in the txtFiel by using " onData " if your txtFiel is just regular characters then you can use onLoad . but it really depends on what your txtFiel contents are ..i can show you how i load in external xtx files depending on the contents .
this script i use when ther are no special characters =)(/&%/%¤#"¤
Code:
//system use code page . will display characters such as ÄÖÅäöå
System.useCodepage = true;
load_btn.onRelease = function() {
var myVar:LoadVars = new LoadVars();
myVar.load("load_txt.txt");
myVar.onLoad = function(success:Boolean):Void {
if (success) {
load_txt.htmlText = this.load_txt;
trace("loaded");
} else {
trace("not loaded");
}
};
};
and this 1 is for special characters
Code:
//load vars onData you dont have to URL encode
var my_lv:LoadVars = new LoadVars();
my_lv.onData = function(src:String) {
if (src == undefined) {
trace("Error loading content.");
} else {
my_txt.text = src;
}
};
my_lv.load("my_txt.txt");
on the code that uses on data , you do NOT NEED to include my_txt= in the external txt file as the first line ..
so much more to type . but i think this will help you on your way , or atleast i hope it does .
i hope this helps you in your external txtFile quest .
Cheers M8
T
Last edited by timothye; 01-26-2006 at 04:54 PM.
I want to learn .
wannabe flasher [ Actionscript 2.0 ]
-
bringing external text
[QUOTE=estudioworks]Here is a .fla I put together a loooooooooooong time ago !!
Dear Estudioworks... your example may have put me on the right track but I still may not be naming things properly. Would you be willing to look at what I'm trying to do in context: http://www.teresajordan.id.au/painting/painting.htm (click posters & then the cathedral button.)
this is the code I've used so far
loadVariablesNum("text/enter.txt",0);
loadMovie("posterimages/harrass.jpg", picMc);
txtstageMc.gotoAndStop("harrass");
cathedralBu.onRelease = function() {
loadMovie("posterimages/cathedral.jpg", picMc);
txtstageMc.gotoAndStop("cathedral");
loadVariablesNum("text/enter.txt",0);
};
etc
-
Moderator
Make sure the text field you are trying to use is Dynamic, has an instance name, also put this in your text file before your text
Last edited by enpstudios; 01-26-2006 at 08:47 PM.
-
Hi estudioworks,
thanks so much for helping!
I have called the text field instance cathedralTxt
I have started the text file like this:-
<cathedralTxt
&content=etc>
(is this what you mean?) the html tags which don't show here
Where would I put the instance name (cathedralTxt) in the action script code below?
loadVariablesNum("text/enter.txt",0);
-
Moderator
You need to do this:
Code:
cathedralTxt.text = &content
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|