all groups > flash actionscript > may 2004 >
You're in the

flash actionscript

group:

Need help with this action script code..


Need help with this action script code.. helpdemos
5/16/2004 5:59:06 PM
flash actionscript:
Hi
I try to pass an IP of a server to my txt file. I use this action script:

myData = new LocalConnection();
trace(myData.domain());
myData.onLoad = function(){
if(myData.domain()!="" ){
myData.Title = Title.text
myData.sendAndLoad("save.php", myData, "POST") //php

}
}
myData = new LoadVars()
myData.onLoad = function(){
if(this.writing=="Ok") {
gotoAndStop(2)
status.text = "Submited data was saved"
}
else status.text = "Error in saving submitted data"
}
stop()

and here is my PHP file (save.php):
<?php
//Capture data from $_POST array
$title = $_POST['Title'];
//Make one big string in a format Flash understand
$toSave = "Title=".$title;
//Open a file in write mode
$fp = fopen("test4/file.txt", "w");
if(fwrite($fp, $toSave)) echo "writing=Ok";
else echo "writing=Error";
fclose($fp);
?>


But it does not work. I do not know why it does not work because I checked it
many times and it should work.


any advices are welcome

Thanks a lot!
Re: Need help with this action script code.. Jack.
5/16/2004 6:19:54 PM
see if this approach helps,

dom = new LocalConnection();
trace(dom.domain());

sendData = new LoadVars();
if(dom.domain()!="" ){
sendData.Title = Title.text;
}

loadData = new LoadVars();
loadData.onLoad = function(){
if(loadData.writing=="Ok"){
gotoAndStop(2)
status.text = "Submited data was saved"
} else {
status.text = "Error in saving submitted data"
}
};

sendData.sendAndLoad("save.php", loadData, "POST");
stop();

AddThis Social Bookmark Button