If like me and your new to AS3, and you start looking at pre-made server solutions, SFS looks like the ideal candidate. The examples and tutorials make it all seem so easy to do, and easy to set up.
Now this problem isnt with SFS, but I do think they make the situation worse. For a start they have a lot of information on AS2 but little on AS3, and also have a lot of out-datted material which further leads to confusion. The forum support isnt great, although I understand they are not there to help with AS3, but you would think if they want me to buy their software they could at least have told me somthing as simple as this in AS3.
Anyway enough of the rant, the problem you might get is an error such as:
ERROR5001: The package name of 'sfsEvent' does not reflect this files location, please either rename the package or move the file.
Then you think, ok iv followed the instructions to the letter, made sure that i have used the correct class path for my .FLA, and imported all the classes.
The problem here is that the name of the package is actually where the file is located in reference to your main .FLA file document class. So you have probably put the main document class file in the same folder as this package. In which case, just delete the package name.
However if you want to point it to a different folder then make sure you add the directory tree to this file with '.' instead of '/' or '\'.
So if my file is located in: '/file1/file2/sfsevent.as' in relation to the document class then the package name should be: 'package file1.file2.sfsevent.as {'
I find it easier though to just keep all my classes in the same folder, and the .FLA file one folder outside of this.
Anyway this is something to check everytime you get one of these errors. You then might get an error saying that something is an undefined variable such as sfsEvent. You need to make sure that you have imported the class and the import location is where the actual file is, so:
import file1.file2.sfsEvent;
07 August 2009
Sending and Recieving Variables - 'Undefined' value Problem FLASH PHP JAVASCRIPT AJAX
Heres a problem I know a lot of people come accross. Basically you are trying to send and recieve information between a server side language and client side language.
For ajax you might have a class that sends POST or GET data with a response handler. Actually its the same with as3...
But the problem is when you recieve the response from PHP for some reason the value you get is 'undefined', or you even get a print out of the whole PHP code, or even stranger you get the whole page in the encoding formatt which basically has loads of % signs and so on.
This is an easy problem to solve but took me days to find what was causing this problem.
One early solution I had was to just assign a blank variable on the first variable and not use it, which I know is popular with a lot of people. You may have even tried it yourself.
But heres how you can avoid this messy hack.
When you get this error, your actually accessing the .php file directly, and NOT through your local server (apache for example). So for an AJAX example you might have:
postData(mydata,POST,'myPHPfile.php',responseHandler);
or for Flash AS3 you would have:
file = new URLRequest("myPHPfile.php");
All you need to do is point to this file through your server so instead of:
'myPHPfile.php' you should use:
'http://localhost/htdocs/myPHPfile.php';
or wherever you run your php scripts.
So now the as3 example will look like this:
file = new URLRequest("http://localhost/htdocs/myPHPfile.php");
Try to get those variables now and you will see it is all working! Thank F*CK FOR THAT!
For ajax you might have a class that sends POST or GET data with a response handler. Actually its the same with as3...
But the problem is when you recieve the response from PHP for some reason the value you get is 'undefined', or you even get a print out of the whole PHP code, or even stranger you get the whole page in the encoding formatt which basically has loads of % signs and so on.
This is an easy problem to solve but took me days to find what was causing this problem.
One early solution I had was to just assign a blank variable on the first variable and not use it, which I know is popular with a lot of people. You may have even tried it yourself.
But heres how you can avoid this messy hack.
When you get this error, your actually accessing the .php file directly, and NOT through your local server (apache for example). So for an AJAX example you might have:
postData(mydata,POST,'myPHPfile.php',responseHandler);
or for Flash AS3 you would have:
file = new URLRequest("myPHPfile.php");
All you need to do is point to this file through your server so instead of:
'myPHPfile.php' you should use:
'http://localhost/htdocs/myPHPfile.php';
or wherever you run your php scripts.
So now the as3 example will look like this:
file = new URLRequest("http://localhost/htdocs/myPHPfile.php");
Try to get those variables now and you will see it is all working! Thank F*CK FOR THAT!
Subscribe to:
Posts (Atom)