Avatar
💡
  • One of the cool features of Adobe AIR (especially for Flash developers) is its ability to render full featured HTML within Flash content. The rendering is handled by the WebKit core, and the HTML content can be from both local and remote URLs as well as from a string of HTML text.

    HTML rendering within Flash content is handled by the ActionScript HTMLControl class (which is wrapped by the HTML component in Flex). The HTMLControl class is a DisplayObject instance (it directly inherits from Sprite) and thus renders its HTML directly to the display list.

    Created Fri, 09 Nov 2007 12:57:01 +0000
  • One of the things that you might need to do when building your application is detecting whether your application has run before. This can be useful if you need to initialize settings, or perhaps prompt the user with some information.

    Below is a simple example that shows how to detect whether the application has run before. Basically, it checks for the existence of a file. If it doesn’t exist, then the app hasn’t run before, if it does exist, then it means that app has run.

    actionscript Created Wed, 07 Nov 2007 12:32:01 +0000
  • Here is a simple example that shows how to enable your Adobe AIR application to accept native drag and drop operations.

    This is a simple application that allows you to drag a text file into the application and then view its contents.

    DragAndDropExample.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication
    	creationComplete="onCreationComplete()"
    	xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    
    	<mx:Script source="DragAndDropExampleClass.as" />
    
    	<mx:TextArea top="10" right="10" bottom="10" left="251"
    			id="outputField" />
    	<mx:Text text="Drag a Text File into the Application"
    			width="233" height="148" top="11" left="10"/>
    
    </mx:WindowedApplication>
    

    DragAndDropExampleClass.as

    import flash.desktop.ClipboardFormats;
    import flash.desktop.DragManager;
    import flash.events.NativeDragEvent;
    import flash.filesystem.File;
    import flash.filesystem.FileMode;
    import flash.filesystem.FileStream;
    
    //called when app has initialized and is about to display
    private function onCreationComplete():void
    {
    	//register for the drag enter event
    	addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onDragIn);
    
    	//register for the drag drop event
    	addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
    }
    
    //called when the user drags an item into the component area
    private function onDragIn(e:NativeDragEvent):void
    {
    	//check and see if files are being drug in
    	if(e.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT))
    	{
    		//get the array of files
    		var files:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
    
    		//make sure only one file is dragged in (i.e. this app doesn't
    		//support dragging in multiple files)
    		if(files.length == 1)
    		{
    			//accept the drag action
    			DragManager.acceptDragDrop(this);
    		}
    	}
    }
    
    //called when the user drops an item over the component
    private function onDragDrop(e:NativeDragEvent):void
    {
    	//get the array of files being drug into the app
    	var arr:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
    
    	//grab the files file
    	var f:File = File(arr[0]);
    
    	//create a FileStream to work with the file
    	var fs:FileStream = new FileStream();
    
    		//open the file for reading
    		fs.open(f, FileMode.READ);
    
    	//read the file as a string
    	var data:String = fs.readUTFBytes(fs.bytesAvailable);
    
    		//close the file
    		fs.close();
    
    	//display the contents of the file
    	outputField.text = data;
    }
    

    One of the cool things about the API, is that you can have specific components within your application accept native drag and drop operations (and not just your entire app).

    actionscript Created Wed, 07 Nov 2007 12:16:01 +0000
  • As part of my Flash on the Beach Intro to AIR Session, I built a simple HTML Editor with a live preview. I have added comments to the code, and uploaded it to the on AIR tour google repository.

    This example demonstrates:

    • Using the File API to write a string to a file
    • Using the HTML Control within an application to render a string of HTML
    • Using the File.browseForSave API to open a native save dialog.

    Here is the code if you just want to glance at it:

    actionscript Created Tue, 06 Nov 2007 12:16:01 +0000
  • Originally posted on onair.adobe.com blog.

    Andrew Shorten just announce at the Flash on the Beach Conference Keynote in Brighton, England that the on AIR Tour is heading to Europe. We are still finalizing some of the details, but the tour will cover 12 cities over 4 weeks (divided into two legs or 2 weeks each), and will be held in late Spring of 2008.

    No bus this time (we couldn’t get the nerd smell out of it), so the European tour will be done via train.

    onairtour onairtoureurope Created Mon, 05 Nov 2007 12:00:00 +0000
  • We have just released an updated beta build of Flash Player 9. This release fixes some compatibility issues with Leopard (including problems with uploading files).

    You can grab the updated beta from here.

    Created Thu, 01 Nov 2007 12:15:01 +0000
  • More information here, here and here.

    ECMAScript 4 is the next version of ECMAScript, of which both JavaScript and ActionScript are based upon.

    Created Thu, 01 Nov 2007 12:14:01 +0000
  • I just noticed that we have a Adobe CS3 Video Workshop was contains a TON of videos and video tutorials for all of the CS3 products. There are 34 videos for just Flash CS3 alone!

    Anyways, if you are interested in learning more about some of the CS3 products then make sure to check out the video workshop.

    Created Wed, 31 Oct 2007 12:46:01 +0000
  • I have been teaching myself Objective-C and Cocoa (in part so I can build native iPhone / iTouch apps), and have been working on a simple command line application named “turl”. This basically provides a command-line interface to url shortening services such as tinyurl.com and urltea.com.

    Anyways, I ran into an issue where a specific URL was not being created correctly. It turns out, it was because I was not url encoding the url before sending it to the api. No problem I thought, I’ll just url encode it. However, after much searching, I found that Cocoa didn’t really provide a url encode API. I did find find a couple of possible solutions that used other APIs, but I could not get either one to work for me, and it didn’t appear that they were made specifically to URL encode urls.

    Created Wed, 31 Oct 2007 12:36:01 +0000
  • I just got a an email telling me that registration for the Amsterdam user group meeting has be really high, and thus we have had to move the meeting to a new (and larger venue).

    If you have already registered, make sure to check out the new info (and if you haven’t registered, then make sure to register on the site).

    You can find more information on the entire European User Group tour (that Lee Brimelow and I are doing) on this page.

    Created Wed, 31 Oct 2007 12:32:01 +0000