PDA

View Full Version : dynamic text in loaded movieclip


mrbrain
12-26-2004, 08:43 PM
I wrote this code

on (release) {
_root.tb1place.loadMovie("textbox.swf");
myData = new LoadVars();
myData.onLoad = function(){
_level0.tb1place.textarea.text = this.barz1;
trace(_level0.tb1place.textarea._width);

};
myData.load("barze.txt");
}


how can I put the text loaded into the textarea included in the loaded MC?
The above code does not work

farafiro
12-27-2004, 08:08 AM
try to change this_level0.tb1place.textarea.text = this.myData.barz1;if it didn't work, post the fla

mrbrain
12-27-2004, 08:39 AM
Sorry but it did not work.
these are the FLAs and the text file.
http://mrbrain.altervista.org/files.zip
Thanks for the help

farafiro
12-27-2004, 12:54 PM
wrong URL, it directed me to
http://home.altervista.org/site/

mrbrain
12-27-2004, 02:55 PM
URL was correct. please right click on it, copy link location and paste on the address bar.
Thanks for patience

farafiro
12-28-2004, 07:45 AM
okey, here you go
your problem is that u r adding a script to an instance where it's not in the same frame
so, u may do this or change your animation way
//the button's as
on (press) {
_root.tb1place.loadMovie("textbox.swf");
}
on (release) {
var myData:LoadVars = new LoadVars();
myData.load("barze.txt");
trace(_level0.tb1place.textarea.text);
_level0.doIt = true
}
//in the same frame where the buttons is
var doIt = false;
this.onEnterFrame = function() {
if (doIT && _level0.tb1place._currentframe>=_level0.tb1place._totalframes) {
myData.onLoad = function(done) {
if (done) {
tb1place.textarea.text = this.barz1;
}
};
}
};

mrbrain
12-28-2004, 12:30 PM
okey, here you go
your problem is that u r adding a script to an instance where it's not in the same frame
so, u may do this or change your animation way


Thanks. Now I pass the text to the MC in a variable, and when in the MC textarea is created, I give it the value of that variable. Now it works fine. Thanks for the help.

farafiro
12-28-2004, 12:48 PM
welcome
;)

mrbrain
12-28-2004, 02:29 PM
Now I can fetch variables values. I tried to do it with arrays. In the txt I wrote
foo[0]=aaa&foo[1]=bbb
but it did not work. Can u tell me why?


And when I get text from a variable, I can't display characters like and . How can I get them?

CyanBlue
12-28-2004, 02:36 PM
You cannot specify the array items in the external text file like that because Flash only recognize the external data as a string... You'll have to change it to be something like this and loop through the items when the data gets fully loaded...
foo0=aaa&foo1=bbb
As for the and ... Search the forum... There are many threads that deal the same problem... :)

mrbrain
12-28-2004, 03:50 PM
You cannot specify the array items in the external text file like that because Flash only recognize the external data as a string... You'll have to change it to be something like this and loop through the items when the data gets fully loaded...
foo0=aaa&foo1=bbb



EOF=0; //variable at end of txt file
barzellette = new Array();
for (i=0;EOF=0;i++) {
foo[i]=this.foo{i}; //this is the loadvars object
}


Please correct the red part. it must create a variable name at every iteration (foo1, foo2 etc)

CyanBlue
12-28-2004, 04:13 PM
You could try this...(I don't know what you meant by EOF though...)
Send out the total number from the text file like this...
foo0=aaa&foo1=bbb&total=2
and use that instead of the EOF...

for (var i = 0 ; i < parseInt(this.total) ; i++) {
foo[i] = this["foo" + i]; //this is the loadvars object
}

mrbrain
12-28-2004, 05:13 PM
it worked. thanks for help