PDA

View Full Version : when is "air." required?


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);
}

NoobsArePeople2
03-08-2010, 05:18 PM
You mention a crossdomain file, are you trying to use AIR in a web browser?

ryanmills
03-09-2010, 10:19 PM
You mention a crossdomain file, are you trying to use AIR in a web browser?

No, connecting to a website via URLRequest(), it was just a last ditch effort, still cant get this to work :(

NoobsArePeople2
03-09-2010, 10:29 PM
I know this probably isn't too helpful but it sounds like you're AIR project isn't set up correctly.

I haven't used Flash CS4 with AIR since I have Flex Builder but I'd probably start here if I were to use Flash: http://help.adobe.com/en_US/AIR/1.5/devappsflash/index.html

ryanmills
03-11-2010, 06:24 PM
I know this probably isn't too helpful but it sounds like you're AIR project isn't set up correctly.

I haven't used Flash CS4 with AIR since I have Flex Builder but I'd probably start here if I were to use Flash: http://help.adobe.com/en_US/AIR/1.5/devappsflash/index.html

Thanks i will give that a read over.