Quantcast
Channel: Adobe Community : Popular Discussions - Archived Discussions
Viewing all articles
Browse latest Browse all 21156

Calling Actionscript functions from HTML in Air?

$
0
0
Arg... I feel like I am soo close - but something is not quite right...

I am stuck on the communcation from Javascript back to Actionscript in an Adobe Air 1.5 app... (not flex).

here is my Main():
quote:


public class Main extends Sprite {

public var _as3Var:String = "testing";
public function as3Function():void
{
trace("as3Function called from Javascript");
}

public function Main() {
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);
}

protected function onInvoke(e:InvokeEvent):void {
NativeApplication.nativeApplication.removeEventListener(InvokeEvent.INVOKE, onInvoke );
var app = new App();
addChild(app);
app.init(new ExternalContainer(), e.currentDirectory, e.arguments);
}
}
}



Now, I simply want to either access _as3Var or as3Function() from my AppSandbox javascript... My HTMLLoader looks like this:
quote:


{
_html = new HTMLLoader();
_html.useCache = false;
_html.runtimeApplicationDomain = ApplicationDomain.currentDomain;
_html.load(new URLRequest("sandbox/AirRoot.html"));
}



And this is my javascript snippit:
quote:


Exposed.testAs3 = function()
{
air.trace("Exposed.testAs3 called"); /* this works great */
air.trace("runtimeVersion:"); /* this works great */
air.trace(air.NativeApplication.nativeApplication.runtimeVersion); /* this works great */

air.trace("seeing if I can get to AS3 params..."); /* this works great */
air.NativeApplication.nativeApplication.as3Function(); /* this produces an exception: TypeError: Value undefined does not allow function calls. */
}




What I am doing wrong?

Viewing all articles
Browse latest Browse all 21156

Trending Articles