Jump to content

php vars in flash


dowdie

Recommended Posts

I want to know how to use php variables within flashI have a flash video file which has a path to the .flv file i want to be able to change that path from the php filePHP$flv = newClientsflv.flv;FLASHvar nc:NetConnection = new NetConnection();nc.connect(null);var ns:NetStream = new NetStream(nc);theVideo.attachVideo(ns);ns.play($flv);

Link to comment
Share on other sites

Uhm... Maybe I'm old-school, but last i checked Flash and PHP generally don't work together that easily. their syntaxes are obviously very different, and Flash runs on the client side while PHP runs on the server. However i do recall hearing something about Flash having the ability to retreive data(as in, string data or XML data) from a server via some Flash form of AJAX object. What that is, or how you do that, I am not exactly sure. But it may give you something to look up on.

Link to comment
Share on other sites

You can use the getURL function in Actionscript to load an external URL. You can also use loadVariables, or there is also a built-in XML object you can use to get and read XML data. Check with getURL first, it's easy.

Link to comment
Share on other sites

You can use the getURL function in Actionscript to load an external URL. You can also use loadVariables, or there is also a built-in XML object you can use to get and read XML data. Check with getURL first, it's easy.
Thanks for the reply but those functions don't do what I want...All i want is for the client to be able to write the new flv filename in the php page so the flash can update auto. This way the client won't have to constantly open up the .fla and change the path to the .flv
Link to comment
Share on other sites

Yeah I know what you're saying. Those functions do exactly what you want. I used MovieClip.loadVariables today in 2 applications to do exactly that, load a filename from an external playlist.
Ok mate cheers, i'll take on your advise and give it a shot
Link to comment
Share on other sites

I got the variable from a external txt file but I'm not sure how to output it via ns.play() Any ideas here?flv="shefif.flv"var nc:NetConnection = new NetConnection();nc.connect(null);var ns:NetStream = new NetStream(nc);this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());target_mc.loadVariables("params.txt");function checkParamsLoaded() { if (target_mc.flv == undefined) { trace("not yet."); } else { trace("finished loading. killing interval."); trace("-------------"); for (i in target_mc) { trace(i+": "+target_mc); } trace("-------------"); clearInterval(param_interval); }}var param_interval = setInterval(checkParamsLoaded, 100);theVideo.attachVideo(ns);ns.play(target_mc.flv); trace(target_mc.flv);

Link to comment
Share on other sites

I've trimmed the code down a bit and i can get it to trace the path "sherif.flv" it still wont output it though...var nc:NetConnection = new NetConnection();nc.connect(null);var ns:NetStream = new NetStream(nc);this.createEmptyMovieClip("target_mc",this.getNextHighestDepth());target_mc.loadVariables("params.txt");function checkParamsLoaded() { if (target_mc.flv == undefined) { trace("not yet."); } else { for (i in target_mc) { trace(target_mc.flv); theVideo.attachVideo(ns); ns.play(target_mc.flv); } clearInterval(param_interval); }}var param_interval = setInterval(checkParamsLoaded, 100);

I got the variable from a external txt file but I'm not sure how to output it via ns.play() Any ideas here?flv="shefif.flv"var nc:NetConnection = new NetConnection();nc.connect(null);var ns:NetStream = new NetStream(nc);this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());target_mc.loadVariables("params.txt");function checkParamsLoaded() { if (target_mc.flv == undefined) { trace("not yet."); } else { trace("finished loading. killing interval."); trace("-------------"); for (i in target_mc) { trace(i+": "+target_mc); } trace("-------------"); clearInterval(param_interval); }}var param_interval = setInterval(checkParamsLoaded, 100);theVideo.attachVideo(ns);ns.play(target_mc.flv); trace(target_mc.flv);
Link to comment
Share on other sites

I'm not sure what attachVideo does and I don't have the Flash software where I am today, so I can't read the help on it. But you're passing a netStream object to it, I'm not sure if that's correct or not. I'm not sure if FLV files work the same as SWF files (I've built the players for MP3 and SWF, I still need to do the one for FLV next week), but for the SWF I used MovieClip.loadMovie to play it.Anyway, I will be doing this same thing myself next week so I'll have some more info then if you don't get it figured out by then.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...