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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loadMovie and loadVars problems! 1

Status
Not open for further replies.

MJB3K

Programmer
Jul 16, 2004
524
GB
Hi, i have a movie (home.swf) that has a loadVars() call on it to load news into the home.swf. when viewed normally it loads the news into the home.swf.

BUT, when i load the home.swf into another movie, the loadVars() stop working?

any ideas??

also: if i have my php code as:

Code:
$q = mysql_query("SELECT title, news, subDate FROM gr_news WHERE view = 'yes'") or die("news=".mysql_error());
	while(list($t,$n,$sd) = mysql_fetch_row($q)){
		echo "news=<font color='#99FF00'><b>$t</b><br>-$sd</font><br><br>$n<br><br>";
	}

it loads it into the flash movie but displays as:

news=something

news=someting?

why is it doing that and if i add a '&' before the news (&news) it only returns one result?

please help me! :)


Regards,

Martin

Gaming Help And Info:
 
It is only returning one result because you are only producing one variable in your PHP. ASP is my language so I can't really help you with your PHP, but what I can tell you is that the PHP page needs to create unique name/value pairs.

So if you have multiple "news" items each specific news item must have it's own variable. (ie: news1, news2, news3, etc...) Anything you want to be seperate must have a unique variable name... OR ... you must completely format the PHP "news" variable (with all of the news items in it) using HTML.

The output of your PHP page (if you view it in the browser) should be something like this:

Code:
news=<font color'#99ff00'><b>MY Title</b><br>This is the news story</font>
&news2=<font color'#99ff00'><b>MY Title</b><br>This is the news story</font>

Then in Flash you would refer to each item uniquely (if your text box has the instance name "news"):

Code:
myLv = new LoadVars();
myLv.onLoad = function(success){
	if (success){
		news.html = true;
		news.htmlText = myLv.news;
		news.htmlText = news.htmlText + myLv.news2;
	}
}

myLv.load("yourpage.php");
Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
yea but if im doing it dynamicly, i cant keep editing the .fla to update for the news!

is there anyway of telling flash how many news items there are and then joing them together in the flash movie?

thanx for your help!

Regards,

Martin

Gaming Help And Info:
 
Sure. One way would be to feed in a number from your PHP using the same loadVars mechanism you are using now. Like I said I can't tell you how to code the PHP, but what you want to do is get the number of records in the set you return from MySQL and add it to the variable string. PHP output would be something like this:

Code:
numStories=5&news1=blabhabhaba&news2=blahblahblah

Then you would just add a while function to your loadVars().

Code:
myLv = new LoadVars();
myLv.onLoad = function(success){
    i=1;
    if (success){
       while(i<=myLV.numStories){
           news.html = true;
           news.htmlText = news.htmlText + myLv.news[i];
           i++;
       }
    }
}

That's not tested but it would be something like that.

There are some other ways you could accomplish it but that is probably the easiest.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
i found out a way of doing it.

all i did was print the &news= first then made a string of news from a query and joined it together!!

another way!

thanx for your help!

have a star ;)


Regards,

Martin

Gaming Help And Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top