Hey everyone this is a second attempt to post this thread - firefox died last time just as i was about to submit. Ok so I am having a major problem at the moment which seems like it should have quite an easy fix. I am currently messing about with amfphp for a project I am working on and it is working perfectly for me, very quick and loads all the data that I need in a very efficient way. Now the only thing is I need to include a publish function and for this I have been getting helped so far and was given a package to help me publish some variables to a database. What I am trying to do is publish the coordinates of an mc when it has been dropped, after being dragged, and so I am trying to reference the publish function(found in the class) inside of the drop function(inside each of the mcs on my stage).
So here is the class code:
package
{
/////////////////////
// import packages //
/////////////////////
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
import flash.system.Security;
/////////////////////////////////////////////////////////////
// Responsible for saving and loading all external content //
/////////////////////////////////////////////////////////////
public class ExternalIO
{
private var _myService:NetConnection;
private static var instance:ExternalIO;
private static var allowInstance:Boolean;
///////////////
// Construct //
///////////////
public function ExternalIO()
{
if (!allowInstance)
{
throw new Error("use ExternalIO.getInstance() instead of new keyword !");
}
}
///////////////
// Singleton //
// @return //
///////////////
public static function getInstance():ExternalIO
{
if (instance == null)
{
allowInstance = true;
instance = new ExternalIO();
instance.init();
allowInstance = false;
}
else
{
trace("ExternalIO instance already exist !");
}
return instance;
}
///////////////////////////////////
// Create the new RPC connection //
///////////////////////////////////
private function init():void
{
Security.allowDomain("*");
Security.loadPolicyFile("http://example.com/amfphp/crossdomain.xml");
_myService = new NetConnection();
_myService.objectEncoding = ObjectEncoding.AMF3;
_myService.connect("http://pyrrha.csisdmz.ul.ie/chiggins/amfphp/gateway.php");
}
//////////////////////
// Save to database //
//////////////////////
public function publish(X:Number, Y:Number, NAME:String)
{
//store the data into the database using RPC
var responder:Responder = new Responder(publishSuccess, publishFault);
_myService.call("chaudioCircs.publish", responder, X, Y, NAME);
}
//////////////////////////
// publishSuccess //
// Successful data save //
//////////////////////////
function publishSuccess(responds:Object):void
{
trace("AMFPHP publish success:" + responds);
}
//////////////////////
// publishFault //
// Failed data save //
//////////////////////
private function publishFault(responds:Object):void
{
trace("AMFPHP publish failed:" + responds);
}
}
}
and here is how I am referencing it inside of my mc:
// Update the DB
var extIO:ExternalIO = new ExternalIO();
var X:Number = this.x;
var Y:Number = this.y;
var NAME:String = iName;
extIO.publish(X, Y, NAME);
But when I drop the mc on the stage it is throwing this error:
Error: Error #2136: The SWF file file:///Macintosh%20HD/Users/Bob/Desktop/WORK%5FDON%27T%20TOUCH/amfPHP%20work/amfphpTest.swf contains invalid data.
I don’t really know what’s wrong with it to be honest and was hoping to find some help on the matter because it is pretty urgent at this stage.
/Conor