PDA

View Full Version : dynamic text



chris9902
May 30th, 2003, 06:28 AM
ok how to i make a button so when i press it, it loads an external .txt files in my text box in flash

pom
May 30th, 2003, 10:51 AM
There are tutes about text loadings here :)

chris9902
May 30th, 2003, 11:16 AM
were can you post one please

thoriphes
May 30th, 2003, 11:40 AM
here's the link :):
http://www.kirupaforum.com/forums/search.php?s=

kode
May 30th, 2003, 11:41 AM
http://www.kirupa.com/developer/mx/dynamic_scroller.htm

;)

lunatic
May 30th, 2003, 11:44 AM
I'm kind of still new at this myself but I'm pretty sure all you have to do is put a name for the variable (Var:) in the dynamic text properties box (NOT the instance name), for example: textField

Then on your button you say something like:

on (release){
loadVariables("external_text.txt", textField);}

This says to load the text file called "external_text" into the dynamic text box you created that you called "textField".

Hope this helps!

chris9902
May 30th, 2003, 01:47 PM
i tested that but it did not work

am i doing it wrong

Danno
May 30th, 2003, 02:04 PM
upload your .fla file... then we can check to see if you have everything correct

meisje
June 2nd, 2003, 06:08 AM
i'm not the original poster but i can't get lunatic's script to work either..

.zip attached

on another note, while searching for an answer i read, io have no idea whether it's relevant:

http://www.macromedia.com/support/flash/ts/documents/dynamic_text_scrollmx.htm

"Loading text into a dynamic text field in Flash MX is done differently. In Flash MX text is it's own ActionScript object, so a text field can have both a variable name and an instance name (see Flash MX Text fields have instance names and variable names, TechNote 16184, for details). Flash MX also introduces a more sophisticated action for loading external data called loadVars(). These two methods are combined to load external text to a scrolling text field created using the ScrollBar component."

meisje
June 2nd, 2003, 08:20 AM
on (release) {
loadText = new loadVars();
loadText.load("kirupa.txt");
loadText.onLoad = function() {
_root.textField = loadText;
};
}

this seems to work..

anyone any tips how how to get text not show up with %20 as spaces? i tried unicode and a several other formats..

meisje

kode
June 2nd, 2003, 08:23 AM
_root.textField = unescape(loadText);

meisje
June 2nd, 2003, 08:31 AM
thanks kax :toad:

kode
June 2nd, 2003, 08:33 AM
you're welcome. ;)

meisje
June 2nd, 2003, 09:31 AM
one more issue, a loaded text is always trailed by the following:

=&onLoad=[type Function]

(major thunderstorm is coming turning of puter for the while)

kode
June 2nd, 2003, 09:42 AM
if you're still using the same script you posted above, try adding this line of code:

ASSetPropFlags(loadText, "onLoad", 1);
however, i encourage you to follow the tutorial here at kirupa.com
http://www.kirupa.com/developer/mx/dynamic_scroller.htm

meisje
June 2nd, 2003, 10:31 AM
thanks for the encouragement kax :) i have done the tutorial now, please correct me if i'm wrong:

- - -

scene: button and dynamic textfield.

name the textfield "textField" in the instance name box (this time NOT the var name!!).

on the button hang this script:
on (release) {
loadText = new loadVars();
loadText.load("kirupa.txt");
loadText.onLoad = function() {
textField.text = this.kirupatext;
};
}


then make a textfile and put:
kirupatext=
followed directly by the rest of your text.

save the file as:
kirupa.txt
for loading other text just copy the code and only change "kirupa.txt" to whatever you want loaded

voilá kirupá :) thanks again kax

kode
June 2nd, 2003, 10:38 AM
no problem, meisje. =)

by the way, i think you should read this technote. i'm telling you this because of the instance name you used for the TextField. ;)
http://www.macromedia.com/support/flash/ts/documents/naming_strategies.htm

meisje
June 2nd, 2003, 10:46 AM
information assimilated :thumb:

and this one is for you :flower: later kax!

kode
June 2nd, 2003, 10:51 AM
:P

see ya! ;)

Felipe Bastos
June 3rd, 2003, 05:47 PM
I`m trying to use the code creating a function called "loadNote" but the text is not loading


// define the function loadNote
function loadNote (idnote) {
_root.attachnote.attachMovie("mcnote", "mcnote", 1);
_root.attachnote.posY = 300;
loadText = new LoadVars();
loadText.load(idnote);
loadText.onLoad = function () {
_root.attachnote.mcnote.loadtxt = loadText;
trace = "function loadNote ok";
}
}

on my btn01 action I wrote:


on(release) {
// call the function loadNote on stage
_root.loadNote("cap02/notes/note" + "01" + ".txt");
}

The attach action is ok but the text is not loading inside mcnote, in textfield "loadtxt".

Can some help me? :)
Thanks

Felipe Bastos
June 5th, 2003, 01:25 AM
Hey
Is there anyone?
Please?

:(

meisje
June 5th, 2003, 03:02 AM
hallo van Basten

Basten as in MARCO VAN BASTEN!!!!!!!!!!!!!!!! ? :)

try this:

script for the frame:

loadLetter = function (letterName) {
loadText = new loadVars();
loadText.load(letterName);
loadText.onLoad = function() {
_root.veld.text = this.kirupatext;
};
};

script for button:

on (release) {
loadLetter("kirupa1.txt")
}

hope this what you mean, meisje

Felipe Bastos
June 5th, 2003, 01:41 PM
Let me explain it better.

I`m working on a cd-rom project. There are 13 chapters and each one has complementary text. This text is called by clicking an icon besides the word. In some chapters there are more than 50 icons. By clicking on them I want to access the function "loadNote"

loadNote = function(idnote) {
loadText = new LoadVars();
loadText.load(idnote);
loadText.onLoad = function () {
// attach the mcnote into attachnote.
_root.attachnote.attachMovie("mcnote", "mcnote", 1);
// load the var loadText into "loadtxt"
_root.attachnote.mcnote.loadtxt = this.note;
// send attachnote to Y position = 300
_root.attachnote.posY = 300;
}
}

script for the button:

on(release) {
// call function "loadNote" and set the parameter idnote.
// this way I would only change the number of the file for each button in the same chapter!!!
_root.loadNote("cap02/notes/note" + "01" +".txt");
}

Maybe I`m doing something wrong with the file.txt.
Do I have to put the word "note" before the text?
I`m writing the file.txt with simple text, a mac text editor.

Thanks
Van Basten comes from my last name "Bastos" !!! :P

meisje
June 5th, 2003, 02:02 PM
maybe stupid question but do you have "loadtxt=" (w/o the quotations) at the beginning in the file.txt? i don't know whether its loadtxt or any of the other variables.. i always try them all out in the hope that it works :)

bastos cigarette wrapping is the best and they are from belgium :) i guess that like saying you are from argentina here in holland.. something like that :beam:

Felipe Bastos
June 5th, 2003, 02:02 PM
I`ve done some upgrade so the mc attachnote would deslocate depending on the final loadtxt height. Here it`s

loadNote = function(idnote) {
loadText = new LoadVars();
loadText.load(idnote);
loadText.onLoad = function () {
_root.attachnote.attachMovie("mcnote", "mcnote", 1);
_root.attachnote.mcnote.loadtxt = this.note;
_root.attachnote.posY = 360 - _root.attachnote.mcnote.loadtxt._height;
}
}

all the code is working fine except the text that is not being loaded!

no, before the text i didint use the " ".

Felipe Bastos
June 6th, 2003, 10:59 AM
:( I really need some help here so I can have a progress on my project.
The deadline is next Tuesday and I`ve done all the tests but the txt file is not being loaded. Can I put the txt file in another folder?.. cause all my text files path is like this:/chapterX/notes/noteX.txt.

Please, please :)

Felipe Bastos
June 6th, 2003, 01:19 PM
I was checking the debbuger and found out that the text is being loaded.
The problem is that is not being displayed inside the textfield "notetxt".
I captured some screen shots..
Please, take a look at them!

This is the actual as code for the first frame:

function loadNote(idnote) {
loadText = new LoadVars();
loadText.load(idnote);
loadText.onLoad = function () {
_root.attachnote.attachMovie("mcnote", "mcnote", 1);
_root.attachnote.mcnote.notetxt = this.note;
_root.attachnote.posY = 360;
}
}

This is the as code attached to the btn:

on(release) {
_root.loadNote("cap01/notes/note" + "01" + ".txt");
}

Thanks! :)

kode
June 6th, 2003, 07:30 PM
maybe...

_root.attachnote.mcnote.notetxt.text = this.note;
??

and just in case, the .txt file should read something like this...

note=your text here&

Felipe Bastos
June 6th, 2003, 07:47 PM
LOVE YOU Kax!:love:
Finally!!! I`m so happy.
But this is not the end.
I`ll prepair a special fla to post it here soon.
Now the problem is that, my dynamic textbox is set to multline, but when it load the filex.txt, it keeps showing the first line of text. It does not not fit the text lengh. I set the border to check this. What should I do?

Thanks again!
so glad!

kode
June 6th, 2003, 08:07 PM
are you sure that the line type is set to multiline, and not multiline no wrap?

i make that mistake all the time. :P

Felipe Bastos
June 7th, 2003, 02:11 AM
I tried both but they didnt work! :(
Would it be better if this textfield were created dynamically, using AS?

Felipe Bastos
June 7th, 2003, 11:04 AM
I created a new textfield, set to multiline, bla bla, and it continues to display only the first line of text. I can`t understand what is happening! Did I miss something?!! :?

kode
June 7th, 2003, 11:11 AM
i don't feel like guessing... attach your .fla and .txt files. ;)

Felipe Bastos
June 7th, 2003, 11:56 AM
In order to function properly I need to send other files, so u can load external swf and click on the btn to load the txt file. But the files exceed the maximum file size. Could I send it to your e-mail? Do u work with win or mac? cause I use stuff it...

kode
June 7th, 2003, 12:06 PM
win

*****@msn.com

;)

kode
June 7th, 2003, 02:39 PM
ok... set its autoSize property to true. =)

notetxt.autoSize = true;

Felipe Bastos
June 7th, 2003, 04:14 PM
uhuuuu!
Great! Working fine!.
You are being very helpfull!
Thanks a lot! :)

Could you give me your opinion about the interface?
Please, feel free to point what u think is wrong or that could get better!

Would u mind helping me with a little other questions?

Thanks again

kode
June 7th, 2003, 04:29 PM
nope, i don't mind at all. if i know the answer, why shouldn't i help you? and if i don't, i'll try to figure it out. ;)

and i really like the interface as is. :)

Felipe Bastos
June 7th, 2003, 04:43 PM
:):):):):)

kode
June 7th, 2003, 05:00 PM
and the question is... ? :P

chris9902
June 7th, 2003, 05:02 PM
try this

make a movie with 3 buttons (1,2 and 3)

for each button you need a .txt file.

now on each button add these actions


on (release) {
loadText = new loadVars();
loadText.load("NAME OF YOU TEXT FILE.txt");
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.myNews;
}
};
}


now call your dyanamic text box "newsBox" [no ""]

and that is it, save the .fla, .swf and the 3 different .txt files in the same folder. (very important:) )

here is a winzip file you you to look at

============
be warned it is a whole 6kb:smirk:
============

chris9902
June 7th, 2003, 05:13 PM
i have just found my fault

in the text files you MUST add
myNews= on the first line

then there it is:trout:

chris9902
June 7th, 2003, 05:16 PM
let me explain

the code is this

on (release) {
loadText = new loadVars();
loadText.load("NAME OF YOU TEXT FILE.txt");
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.myNews;
}
};
}


the part you need is

newsBox.htmlText = this.myNews;

the part that says

myNews

you can change this to anything you want.

this is what you add to the start of the text files

so if you change it to



newsBox.htmlText = this.chris9902;

the start of you text file would start

chris9902=

hope that help

i will wirte a full tutorial when i get some time:)