greens85 Posted April 11, 2008 Share Posted April 11, 2008 Hi All, I have a situation where i have some PHP code that displays images of 3 fruits, the order of these fruits are randomised through a mySQL database. This works perfectly fine, the problem i have is that i want to pass these images to Flash. I have looked at a number of tutorials but none of them seems to show me how to do it. Could anyone please advise me on how to do this? PHP Code: <?php //Connecting to the database $connection = mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db('mydb', $connection) or die(mysql_error()); $fruit1 = "<img src=\"/images/fruitimages/Apple.gif\"border=\"0\""; $fruit2 = "<img src=\"/images/fruitimages/Orange.gif\"border=\"0\""; $fruit3 = Pear; $fruit4 = Banana; $fruit5 = Peach; $fruit6 = Cherry; $fruit7 = "<img src=\"/images/fruitimages/Strawberry.gif\"border=\"0\""; $fruit8 = Grape; $fruit9 = Blackberry; $rq="SELECT * FROM symbols ORDER BY RAND() LIMIT 1"; $result= mysql_query ($rq) or die ("Select impossible"); $data=mysql_fetch_array($result); $sym1=$data['sym1']; $sym2=$data['sym2']; $sym3=$data['sym3']; $id=$data['id']; //Delete the row after it has been selected $sql = "DELETE FROM symbols WHERE id='$id'"; $result = mysql_query($sql); //Checking what sym1 is equal to and display the appropriate fruit if($sym1=='1'){echo $fruit1;} if($sym1=='2'){echo $fruit2;} if($sym1=='3'){echo $fruit3;} if($sym1=='4'){echo $fruit4;} if($sym1=='5'){echo $fruit5;} if($sym1=='6'){echo $fruit6;} if($sym1=='7'){echo $fruit7;} if($sym1=='8'){echo $fruit8;} if($sym1=='9'){echo $fruit9;} echo '<br/>'; echo '<br/>'; //Checking what sym2 is equal to and display the appropriate fruit if($sym2=='1'){echo $fruit1;} if($sym2=='2'){echo $fruit2;} if($sym2=='3'){echo $fruit3;} if($sym2=='4'){echo $fruit4;} if($sym2=='5'){echo $fruit5;} if($sym2=='6'){echo $fruit6;} if($sym2=='7'){echo $fruit7;} if($sym2=='8'){echo $fruit8;} if($sym2=='9'){echo $fruit9;} echo '<br/>'; echo '<br/>'; //Checking what sym3 is equal to and display the appropriate fruit if($sym3=='1'){echo $fruit1;} if($sym3=='2'){echo $fruit2;} if($sym3=='3'){echo $fruit3;} if($sym3=='4'){echo $fruit4;} if($sym3=='5'){echo $fruit5;} if($sym3=='6'){echo $fruit6;} if($sym3=='7'){echo $fruit7;} if($sym3=='8'){echo $fruit8;} if($sym3=='9'){echo $fruit9;} ?> Quote Link to comment https://forums.phpfreaks.com/topic/100646-passing-variables-to-flash/ Share on other sites More sharing options...
AP81 Posted April 11, 2008 Share Posted April 11, 2008 You can't pass images to Flash. All you can pass is variables. Quote Link to comment https://forums.phpfreaks.com/topic/100646-passing-variables-to-flash/#findComment-514793 Share on other sites More sharing options...
greens85 Posted April 11, 2008 Author Share Posted April 11, 2008 So even if my image is placed in a variable like it is: $fruit1 = "<img src=\"/images/fruitimages/Apple.gif\"border=\"0\""; It still wont work? I thought that if i somehow managed to pass that variable through the flash it would read it and display the image. Quote Link to comment https://forums.phpfreaks.com/topic/100646-passing-variables-to-flash/#findComment-514815 Share on other sites More sharing options...
AP81 Posted April 12, 2008 Share Posted April 12, 2008 That will probably work, but you need to pass that as a FlashVar. i.e. ... <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="flaMovie1.swf?imageFilename=$fruit1 ... In you flash program you will need to read in the variable imageFilename, then display the picture if that is valid. Quote Link to comment https://forums.phpfreaks.com/topic/100646-passing-variables-to-flash/#findComment-515335 Share on other sites More sharing options...
gnznroses Posted April 12, 2008 Share Posted April 12, 2008 i think there's two different ways of passing vars to flash, depending on browser. so be sure to use both. it's covered on adobe's site. Quote Link to comment https://forums.phpfreaks.com/topic/100646-passing-variables-to-flash/#findComment-515338 Share on other sites More sharing options...
greens85 Posted April 14, 2008 Author Share Posted April 14, 2008 Hi again, Ive now managed to pass the variables to flash using the following code: <?php //Set The Variables $fruit1 = "<img src=\"/images/fruitimages/Apple.gif\"border=\"0\""; $fruit2 = "<img src=\"/images/fruitimages/Orange.gif\"border=\"0\""; $fruit3 = Pear; $fruit4 = Banana; $fruit5 = Peach; $fruit6 = Cherry; $fruit7 = "<img src=\"/images/fruitimages/Strawberry.gif\"border=\"0\""; $fruit8 = Grape; $fruit9 = Blackberry; //Echo These Variables echo("&fruit1=$fruit1&fruit2=$fruit2&fruit3=$fruit3&fruit4=$fruit4&fruit5=$fruit5&fruit6=$fruit6&fruit7=$fruit7&fruit8=$fruit8&fruit9=$fruit9&"); ?> I know this code is sending the variables as i have a trace on them in flash, using this code: // create an object to store the variables varReceiver = new LoadVars(); // load the variables from the text file varReceiver.load("http://www.lotterykingkellyseye.com/Scratch/NameVariables.php"); // trigger something - when the variables finish loading varReceiver.onLoad = function(){ //the variables have finished loading //do something... trace(this.fruit1); // you use the this keyword to call the variables stored in the object varReceiver trace(this.fruit2); trace(this.fruit3); trace(this.fruit4); trace(this.fruit5); trace(this.fruit6); trace(this.fruit7); trace(this.fruit8); trace(this.fruit9); }; However im having trouble then putting the variables where i want them, e.g. in a dynamic text field? Can anyone point me in the direction of how to call a variable? Quote Link to comment https://forums.phpfreaks.com/topic/100646-passing-variables-to-flash/#findComment-516676 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.