Friday, March 26, 2010

Actionscript 3 - URL Variables to server side language (ASP,PHP)

Way to pass a variable from Flash AS3 to Server side languages (ASP, PHP).

Flash - Actionscript3

var myVars:URLVariables = new URLVariables(); // instance for URL variables
myVars.myName = "test"; // your variable name & value, which to be sent to server side
var myRequest:URLRequest = new URLRequest(); // instance for URL request
myRequest.url = "http://localhost/site/test.asp"; // Server side page name, where to send
myRequest.method = URLRequestMethod.POST; //Method, which to be used
myRequest.data = myVars; //Adding a variable to request
var myLoader:URLLoader = new URLLoader(); //instance for URL Loader
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES; //Return data format
myLoader.load(myRequest); //Sending request to serve side page.

ASP - Server side page

<% myName = request("myName") response.write myName %>

Happy Coding....

Sunday, March 21, 2010

ActionScript Error #2032: Stream Error. URL: http://localhost/sitename/swf/test.swf

Description:

This is an ActionScript Runtime Error, you will get if you are trying to load a swf file into Flash applications. The reason you will get this error is if you have targeted an swf or any file incorrectly. This can include ASP scripts and other external datasources.

Fix:
Make sure that you are giving the file correctly otherwise you will get Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.at SoundControl_fla::MainTimeline/frame1().

Wrong Code:
stream = new URLStream();
stream.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
stream.load( new URLRequest("http://localhost/sitename/swf/tst.swf"))
Correct Code:
stream = new URLStream();
stream.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
stream.load( new URLRequest("http://localhost/sitename/swf/test.swf"))

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.at SoundControl_fla::MainTimeline/frame1()

I hope this will resolve your AS3 stream error.

happy coding...