|
-
using txt files in flash
hi, this is a double question.
1. i've used this code to import txt files into flash in flash mx with no problems. now i'm using flash 8 and i am having problems with it. here it is.
System.useCodepage=true;
contact.html=true;
contact.wordWrap=true;
myLoadVar = new LoadVars ();
myLoadVar.load("contact.txt");
myLoadVar.onLoad = function (success){
if (success == true) {
contact.htmlText=myLoadVar.myText;
}
}
i don't know enough actionscript to break this down, it was given to me and the only thing i know how to edit is the name of the text file and the instance of the text box to load the text into. i saved the .txt as unicode but still no dice. i get the message "undefined" in the box when i load the swf.
what am i doing wrong.
2. i am using the UIscrollbar component with the dynamic text box and it works great when there is text that needs to be scrolled but when there is only one or two lines i only get the bar with no arrows at the top or bottom and it looks crappy. i would like to see the whole thing even if they will be inactive, how do i do this?
thanks
jeremy boyd
-
Senior Member
us a
loadVariablesNum("myfile.txt", box)
box being a dynamic text field. i'm not 100% certain, but i think that is how it goes. make sure your text file is in the same directory first.
Xero Patience Studios
Web Design
Software Development
Graphic/Logo Design
-
not quite
i tried this but it opened up a seperate explorer window with the text in it.
weird
-
Senior Member
try this.
PHP Code:
//Load the text.
myLoadVars = new LoadVars();
myLoadVars.load("contact.txt");
myloadVars.onLoad = function(success) {
if (success) {
contact.html = true;
contact.htmlText = this.src;//put "src=" without
//the quotes as the very first line in the contact.txt file
} else {
trace("Could not load text file.");
}
};
the scrollbar will only show arrows when there is something to scroll
If you don't think you're going to like the answer, then don't ask the question.
-
still nuthin
i followed the instructions but i don't even get the error message in the text box, nothing comes up. i'm at a loss, is flash 8 that different than mx that a simple actionscript won't translate? i've tried many of the tutorials on the site but none of them yield any results. thanks for helping, i'll keep at it.
jeremy boyd
-
Senior Member
sorry, it was a bit off...
Code:
loadVariablesNum("Topic.txt",level);
then in the Topic.txt, you have to start it with a
Code:
&topic1= What ever you want to put here
topic1 being the name of the dynamic text box
Xero Patience Studios
Web Design
Software Development
Graphic/Logo Design
-
Senior Member
Hi thebone, can you post the fla and the textfile?
If you don't think you're going to like the answer, then don't ask the question.
-
Flash Gordon
And just btw...
If you set a textboxs text via the variable name, the scrollbars won't work at all 
You need to set it via TextFieldInstanceName.htmlText =
My letters on the F1 key have faded, how are yours today?
-
Here is how you do it
Ok! This is really easier than it seems.
Let's call your text file text.txt.
Make an actions layer and on the same frame where your dynamic text box is located type in the actions area:
LoadVariables("text.txt", this);
stop();
Make sure your text document is saved in the same folder as your fla document.
Give the dynamic text box a name, for example "news"
Inside your text document type
&news= blah blah blah
The blah blah blah should now show up on your screen, but you probably want your dynamic text box settings to be multiline and maybe to render html.
(the reason it was popping up in a new window before was because of the LoadVariablesNum)
Hope this helps!
p.s. Sometimes use the actionscript assist or target option to make sure that your target paths are correct eg .this or _root. or .parent, etc
Last edited by lameloy; 02-16-2006 at 03:27 PM.
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
|