Archive for October, 2007

07OctAIF Toolkit

For those of you that have done some pixel shading programming, Adobe is bringing into Flash a very interesting project:

Adobe Image Foundation (AIF) Toolkit preview , codenamed Hydra.

Now, if only my card was supported…

06OctAIR: Registering file types

With the last release of AIR beta 2 comes more detailed file type asociation.

This is the fileTypes tag in the AIR configuration XML:

<fileTypes>
      <fileType>
          <name>com.example</name>
          <extension>xmpl</extension>
          <description>Example file</description>
          <contentType>example/x-data-type</contentType>
            <icon>
              <image16x16>icons/AIRApp_16.png</image16x16>     
              <image32x32>icons/AIRApp_32.png</image32x32>     
              <image48x48>icons/AIRApp_48.png</image48x48>     
              <image128x128>icons/AIRApp_128.png</image128x128>
            </icon>
      </fileType>
</fileTypes>

There's a description of some of these paremeters at the Adobe Live Docs site.

The code above, registers the types with your application, so the AIR app is open upon clicking any file with the right extension. In order to perform an action (eg. open), we need to retrieve the value of such file.

To do so we need to add the following code to the "invoke" event in the WindowedApplicaton ( invoke="onInvoke(event) ):

public function onInvoke(invokeEvent:InvokeEvent):void
{
   //trace("Invoke event received.");
                    
   if(invokeEvent.arguments.length> 0){
      trace("Application opened with: "+event.arguments[0]); // file path
      // ...
      // custom code
      // ...
   } else {
      trace("--no arguments--");
   }
}

Again, at Adobe you can find more details.

Finally, if you want a full detailed tutorial go over to Setting Up an AIR Application with File Associations where you'll find an excellent step-by-step guide by senocular.

06OctCreate AIR applications out of your old AS2 code

If you have some old AS2 code laying around that you'd like to take into the desktop, here you have a quick tip that might save you hours of re-coding those AS2 classes into AS3.

In my case, I had an AS2 project completed that I had long ago converted into an executable with Screenweaver. I needed to change a couple of things, and it was then when I realized that Screenweaver was obsolete and would not run in Vista.

Of course AIR is the "desktop publisher" of choice right now, but AIR supports only AS3. The solution comes (using Flex) with an easy SWFLoader, that simply performs an old loadMovie, effectively loading your AS2 movie into AS3. Create a wrapper AS3 class that simply loads your AS2 movie, and create your application with AIR.

You'll need to create a WindowedApplication class to substitute the default class created by Flex.

AS2AIR.as

package com.domain
{
    import mx.core.WindowedApplication;
    import mx.controls.SWFLoader;
   
    public class AS2AIR extends WindowedApplication
    {
        public var swf:SWFLoader;
       
            public function init():void
            {
                this.swf.source = "My_Old_AS2_Code.swf";
            }
    }
}

And the MXML file contains just that SWFLoader.

AS2AIR.mxml

<xml version="1.0" encoding="utf-8"?>

<app:AS2AIR
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:app="com.domain.*"
    initialize="init();" width="800" height="600"
    layout="absolute" xmlns:ns1="*">

<mx:SWFLoader id="swf" scaleContent="false" width="100%" height="100%" x="0" y="0"/>
   
</app:AS2AIR>

You can, of course, indicate the source file direclty in the MXML file, but if you need to manage some communication between your AIR application and your AS2 movie, you'll have to deal with your own AS class.