Jump to content


Photo

Undefined text


  • Please log in to reply
11 replies to this topic

#1 Liesjuh

Liesjuh

    Young Padawan

  • Members
  • Pip
  • 26 posts

Posted 07 May 2006 - 06:06 AM

Didnt want to post here for some time, cuz I posted to much lately but I got another problem wich I need to get solved.
I've got some dynamic textboxes wich load .txt files. I've got a main content part wich works alright. Then I copied the code I used for that copied it in an other layer with an other dynamic textbox, changed the code a bit so it loads an other text wich workes also. But now comes the problem. I tried to copy the page to a third dynamic textbox, change it so it loads an other textfile, but now I get undefined in the textbox. This is the code I use:
nextup.html = true;
myLoadVar = new LoadVars();
myLoadVar.load("content/nextuptext.txt");
myLoadVar.onLoad = function(success){
	if (success == true){
		nextup.htmlText = myLoadVar.content;
	}
};
The txt file starts with content=
The dynamic text box is called nextup

This code works perfect with the other text boxes. I dont get whats wrong...

#2 Ding

Ding

    Young Padawan

  • Members
  • Pip
  • 7 posts
  • Location:Michigan

Posted 07 May 2006 - 08:58 AM

I'm pretty sure the only time you will get undefined in a text box is if the variable in the text file is not named content. Make sure you said content=this is my content. And that there is nothing else in the file. Hope this helps. ;)

#3 Liesjuh

Liesjuh

    Young Padawan

  • Members
  • Pip
  • 26 posts

Posted 07 May 2006 - 09:14 AM

I've treedouble checked that. I even changed the embed in all glyphs, changed it back to basic latin, changed everything about the code that says nextup or content, changed it back again.
I can change somethings and then it says _level0.nextup, maybe someone knows how to solve this?

#4 Ding

Ding

    Young Padawan

  • Members
  • Pip
  • 7 posts
  • Location:Michigan

Posted 07 May 2006 - 09:48 AM

Make sure you are not using any variables more than once. I tested your exact code and it worked fine for me. Declare a new LoadVars object for each text field (that) you are importing data into. Make sure the text field has the nextup instance name and has nothing set for the Var:. Not sure what else could be the problem, check that you have a text file in /content/nextuptext.txt.

#5 Liesjuh

Liesjuh

    Young Padawan

  • Members
  • Pip
  • 26 posts

Posted 07 May 2006 - 10:00 AM

Done all that. Still got undefined. Had nextup first in the Var bar, but that shouldnt matter cuz I did that in the content textbox too.

#6 Ding

Ding

    Young Padawan

  • Members
  • Pip
  • 7 posts
  • Location:Michigan

Posted 07 May 2006 - 10:06 AM

Try changing the if statement to

if (success == true){
		trace(myLoadVar.content);

And tell me what it puts in the Output panel.

And if possible could you post a zip of the files used?

Edited by Ding, 07 May 2006 - 10:07 AM.


#7 Liesjuh

Liesjuh

    Young Padawan

  • Members
  • Pip
  • 26 posts

Posted 07 May 2006 - 10:58 AM

Output: undefined

Send pm with zipfile

Edited by Liesjuh, 07 May 2006 - 11:07 AM.


#8 Ding

Ding

    Young Padawan

  • Members
  • Pip
  • 7 posts
  • Location:Michigan

Posted 07 May 2006 - 12:56 PM

As I said, you need seperate variable names for all your variables. You have two variables named myLoadVar. So change

System.useCodepage = true;
nextup.html = true;
myLoadVar = new LoadVars();
myLoadVar.load("content/nextuptext.txt");
myLoadVar.onLoad = function(success){
	if (success == true){
		trace(myLoadVar.content);
		nextup.htmlText = myLoadVar.content;
	}
};
to

System.useCodepage = true;
nextup.html = true;
myLoadVar2 = new LoadVars();
myLoadVar2.load("content/nextuptext.txt");
myLoadVar2.onLoad = function(success){
	if (success == true){
		nextup.htmlText = myLoadVar2.content;
	}
};
And it should work fine :).

Edited by Ding, 07 May 2006 - 12:58 PM.


#9 Liesjuh

Liesjuh

    Young Padawan

  • Members
  • Pip
  • 26 posts

Posted 07 May 2006 - 02:00 PM

Yes, it works.
Thank you so much :) :dance:

And since you have my fla do you know how to do that random quote? (Maybe to much to ask since you already done so much, but could try it anyway)

Just a thought, but how could it work for the news box with the same var and not for the nextup thing?

Edited by Liesjuh, 07 May 2006 - 02:04 PM.


#10 Ding

Ding

    Young Padawan

  • Members
  • Pip
  • 7 posts
  • Location:Michigan

Posted 07 May 2006 - 02:11 PM

Inseat of where you have
loadVariablesNum("content/quotes.txt",0);
newquote = random(numQuotes);
_root.myquote = eval("quote" +newquote+ "txt");

You should do something like

var quote;
var nRandom = Math.floor(Math.random()*4); //creates a random number 0-3
myLoadVar3 = new LoadVars();
myLoadVar3.load("content/quotes.txt"); //loads the variables inside quotes.txt
myLoadVar3.onLoad = function(success) {
	if(success)
	{
		quote = myLoadVar3["quote"+nRandom+"txt"];  //stores the variable quote with the myLoadVar3.quote(number)txt
		myquote.text = quote;  //sets the text field to the quote
	}
}

As for the news box and the nextup, I think it works because they are on different frames. When they are on the same frame the second declaration of the same variable erases the first one before it can load the text file. Atleast that's my theory :).

Edited by Ding, 07 May 2006 - 02:14 PM.


#11 Liesjuh

Liesjuh

    Young Padawan

  • Members
  • Pip
  • 26 posts

Posted 08 May 2006 - 07:46 AM

Man, i wish I was that good with flash... :love:
To bad I'm not... :(

So here are my new questions for this week ;) :

1. I've got a simple scrollbar with scroll-=1 and scroll+=1, but how do I get it to scroll when I push it for 5 sec or so. That I dont have to click the whole time.
2. I've got a textbox which has to contain a lot of text which has to be updated weekly. I need some sort of buttons wich lead to a specific part of the text. Like the to ^top buttons on websites. But like I sayd has to be edited weekly. How do I do this? Was thinkin of using <a href=#name> or sumting like that but that isnt possible in txt files.
3. How do I do that random stuf with images?

Thats it for now :P

Edited by Liesjuh, 08 May 2006 - 09:32 AM.


#12 Liesjuh

Liesjuh

    Young Padawan

  • Members
  • Pip
  • 26 posts

Posted 11 May 2006 - 08:53 AM

bump...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users