ridiculous Posted December 12, 2006 Share Posted December 12, 2006 Hello. QUESTION:Can and how do you convert global variables to local variables ANDcan and how do you convert local variables to global variables?REASON FOR QUESTION:I have a FLASH movie that imports some PHP variables, but not others. All the variables behave the same in PHP. FACTS:I have a FLASH movie that imports PHP variables into a dynamic text box. From what I have observed, Actionscript only imports variables that are set as follows:[color=purple][u]Ex. 1 : Flash imports variables where the value is written in directly.[/u][/color]$text = "city";[color=purple][u]Ex. 2: Flash imports variables where the value is the result of a query on the same script.[/u][/color]$conn = db_connect();$sql = 'SELECT Site FROM course_catalogue ORDER BY RAND() LIMIT 1'; if( ($result = mysql_query($sql)) === FALSE ) {echo mysql_error();} else while ($row = mysql_fetch_assoc($result)) {extract($row);[color=red]Probably sounds reasonable enough.[/color] But, the issue I'm having is that I must carry variables from my initial query through a series of other scripts (by POSTing them to a url or as part of a function). When I need to import my variables to FLASH, they [color=blue][b]print [/b][/color]$myvar; and [color=blue][b]echo[/b][/color] $myvar; normally and appear to behave as any other variable for PHP purposes. Flash, however, does not recognize them. Your help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted December 12, 2006 Share Posted December 12, 2006 In my limited knowledge, you can pass variables in these ways:* if a variable is outside a function and you want to use it inside a function then claim it as 'global'[code]<?php$a = 1;$b = 2;function Sum(){ global $a, $b; $b = $a + $b;}Sum();echo $b;?> [/code]* If you wish to pass it to another page you can use:1. session vars2. pass it in the URL (ex: nextpage.php?hotstuff=$hotStuff which would pass along 'Kate Bekinsdale' to be captured in a $_GET statement) Quote Link to comment Share on other sites More sharing options...
ridiculous Posted December 12, 2006 Author Share Posted December 12, 2006 I was wrong. Quote Link to comment Share on other sites More sharing options...
ridiculous Posted December 12, 2006 Author Share Posted December 12, 2006 All that time, wasted. Actionscript loadVariables only reads (PHP Variables) right from the PHP script indicated in the URL; so Flash can only take what it sees there at the time it "parses" the doc in its own half-assed way. No session variables. If you want to import dynamic content into Flash from PHP, you have to either write your variables to an XML file that you destroy at the end of the session or use an Apache Module like amfphp, which you can't do unless you have root access. Worthless. Quote Link to comment 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.