;

PDA

Click to See Complete Forum and Search --> : Client Control


talytech
12-15-2007, 10:32 AM
Is there a way to give the end user control over the text in a dynamic text box? My client wants to be able to update their own text. I can't figure out how to load text without it being in HTML. Is it a way to do that?

blanius
12-15-2007, 06:21 PM
yes I do this all the time.

The way I do it is just a simple text file. lets say it's aboutus.txt for an about us page

then when I want to load that into say a content pane I use LoadVars

content=new LoadVars();

then using the onData function I get the raw file contents

content.onData=function(src){
contentpane1.setContent(0,src,1,2);
}

talytech
12-16-2007, 02:39 PM
yes I do this all the time.

The way I do it is just a simple text file. lets say it's aboutus.txt for an about us page

then when I want to load that into say a content pane I use LoadVars

content=new LoadVars();

then using the onData function I get the raw file contents

content.onData=function(src){
contentpane1.setContent(0,src,1,2);
}

Thank you ... but I don't know what I'm doing wrong. My text file is welcome.txt. On my first frame I have a contentpanel object. I put your code in the first frame replacing src with welcome.txt. Like this:

content=new LoadVars();

content.onData=function(welcome){
contentpane1.setContent(0,welcome,1,2);
}

blanius
12-16-2007, 08:06 PM
You have to load it.... Sorry I left that out.

content.load("welcome.txt");

talytech
12-16-2007, 08:37 PM
thanks blanius. it worked. is it a way I can make that text auto scroll like a news ticker? I've been searching for that effect.

blanius
12-16-2007, 09:18 PM
Not in a content pane I don't think.

Once you have the text in the flash you can do whatever you want with it.

Try something like this

myArray=welcome.split("\n");

function showWelcome() {
txt1.text=""
if(count >= maxCount) {
clearInterval(intervalId);
}
for (x=count;x<=count+10;x++){
txt1.text+=myArray[x];
}
count++
}

maxCount=myArray.length
intervalId = setInterval(this, "showWelcome", 1000);



You probably could make that work with a content pane after all

talytech
12-16-2007, 09:19 PM
thanks blanius. it worked. is it a way I can make that text auto scroll like a news ticker? I've been searching for that effect.

hey blanius, will that code work with a dynamic text box? I want the background to be transparent and I can't acheive that with a contentpanel. At least I don't think I can. but the text box object gives me that option so I'd rather use the text box. I tried the code but it returns an error. this is what i have:

content=new LoadVars();

content.onData=function(src){
text.setContent(0,src,1,2);
}

content.load("welcome.txt")


this is what the text box displays: _level0.mc9.text

blanius
12-16-2007, 09:24 PM
That's what I assumed named txt1 try it. I just pulled this code from a test project so it should work.

talytech
12-16-2007, 11:19 PM
Not in a content pane I don't think.

Once you have the text in the flash you can do whatever you want with it.

Try something like this

myArray=welcome.split("\n");

function showWelcome() {
txt1.text=""
if(count >= maxCount) {
clearInterval(intervalId);
}
for (x=count;x<=count+10;x++){
txt1.text+=myArray[x];
}
count++
}

maxCount=myArray.length
intervalId = setInterval(this, "showWelcome", 1000);



You probably could make that work with a content pane after all

what is txt1.text? my txt object is named text and my variable is named text. Nothing is named txt1. And do I put this code on the same frame as the dynamic text box?

blanius
12-19-2007, 08:27 AM
So change txt1 to whatever it's an example only. I would not reccomend naming a text field to the name 'text' the default names are txt1, txt2 etc so that was what I used in the example.

Put the code in the OnData is fine as you don't want to execute it until you have the text from your file loaded in.

talytech
12-28-2007, 10:37 AM
Hi Bret,
I've been trying for a week now to get the data from my text file loaded into my dynamic text box and to scroll. I can't get it to work. Can you please tell me what I'm doing wrong ... I give up. Here's what I have:

content=new LoadVars();

content.onData=function(welcome){
text.setContent(0,welcome,1,2);
}

content.load("welcome.txt")

myArray=welcome.split("\n");

function showWelcome() {
welcome.text=""
if(count >= maxCount) {
clearInterval(intervalId);
}
for (x=count;x<=count+10;x++){
welcome.text+=myArray[x];
}
count++
}

maxCount=myArray.length
intervalId = setInterval(this, "showWelcome", 1000);

talytech
12-28-2007, 01:14 PM
Can anyone help me ... this is driving me crazy. I've searched through several pages on the forum for how to use the LoadVars to import a text file and I can't seem to get my function to work. I don't know what I'm doing wrong. I have a text file (welcome.txt) that simply reads: My name is talytech. On frame 2 of my KoolMoves movie I have a dynamic text box named welcome and the variable name is welcome. I put the following AS code on frame 2:

content=new LoadVars();

content.onData=function(welcome){
this.welcome.setContent(0,welcome,1,2);
}

content.load("welcome.txt");

that code returns the following in my dynamic text box: _level0.welcome

I can't figure it out. Why won't it display what's in my text file? Please somebody help me ... I'm running out of time.

blanius
12-28-2007, 11:56 PM
You're almost there.
First off if you want to load as a variable you must format the text as a variable so your text file should be

&welcome=my name is Talytech

content=new LoadVars();

content.onLoad(success){
if (success){
contentpane1.setContent(0,this.welcome,1,2);
}
}

content.load("welcome.txt")



You use onData only if you want to access the raw data

talytech
12-29-2007, 03:30 PM
thanks Blanius. But someone else assisted me. This is the code I used:

var R;
//
res=new LoadVars();
res.load("welcome.txt");

res.onData=function(info){
if (info==undefined){
R="Loading failed";
}else{
R=info;
}
txt1.text=R;
}

blanius
12-29-2007, 08:39 PM
That's actually the way I do it on my sites. But I keep it shorter

res.onData=function(src){
if (src==undefined){
txt1.text="data not loaded";
}else{
txt1.text=src;
}