PDA

View Full Version : dynamically load movie&text from php


monkeybrainz
07-09-2003, 06:47 AM
hey fellas!

how do you load a swf depending on what link you click? i have a flash movie called tutorialPlayer.swf within which i'd like to load the appropriate flash tutorial, depending on which link you click from an HTML page. here's the link:<a href="tutorialLoader.php?tut=addEmail">Add Email Account</a>in tutorialLoader.php i've embedded the tutorialPlayer.swf which when loaded, tries to "loadMovie" the right tutorial:this.loadVariables("tutorialLoader.php");
loadMovie([tut+".swf"], "pm");
i'm definitely missing something here! it works fine with the swf hard coded in there....

thanks for any advice you can offer!!
-mb

vosgien
07-09-2003, 04:29 PM
Hi,
had another look - can you tell me what the [ ] and "pm" are for, loadMovie works like this

loadMovie(tut + "swf", 0);


or am I missing something.

It might be an idea to give your variable tut time to load, tutorialPlayer.swf may be calling the loadMovie action to soon,if you are using MX you would be better with new Loadvars I think.


*edit* the other thing that just crossed my mind is that if you have php file opening your tutorialPlayer.swf, which is in turn opening a movie based on variables loaded, you may need to give it a absolute path
Vosgien

monkeybrainz
07-09-2003, 04:58 PM
yeah i probably should have posted more code. the "pm" movie is just an empty movieClip (that i call positionMe) i load stuff into. the [tut+".swf"] is to take a variable: tut, and append ".swf" to the end of it so flash sees: addEmail.swf. i use it in other places in flash but wasn't sure if it would work here.if you have php file opening your tutorialPlayer.swf, which is in turn opening a movie based on variables loaded, you may need to give it a absolute pathIt might be an idea to give your variable tut time to load, tutorialPlayer.swf may be calling the loadMovie action to soon,if you are using MX you would be better with new Loadvars I think.
i am starting to think you may be right on both accounts -> but i just got flash MX :D and don't know how to use the Loadvars yet :rolleyes: . will it work here?

vosgien
07-09-2003, 05:10 PM
Hi,
yes it will, try

myVars= new LoadVars();
myVars.load("tutorialLoader.php");
myVars.onLoad = function(success)
{
//check to make sure loaded
if(success)
{
trace(success)
loadMovie(tut + "swf")
}
}

That was pretty fast so I won't guarantee the syntax, if it doesn't work do a search for new LoadVars and cyanblue in the name box
He understands new Loadvars much better than I and he has posted a fairly simple fla which explains it a whole lot better than I can.
Hope it helps

Vosgien

monkeybrainz
07-09-2003, 05:46 PM
holy cow!!! it works!! thanks for your help vosgien i don't think i'll be using loadVariables much more but this is how i solved this:

i needed to let the flash movie know what .swf to load in depending on what HTML link i click on so when you click on <a href="tutorialLoader.php?tut=addEmail">Add Email Account</a> it takes you to tutorialLoader.php where i've appended the variable to be passed to flash!: <body>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="600">
<?php
echo "<param name=\"movie\" value=\"turorialPlayer.swf?tut=$tut\">";
?>
<param name="quality" value="high"><param name="LOOP" value="false">
<embed src="turorialPlayerDynamic.swf" width="800" height="600" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
</body> and voila! the variable "tut" is on the root level of the flash movie. now flash knows what .swf to import!

:D

vosgien
07-09-2003, 05:49 PM
Glad it helped !

Vosgien