Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LoadVars() problem

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
This is my scenario:-

I have the main page, ie main.html which has a main menu embedded in it, and in the main menu, I have a button called News from which I load an asp page, news.asp, and populate some text fields which I have on the news.swf. However, these fields are not showing up. I have done some testing to check wether the asp is loading, and I am sure it is since it is going to the appropriate frame, so the problem must be either with the asp or else with the variables. Here is the code I have in the first frame of the news.fla file:-

stop();
myVars = new LoadVars();
myVars.load("data/news.asp?cachebuster="+getTimer());
myVars.onLoad = function(success) {
if (success) {
_root.NewsTit1.variable = "_root.myVars.news1";
_root.NewsTit2.variable = "_root.myVars.news2";
gotoAndPlay(5);
} else {
trace("not loaded");
}
};

and here is the contents of the asp file, which is like a text file with an asp extension:-

news1=This is the first news article, it has plenty of text. It relates to the setting up of voices, advertising and PR. Lots of text to go hear.. We need enough for the scroll bar.Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exercitation ulliam corper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem veleum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel willum lunombro dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

&news2=This is the second articleIt has planty of text which you can add to!!!Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exercitation ulliam corper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem veleum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel willum lunombro dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

Can you tell me what am I doing wrong please?

Thanks for your help and time.

Johann
 
It looks like these lines are at fault.

_root.NewsTit1.variable = "_root.myVars.news1";
_root.NewsTit2.variable = "_root.myVars.news2";

Try this instead - you don't need to reference the _root path because the variables coming into loadVars are local to that object and loose the quotes as then you're just telling Flash that the value is a string:

_root.NewsTit1.variable = this.news1;
_root.NewsTit2.variable = this.news2;
 
The variable should not be set in the textfield's properties and the format should be...

_level0.my_textfield.text = this.variable; Regards,

oldman3.gif
 
Hi oldnewbie,

you mean like this?

_level0.NewsTit1.text = this.news1;
_level0.NewsTit2.text = this.news2;

where NewsTit is the name of my textfield and news is the name of the variable.

Still not working
 
You sure you've cleared the variable in the Variable box of the textfield's properties?

You don't get a "not loaded" message (your trace)?

Is the color of your text not the same as the background of your textfields?

Your textfields are right on stage? No nested mc?

No mask envolved?

Is your text html formated?

Is the font used, standard?

Have you tried embedding all characters?

Lastly, what if you forget the LoadVars() function for the moment and try...

_level0.NewsTit1.text = "This is a text test!";

... Does it show up? Regards,

oldman3.gif
 
Hi Oldnewbie,

I solved it. I was not loading the variables in frame 5, that is why they were not showing.

Thanks for your time and help mate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top