# Loading .txt in Flash



## Nummi_G4 (Mar 5, 2004)

I am getting this in the dynamic text field instead of the actual text file:

"_level0.stageContent.descriptionText"

The root flash file loads another flash file into a movie clip. The movie clip has the dynamic text field, which loads the text file. I'm guessing the load within a load is throwing me off.

In the root timeline, I have the action:

"loadVariables(description.txt, "_level0.stageContent.descriptionText");"

What am I doing wrong?!


Thanks.


----------



## octane (Mar 6, 2004)

Nummi_G4 said:
			
		

> What am I doing wrong?!.



I'd say it's because you're saying:



> loadVariables(description.txt, "_level0.stageContent.descriptionText");



When you should be saying:



> loadVariables(description.txt, _level0.stageContent.descriptionText);



The double-quotes is sending the dot-path as a literal string.

It certainly looks that way, but my ActionScript is -- as Steve Martin as Orin Scrivello said in Little Shop of Horrors: "all rusty 'n' dull!.."


----------



## Nummi_G4 (Mar 7, 2004)

I just found out that description.txt needs "". But I still get the same error.

Do I need to be using loadVariablesNum() or loadVariables() ?


----------



## Urbansory (Mar 7, 2004)

loadVariablesNum() specifies what level to load into, not into a movieclip.
So that textfield should have the same variable name as one of the variables in that file, considering it's formated correctly.

I haven't used a text file is some time, i prefer XML, so I can't help much on a standard text file, I actually forgot, and converted all my things to XMl and Perl.

Try... loading them into another level... then set it

loadVariablesNum("description.txt", 3);

_level0.stageContent.descriptionText = _level3.variableName;


----------



## Nummi_G4 (Mar 7, 2004)

Urbansory said:
			
		

> I haven't used a text file is some time, i prefer XML, so I can't help much on a standard text file, I actually forgot, and converted all my things to XMl and Perl.



Would XML be a better solution to this? Will I be able to load the xml file into a movie which in turn is being imported into another movie?


----------



## Urbansory (Mar 7, 2004)

first... why are you loading it that way? And if it loads from one to another, seems like you are basically passing variables from one location to anoother. Establish a destination for your data, then have it sent to the movieclip instead. Seem like you're making it more difficult than it needs to be.

What is the data? XML will work fine, just an easier/better way to handle data.


----------



## Nummi_G4 (Mar 7, 2004)

Urbansory said:
			
		

> first... why are you loading it that way? And if it loads from one to another, seems like you are basically passing variables from one location to anoother. Establish a destination for your data, then have it sent to the movieclip instead. Seem like you're making it more difficult than it needs to be.
> 
> What is the data? XML will work fine, just an easier/better way to handle data.



The way I described it might be making it sound complicated. 

The data is just plain text.

Maybe I should post some example files?


----------



## Urbansory (Mar 7, 2004)

yea, and the text file. It has to be formated a certain way for it to even work right. Check out some tutorials online, i'm sure there are a number of them.


----------



## Nummi_G4 (Mar 7, 2004)

If you open the "importMe.swf" file by itself, the *.txt loads. But when the "importMe.swf" file is imported into the "main.swf" file, the *.txt will not load.


----------



## Urbansory (Mar 7, 2004)

u must be using MX 2004, because they won't open with my "regular" MX, lol, i'll update someday, my clients still use Flash 5 or MX. But I see what u mean in the swf files.


----------



## Nummi_G4 (Mar 7, 2004)

The "regular" flash files have a "2" in the name. (mx2004 stinks )


----------



## Urbansory (Mar 8, 2004)

I see what you are doing...

It should be... loadVariables("theText.txt", this.stageContent);

Since you are moving this into the movieclip "stageContent" you need to refrence that when you load the text... so "this" makes it reference itself, loading that data into itself where the textfielf "stageContent" can be found. Thats the best way I can describe it.


----------



## Nummi_G4 (Mar 8, 2004)

Urbansory said:
			
		

> I see what you are doing...
> 
> It should be... loadVariables("theText.txt", this.stageContent);
> 
> Since you are moving this into the movieclip "stageContent" you need to refrence that when you load the text... so "this" makes it reference itself, loading that data into itself where the textfielf "stageContent" can be found. Thats the best way I can describe it.



Cool. That worked with the example I made. But I cannot apply it to my current design. I copied and pasted from the example, no luck. I even made a new document, it is IDENTICAL to the example, IT DOES NOT WORK. I spent an hour making sure it was the same. WTF? If I wasn't such a puss I would have pulled my hair out.


----------



## Urbansory (Mar 8, 2004)

well it's the same idea... as long as all your variables are the same and same relative location, it should work. So whats different? Is it nested within another movie? Use some trace commands to see what happens at a certain time, that will tell you where your code is and isn't working.


----------



## drustar (Mar 22, 2004)

It's probably better to use the new LoadVars object. You can load stuff much efficiently. If the file is no go - you can display an error message or something. I'll get back to you on a sample file.


----------

