Please forgive the long-winded post; I wanted to be thorough and not waste anybody's time...
I have been googling for 2 days and I have no hair left. I am fairly new to programming and love php. I have done some really cool things with PHP/MySQL relatively easy. I have been using Flash for a while but not much ActionScripting thus far.
I got this code from the tutorial I am following here:
http://www.kirupa.com/developer/actionscript/flash_php_mysql.htmthe utterly simple AS:
onClipEvent (load) {
//assuming you have a personal web server and PHP installed locally
loadVariables("test.php", this, "GET"); <--- note: I changed this from the original. <---
}
the utterly simple php:
<?php
//The value of $x would be printed to the screen but the SWF would not read the data
$x = "abc";
print $x; <---SHOULD THIS BE REMOVED FROM THE SCRIPT ?
//The value of $x would be printed to the screen and because of the prefix 'myVar=', the SWF will //interpret this as being the intended value for the variable myVar in the SWF
print "myVar=$x";
?>
The second comment in the code above is a lie :) Flash does not see it 'myVar='.
This tutorial seems to walk you through step by step and I couldn't think of anything easier to start with. Yet, it does not work for me! I have tried other tutorials out there (login/authentication) and end up in the same place... a flash text area (dynamic) with NO TEXT!
I think the PHP code is working but under some circumstances, the test.php pops up in a new window and prints "myVar=123" ...as in... <? echo ("myVar=123") ?> (when I modify the code that is)
Relative points...
1. Should my SWF be in the PHP page or in a seperate HTML file? I have it in an HTML file (index.htm) but I've tried it in both the HTML file and the PHP file.
2. I have seen the code I am trying to use in several scripts <? print "myVar=$x"; ?> except EVERY time I have seen it, it looks like this <? print "&myVar=$x&"; ?> or atleast 1 of the added ampersands.
3. Another thing I tried was to add this parameter to the embeded flash object:
<param name="allowScriptAccess" value="sameDomain" />
4. Would this extremely basic simple script vary for different versions of Flash/ActionScript?
5. Should I be using the loadVariables or should it be loadVariablesNum? I've tried both...
6. If I copy and paste this simple code you would think it WOULD work! It does not!!!
I have been able to bring text into a Flash dynamic text area from a .txt file easy enough. I understand the "&" is what Flash uses to seperate elements from the external text.
If I can figure out how to pass vars between Flash and PHP I am on to great things :)
No kidding, I have tried every combination between everything mentioned above. I have looked everywhere I know of on the web. I have not been able to find anything to get me started that is as simple as this code ( SHOULD BE )!
I'm desperate (no, really)! This is the first time I have had to post to find the answers I seek!
Please help, thanks in advance, and if I could offer more than 500 points I would!!!
Thanks again,
Kevin
P.S. Some good (Flash/PHP) n00b resources would be greatly appreciated. Lot's of great PHP resources out there but not too much using the combination, for n00bs anyway :)
Start Free Trial