Jump to content

load php into dynamic text box flash not showing


hansolo

Recommended Posts

http://www.kirupa.com/developer/acti..._php_mysql.htm loading a php file in my flash file. I am getting the following error .no text of the php file is showing in the text box. When i play the file from the wamp/www which is the local host folder . I get a message saying flash has stopped an unsafe operation. Need to change settings to allow this. I have recently changed the settings and removed the flash waring but theres still no text in the dynamic text box on stage from the php file onClipEvent (load) {//assuming you have a personal web server and PHP installed locallyloadVariables("http://localhost/test.php",'>http://localhost/test.php", this, "GET");} I have add what i belive to be the correct file path on the settings www.localhost/test.php and there i still no text in the box. I have named the vairiable box as the tutorial asks not the instant name cheers any help on this be grateful When i play the file from the wamp/www which is the local host folder . I get a message saying flash has stopped an unsafe operation. Need to change settings to allow this. I have recently changed the settings and removed the flash waring but theres still no text in the dynamic text box on stage from the php file the code on the movie clip which is dynamic text box converted to a movieclip. The fist stage of the tutorial .I have named the variable name "myVar" ActionScript Code: onClipEvent (load) { //assuming you have a personal web server and PHP installed locally loadVariables("http://localhost/test.php", this, "GET");}php code ActionScript Code: <?php/The value of $x would be printed to the screen but the SWF would not read the data $x = "abc";print $x;//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";?>?> Edited by hansolo
Link to comment
Share on other sites

That tutorial is really outdated, new versions of Actionscript no longer use onClipEvent, and he even says that his PHP is using register_globals. To start with, I would launch that in a browser with the developer tools open so that you can see the request to your server going out and check the response. If there's no request then Flash isn't even sending the request. If the PHP you posted above is your actual PHP code, then PHP is responding with "abcmyVar=abc" instead of "myVar=abc".

Link to comment
Share on other sites

I dont normally use clip events either. I dont know why there is aneed in the tutorial to convert the text box into a movieclip. Would it be better if i give the text box an instant name and then place code on the main timeline instead. The reason for me coming across this tutorial is looking at the best way to create a database with mysql and php to create a score board for my flash games. i am new to php and mysql . I do have expereince in flash as2

Link to comment
Share on other sites

ive tested and the flash file is loading and the php file is loading on the internet. However there does seem to be an issue with text not going in the dynamic text box of the clip event if place this on the timeline in the method below of loading php into flash file .. myData = new LoadVars();myData.onLoad = function() { // instant name of text box and i think iplace the variable name at the end myText_txt.text = variablename ;}; // would this be were to put the file path to the php file myData.load("myText1.txt "localhost\myfolder/myfile.php );

Edited by hansolo
Link to comment
Share on other sites

It's better to use instance names for everything, you shouldn't bind variables to text boxes. That's also an old practice. Stick to instance names only, and consider going to AS3. AS3 has much better classes than previous versions, like this for example: http://www.republicofcode.com/tutorials/flash/as3externaltext/

Link to comment
Share on other sites

My games are in as2 and i will go to as3 once after . All i need to do is load a php file into a text box . I know there is only small part not working as load the value true. so the load vars is working i have the small hpfile correct is well . there one simple fustrating thing i am missing . please can some one see what this mistake is submit_button.onRelease = function(){// Load what?var result_lv:LoadVars = new LoadVars();result_lv.onLoad = function(success:Boolean) {if (success) {result_ta.text = "We are in business.";} else {result_ta.text = "Error connecting to server.";}};//now the magicvar StoreshowResults = result_lv.load("http://localhost/test.php");result2.text = StoreshowResults;}

Link to comment
Share on other sites

this code you have sent below also i will load an external txt file. I can do that already in flash as2. I still wont be able to load the php file if its as2 or as3 . Thats the issue so how would i load the php file with this text I can load a text file in as3. I still can load the php file so im in the same position var myTextLoader:URLLoader = new URLLoader();myTextLoader.dataFormat=URLLoaderDataFormat.VARIABLES;myTextLoader.addEventListener(Event.COMPLETE, onLoaded);function onLoaded(e:Event):void {trace(e.target.data.myTitle);trace(e.target.data.myBody);trace(e.target.data.myURL);}myTextLoader.load(new URLRequest("myText.txt")); /____________________________________

Edited by hansolo
Link to comment
Share on other sites

I see the code in the browser. I have wrrote a couple of different php files and i dont have problem loading an external file text fie . As shown below. Later today i tell you exactly what read in the browser by the php file . I dont have access till later tonight as at work.. cheers var myLoadVars:LoadVars = new LoadVars; //loads the path of the file myLoadVars.load("test.txt"); //creates a function if file loads boolean if success myLoadVars.onLoad = function(success:Boolean){ if(success){ // loads the external text file titled homeText in the text editor // in the dynamic text box named "dynamicTextBox" dynamicTextBox.text =this.homeText; } }

Link to comment
Share on other sites

The browswer is only echo out the php which is dslpayed here "&pageID=29" and the code is told to echo this which is imilar to print echo =" &pageID=29" The issue is not the php think. i dont think it the path either. i think the code i wrote before with clip event . As uploading path from a external text editor has been successful . When i uploaded the code with text editor. I had create a variable then load then check the load and then output this to dynamic text box with the path of the text editor . All this hon in the example below. ( i still do have a problem of how is this is possible with a php file http://fav.me/d5rool3

Edited by hansolo
Link to comment
Share on other sites

you right i got it working. Its the same as loading a variable from note pad. /* first create a new instance of the LoadVars object */myVars = new LoadVars();// call the load method to load my php page myVars.load("http://localhost/myfile.php");// once vars have been loaded, we will have these variables: myVars.onLoad = function (success) { if (success) {// instant name of text box and the nam of the php variable dynamicTextBox.text = this.nome; // } } else { trace (" Error loading variables "); } } ______________________________________________________________________________________________________The above does work i have better undesrtanding of the loadVars class now . Not perfect but alot more better. I did find the php file though was not read when i did not have the server turned on. Not a an issue as this current time ._____________________________________________________________________________________________________As sephiroth does mention if the file path needs to be a full path as when i tried to place my php and flash file just in folder and my desktop the file was not read As below this was 1 of my errors Another important consideration. When working with php files, if you make a .load calls in flash like this:myVars.load("file.php"); you can't test your movie inside the flash IDE (CTRL+ENTER), this because in this way the php file won't be processed from your webserver and flash will read the source code of the php file, not the expected output!! __________________________________________________________________________________________________I think this saying that php ont be read by flash player when it on a folder on desktop. Not on a serverI did change the path to locate my folder. It only worked through the server in the wamps www folder. However good news is the code is working now and i am loading like an external text file.

Edited by hansolo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...