LimeLM for HTML/Javascript Programmers w/ no Flex Experience

Hello,

I am an HTML/AJAX programmer using the Aptana framework to build out my AIR app. I have no idea how to reference these .mxml files or anything else for that matter.

Can you please point me in the right direction?

Thanks

The "Using TurboActivate with Adobe AIR" article is a good place to start. You'll need to include TurboActivate.as and TurboActivateEvent.as within your Adobe AIR project. The "mxml" files are just windows showing how to use TurboActivate. You can open these files in a text editor. I also believe Aptana supports opening these files.

Tell me if this helps.

Wyatt,

Thanks for the quick response. Unfortunately I've read that article dozens of times. I can't figure out how to get those files referenced from my main application.xml file?

It seems like it requires me to mix javascript/html AIR Code with Flex/AS which I am entirely unfamiliar with.

Does this mean I only need to include those 2 files, and not have the bin-debug directory with a subdirectory called Windows containined systa.exe, Turboactivate.exe?

I'm also assuming I need to put this code somewhere to activate the registration stuff:

public function init():void{ ta.VersionGUID = "Paste GUID Here";

// these are TurboActivate event handlers that will be used at // both the start of your program and throughout the use of your program ta.addEventListener(TurboActivateEvent.IS_ACTIVATED, onIsActivated); ta.addEventListener(TurboActivateEvent.USE_TRIAL, onUseTrial); ta.addEventListener(TurboActivateEvent.TRIAL_DAYS_REMAINING, onTrialDaysRemaining);}

private function onIsActivated(evt:TurboActivateEvent):void{

}

private function onUseTrial(evt:TurboActivateEvent):void{

}

private function onTrialDaysRemaining(evt:TurboActivateEvent):void{

}

Now would that go in my main HTML file? If so do I need to convert that AS code to JS?

The first step is to add the TurboActivate.as and TurboActivateEvent.as files to your project. They are plain old vanilla ActionScript files that will work with any Flash Based program in the world. Then you need to add the init function to your app and use some TurboActivate functions like show in the step-by-step walkthrough.

Here's how you add an init function: NativeProcess in AIR using JavaScript

Then run your app. You'll get an exception about it not being able to find the "systa.exe" file. Add the systa.exe, TurboActivate.dll, and TurboActivate.dat files in a "Windows" folder you created. And put that "Windows" folder in whatever "debug" folder Aptana creates for you.

This should get you started. Tell me if it helps.

[app:/SNATCHER.html][15:43:13] ReferenceError: Can't find variable: TurboActivate[app:/SNATCHER.html][15:43:13] TypeError: Result of expression 'ta' [undefined] is not an object.

<html> <head> <title>SNATCHER v0.8.11 DESKTOP</title> <link rel="stylesheet" type="text/css" href="css/reset.css" /> <link rel="stylesheet" type="text/css" href="css/styles.css" /> <script src="lib/air/servicemonitor.swf" type="application/x-shockwave-flash" /> <script type="text/javascript" src="lib/air/AIRAliases.js"></script> <script type="text/javascript" src="lib/air/AIRIntrospector.js"></script> <script type="text/javascript" src="lib/air/AIRSourceViewer.js"></script> <script type="text/javascript" src="lib/jquery/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="lib/jquery/init.js"></script> <script type="text/javascript" src="lib/jquery/domainfunctions.js"></script> <script type="text/javascript" src="lib/jquery/savepreferences.js"></script> <script type="text/javascript" src="lib/jquery/timestamp.js"></script> <script type="text/javascript" src="lib/date.js"></script> <script type="text/javascript" src="lib/jquery/encoder.js"></script> <script type="application/x-shockwave-flash" src="lib/air/aircore.swf"></script> <script type="text/javascript">

var ta = new TurboActivate();

function init() { ta.VersionGUID = "17843029414e58ae47exxxxxxxxxxx6"; ta.addEventListener(TurboActivateEvent.IS_ACTIVATED, onIsActivated); ta.addEventListener(TurboActivateEvent.USE_TRIAL, onUseTrial); ta.addEventListener(TurboActivateEvent.TRIAL_DAYS_REMAINING, onTrialDaysRemaining);}

function onIsActivated(evt) { if (evt.ErrorObj == null) { if (evt.boolResponse) { alert('is activated'); // is activated, reenable any features } else { alert('is not activated'); } } else { // the function call failed, disable any features alert('call failed'); // in a real world app don't throw exceptions. This is for debugging only //throw evt.ErrorObj; }}

</script> </head> <body onload="init();">

SO I would expect to get those top errors given im not defining the as files anywhere. I'm just extremely confused with this because Flex/AIR and HTML/JS AIR are so much different. Any insight you could provide would be great

You'll need to add the TurboActivate.as and TurboActivateEvent.as files to your Adobe AIR project. They're already pre-built -- they're in the "API\Adobe AIR\src" folder. Copy them to your project's folder and add them to your project.

I do understand that part and have figured out how to add them to the project but how do I call them to be launched?

The "Using TurboActivate with Adobe AIR" article explains how to use the TurboActivate functions. In the code you've posted you're already using the event handlers (which is a good start). These event handlers will get the response of any functions you call.

If you read on in the article you'll see the example expanded by using the "IsActivated()" function:

public function init():void{...    ta.addEventListener(TurboActivateEvent.IS_ACTIVATED, onIsActivated);...    ta.IsActivated();}

After adding the "ta.IsActivated()" line to your init() function compile and re-run your application. If you see any exceptions read the error. For instance, if you haven't yet put the systa.exe, TurboActivate.dll, and TurboActivate.dat files in your debug folder then you'll get an exception.

Tell me if this helps.

Wyatt,

Thank you for your help. However after countless hours of attempting to make this work I have come to the conclusion that HTML/Javascript AIR Apps and FLEX/Actionscript AIR apps are two totally different monsters.

The code provided is not even remotely applicable from my trials and I hope that in the future you come out with a separate tutorial on AIR projects specific to HTML/Javascript. (If you visit Adobe's help site you'll notice they have entirely different help libraries for the two programming environments).

Thanks

OK, we'll add an HTML/AIR example with TurboActivate 3.1.

Wyatt,

How much would you charge to implement this into my project for me?

Thanks

Send it to wyatt@wyday.com and I'll take a look at it this weekend. There will be no charge -- the real life code will be useful in making a proper AIR HTML/JS example (not that we'll use your code in an example, just that it will let us implement it in real-life way).

Would that help?

Wyatt,

I am in the same boat, I am not sure how you can include actionscript file into a html/js AIR application. ❓

I have gotten to the point where extendedDesktop is supported but stuck on how to incorporate the licensing files TurboActivate.as & TurboActivateEvent.as into the html / javascript files.

I think one would need to create a swf file as a library containing the two as files and build an Actionscript to JS interface on the html page.

Would you be able to provide a sample for an Abobe Air Application built using only html and javascript. Just FYI, http://www.adobe.com/devnet/air/samples_javascript.html.

Thanks,Vijay

Hey Vijay,

We're putting together an HTML/JS AIR example now. We're trying to get it out in about a week.

Wyatt,

Can you please provide an update on the html/javascript AIR integration sample app?

Thanks,-Vijay

We've been working on it. We're trying to get it out in a few days. Unfortunately HTML/JS AIR apps are second class citizens in Adobe's eyes and they don't provide very good tools to work with.

If you're especially rushed you could always convert the TurboActivate.as and TurboActivateEvent.as files from actionscript to Javascript. That's what we're doing now. Everything else will be identical.

Please take a look at these steps from adobe to incorporate inmarket licensing which is not supported anymore.

http://learn.adobe.com/wiki/display/InMarket/Integrating+Licensing+into+an+HTML+application.

Thinking that LimeLM could be substituted where adobe licensing code is used.

This method enables to package the html app into a flex container.

This method also required no porting from AS to JS. Possibly an interface might be needed to handle cases of trial, limited, full versions etc.