ryanmills
03-06-2010, 07:06 AM
First time using AIR so sorry if this is uber simple but im ripping my hair out over this...
The AIR docs don't seem to be consistent and I cant find anything about when I should and should not use "air." for example some docs have air.trace() others just use trace. Im using CS4 pro and air.trace spits errors. I also cant seem to use a basic URLLoader. Are there any docs on what changes when your writing AS for AIR?
Using CS4 Pro, I did add the "servicemonitor.swc", when i added the "airglobal.swc" it started spitting errors I could not even trace on google... there is a crossdomain file. Just seems like this should be easier. I have read I should never use "air." in flash but its in the stupid docs. If thats not the reason any ideas why this might not be working? T
I have the following simple script that start fine but never spits errors and never completes :(
import flash.events.*;
import flash.net.*;
import fl.controls.*;
import air.net.*;
stop();
btn_login.addEventListener(MouseEvent.CLICK, checkLogin);
function checkLogin( e:Event ){
trace("checkLogin(\""+server_path+"\")");
p_progress.visible = true;
df_progress.text = "loging into server";
var loader:URLLoader = new air.URLLoader();
var theURL:URLRequest = new URLRequest( server_path );
theURL.data = "x_user="+f_email.text+"&x_pass="+f_password.text;
theURL.method = URLRequestMethod.POST;
loader.load(theURL);
addEventListener(Event.COMPLETE, completeHandler);
addEventListener(Event.OPEN, openHandler);
addEventListener(ProgressEvent.PROGRESS, progressHandler);
addEventListener(SecurityErrorEvent.SECURITY_ERROR , securityErrorHandler);
addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
function completeHandler(event:Event) {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: " + loader.data);
}
function openHandler(event:Event) {
trace("openHandler: " + event);
}
function progressHandler(event:ProgressEvent) {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
function securityErrorHandler(event:SecurityErrorEvent) {
trace("securityErrorHandler: " + event);
}
function httpStatusHandler(event:HTTPStatusEvent) {
trace("httpStatusHandler: " + event);
}
function ioErrorHandler(event:IOErrorEvent) {
trace("ioErrorHandler: " + event);
}
The AIR docs don't seem to be consistent and I cant find anything about when I should and should not use "air." for example some docs have air.trace() others just use trace. Im using CS4 pro and air.trace spits errors. I also cant seem to use a basic URLLoader. Are there any docs on what changes when your writing AS for AIR?
Using CS4 Pro, I did add the "servicemonitor.swc", when i added the "airglobal.swc" it started spitting errors I could not even trace on google... there is a crossdomain file. Just seems like this should be easier. I have read I should never use "air." in flash but its in the stupid docs. If thats not the reason any ideas why this might not be working? T
I have the following simple script that start fine but never spits errors and never completes :(
import flash.events.*;
import flash.net.*;
import fl.controls.*;
import air.net.*;
stop();
btn_login.addEventListener(MouseEvent.CLICK, checkLogin);
function checkLogin( e:Event ){
trace("checkLogin(\""+server_path+"\")");
p_progress.visible = true;
df_progress.text = "loging into server";
var loader:URLLoader = new air.URLLoader();
var theURL:URLRequest = new URLRequest( server_path );
theURL.data = "x_user="+f_email.text+"&x_pass="+f_password.text;
theURL.method = URLRequestMethod.POST;
loader.load(theURL);
addEventListener(Event.COMPLETE, completeHandler);
addEventListener(Event.OPEN, openHandler);
addEventListener(ProgressEvent.PROGRESS, progressHandler);
addEventListener(SecurityErrorEvent.SECURITY_ERROR , securityErrorHandler);
addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
function completeHandler(event:Event) {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: " + loader.data);
}
function openHandler(event:Event) {
trace("openHandler: " + event);
}
function progressHandler(event:ProgressEvent) {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
function securityErrorHandler(event:SecurityErrorEvent) {
trace("securityErrorHandler: " + event);
}
function httpStatusHandler(event:HTTPStatusEvent) {
trace("httpStatusHandler: " + event);
}
function ioErrorHandler(event:IOErrorEvent) {
trace("ioErrorHandler: " + event);
}