I am building apps with Open Web technologies at Sencha. It is a great platform, take a look...

 

  Ted Patrick - Developer Relations @ Sencha


   Note: This is the personal blog of Ted Patrick. The opinions and statements voiced here are my own.



The End

DIGG IT!     Published Wednesday, January 05, 2011 at 12:13 PM .

This marks the end on blogging at onflash.org and onflex.org. You will find me blogging about interactive software development at http://tedpatrick.com.

Cheers

Ted :)


Opportunity and Thanks

DIGG IT!     Published Tuesday, October 19, 2010 at 9:06 AM .

I am headed to Barnes & Noble to work on the Nook and will be departing Adobe after MAX 2010. I am extremely excited about the opportunity to "redefine the book", but that can wait for another day...

First I want to say thanks.

Adobe has been an amazing place to work. Over the past 4+ years I have travelled the globe, met with thousands of customers, helped many projects, and had the honor of working with great people both inside and outside of Adobe. Working with great people has made this role really rewarding and knowing that I helped make a difference has given me great satisfaction.

Thanks for the opportunity to move Flash forward.
Thanks for the generosity towards my family.
Thanks for the great times.
Thanks for all the fish.

See you at MAX 2010.

Cheers,

Ted :)


Highly Illogical

DIGG IT!     Published Monday, October 11, 2010 at 7:58 AM .

At Adobe MAX 2010, Leonard Nimoy will be joining us as Host for MAX Awards and Sneaks. Given his presence at Sneaks, the team is going all out. We have 10 amazing sneaks from Adobe research labs, Colin Moock is hosting Star Trek trivia with Megaphone between Awards and Sneaks, there are some fairly serious costumes in development, and it is sure to be a great time.



Make sure to register for MAX before it is too late.

Again, don't miss MAX Sneaks!

Ted Out! :)


URL Alignment

DIGG IT!     Published Monday, July 12, 2010 at 1:21 PM .

SWF files (Flash and Flex output) are not naturally aligned with web browser. It is thus the responsibility of the developer to make sure that a SWF file responds to input from the URL in terms of supporting back button behavior, bookmarks, and deep linking. I believe that this lack of default alignment with the web browser is one of Flash's biggest best practice gaps as a platform and one that is surprisingly easy to fix.

SWFAddress

I have standardized all my use of Flash/Flex with SWFAddress. It is a simple, small js/as library that provides deep web browser integration. Adding SWFAddress to any application will instantly make it far more aligned with the web in adding support for back button, deep linking, and bookmarks.

Providing end users the ability to deep link into any part of your SWF application is essential and really simplifies development. Given the growing concept of States, the ability to instantly link to any state with an application provides great end user value and is really easy to do. Simply map the states API to SWFAddress events and you are all set. Better still if URL Alignment is a top priority within your application, you can make programatic entry points into your application with just a url. This can often avoid the need for overly complex inner app navigation and makes your app much more open to user customization. Say as a user I had one screen I use every day for an account I manage, it makes sense to bookmark it. Here is a sample application I wrote that does just that, source included.

Sample Application
Link to Customers View
Search for the Red Bull Account
Create a new Ad for Red Bull's Account

Here is the source!

As developer we tend to think about inner SWF interaction only and avoid any type of browser integration. The problem is that end users depend on the browser and when the back button unloads a Flex application, it can be a real problem especially in Enterprise conditions. There are many users who work inside of Flex applications every day in their daily work and hearing their complains is a real eye opener.

Please take some time to explore SWFAddress, it is a great library and adds some essential value to Flash in terms of URL Alignment. Adding deep linking, bookmark, and back button support into your application is really important and with SWFAddress easy.

Special thanks to Maria Lubenova and Rostislav Hristov at Asual for SWFAddress!

Cheers,

Ted :)


FITC San Francisco August 17-19 & "Multi-Social Multi-Screen"

DIGG IT!     Published Tuesday, June 08, 2010 at 1:30 PM .

The team over at FITC is hosting a San Francisco conference August 17-19 and I am very excited and honored to be speaking at the event. My session is titled "Multi-Social Multi-Screen" and will focus on the trials and tribulations of building a social photo sharing service end to end. The new and unreleased app/site/service supports sharing across social networks and has custom clients for several different phones and browsers. The matrix of making this work seamlessly was an eye opener for me and forced me to use many new technologies including HTML5, AIR on Android, PhoneGap, Google App Engine (python), and yes even some Objective-C. The session will be a fun exploration in building something new across a minefield of compatibility using Minimum Viable Product.



Make sure to register for FITC San Francisco, it should be a great event. See you there!

cheers,

Ted :)


Get Started Building AIR for Android Apps

DIGG IT!     Published Monday, May 10, 2010 at 1:21 PM .

Here is a sample Flash Builder 4 project that I use for starting AIR for Android app development. The FXP contains the current AIRGlobal.swc and AIRCore.swc libraries and the exported SWF file will run on AIR for Android without modification.



The application screen size is set to 480x800 (Nexus One) and will display at 250dpi. The DPI figure is especially useful for prototyping screens. I typically start with this PNG file in Fireworks and build up UI elements then move over to Flash Builder with a new ActionScript Project.

Files:

Fireworks Prototype UI (480x800@250dpi)
Flash Builder 4 Project FXP
NEW: Flash CS5 Pro Project

If you build something cool, feel free to email the SWF to me at ted@adobe.com. I love seeing what folks are building and with GoogleIO right around the corner I might just draft you into the event preparation if you send over something cool.

Looking forward to seeing what you build!

Cheers,

Ted :)


Feature Request: Rendering API (FP-4218)

DIGG IT!     Published Thursday, March 25, 2010 at 10:50 AM .

I would like to see Flash Player support an expanded rendering API. Today Flash has a very limited rendering API and constantly renders any object added to the DisplayList (exceptions for cacheAsBitmap & MouseEvent.updateAfterEvent). Due to the nature of constant rendering, the player is required to constantly switch from rendering graphics to executing logic (AVM bytecode) as highlighted by the Elastic Racetrack.



Having the player constantly render is expensive and if developers could control the rendering cycle, we would see a new class of higher performance graphical applications and games using Flash Player and AIR.

QUESTION: What if developers could have programmatic control of rendering?

flash.display.Stage.frameRate = 0;
//turn off rendering

this.mySprite.render();
//render a single sprite and its children


Today we do have access to a rendering API within flash.events.MouseEvent.updateAfterEvent() and cacheAsBitmap but these are of limited use for those wanting fine grained control of the renderer. The assumption remains that player is constantly rendering but you can skip rendering some objects or on mouse events force rendering to update graphics quickly. The assumption is that the entire displayList is rendered (except where cacheAsBitmap is true) vs designating certain objects in the displayList tree for rendering.


PROPOSAL #1: Rendering is turned off when stage.frameRate is set to 0.

BENEFITS:
- Turn off constant rendering
- Developer must designate items to render via the method below.


PROPOSAL #2:
flash.display.DisplayObject.render():void

BENEFITS:
- Render a sprite and any child objects ondemand
- Pre-render DisplayObjects not attached to the DisplayList
- Render only part of the displayList tree. MySprite.render vs stage.render()


The other way to go is to have modes for the renderer like so:

flash.system.System.renderMode = flash.display.RenderMode.CONSTANT;
//todays default behavior

flash.system.System.renderMode = flash.display.RenderMode.ONDEMAND;
//no rendering but you get enterframe events

I know this would be a powerful API in the hands of game and application developers and would allow a developer to turn off rendering once an animation completed. Obviously it isn't perfect but then again what is? I would love to hear your thoughts on adding a rendering API into Flash Player.

FEATURE REQUEST FP-4218

The proposal has been submitted as a feature enhancement using the public process. Once filed feature enhancement are routed to the Flash Player Product Managers for review. If you have features you want to see, feel free to submit them here.

Cheers,

Ted :)


Configuring ActionScript-Only AIR projects with Flash Builder 4

DIGG IT!     Published Tuesday, March 23, 2010 at 1:27 PM .

There is a trick to setting up an AIR Application using ActionScript-only within Flash Builder 4. Here is how to do it:

1. File > New > "Flex Project"
2. Choose a Project Name: "Foo"
3. Select "Desktop (runs in Adobe AIR)"
4. Press "Finish"
5. Delete "Foo.mxml"
6. File > New > ActionScript Class named "Foo" with "flash.display.Sprite" as SuperClass
7. Press Finish.
8. Right Click on "Foo.as" and press "Set as Default Application"
9. In Foo.as, add this line in the constructor:
"this.stage.nativeWindow.visible = true;"
10. Run & Done!




Here is a sample "Foo" Project for Flash Builder 4: Download

Assuming you used the exact name of the generated MXML file, you project is 100% ready to run, debug, and profile. Within the MXMLC compiler, MXML files are translated into ActionScript classes just before compilation and if you use the same base name, they are interchangeable.

So why use ActionScript Only AIR projects? Mobile.
I have been using this workflow since pre-MAX for mobile application development. It works seamlessly with AIR on mobile.

Cheers,

Ted :)


Jiffiness - Flash Player 10.1 gets a new clock!

DIGG IT!     Published Tuesday, March 02, 2010 at 9:28 AM .

Tinic Uro of the Adobe Flash Player engineering team knows way to much about time. Tinic posted on some internal changes to Flash Player 10.1 Beta 3 and is the first to talk publicly about the timing model updates. These changes are very significant for Flash and Flex developers and designers as they impact how content runs cross-browser, cross-platform, and cross-device.





Changes:

Benefits:
It is a great change for Flash Player 10.1. Regardless of which browser or operating systems or device you use, we will see Flash content playback more consistent and performant across screens.


Flash 10.1 Beta 3 Download

Jiffies via Wikipedia

Cheers,

Ted :)


Bugs Fixed in FP10.1B3

DIGG IT!     Published Tuesday, February 23, 2010 at 8:24 PM .

Download and Test Flash Player 10.1 Beta 3. Special thanks to all the content owners, developers, and customers who logged bugs against Flash Player 10.1 Beta 2, you made a word of difference. Here are the bugs fixed in FP10.1B3:

Graphics:
+DisplayObjects with overlapping strokes sometimes disappears when redrawn
+[FP-3621] Removing and re-adding a Flash movie from the DOM using removeChild and
appendChild causes display issues in Internet Explorer
+[FP-2290] PerspectiveProjections have problems with click events
+3D Facebook game renders incorrectly in Beta 1 and Beta 2
(http://apps.facebook.com/dealornodeallive/)
+'Show Redraw Regions' draws on the entire swf even though only a part of it is changing.
+Images render blank when scaled to specific sizes see example.

Networking:
+The Settings dialog doesn't correctly allow Local Storage requests.
+[FP-1050, FP-1358] Escalation - Active Directory is causing Local Shared Objects to fail when the
information is saved on a network location.
+Safari Only: File Reference upload test always results in a cancelled event.
+Time stamp doesn't get properly set in the request using URLRequestHeader.
+FileReference.download does not return an error even it doesn't have enough space to save the
file to download.
+[FP-1585] loaderInfo Event.COMPLETE not dispatched if wmode is "transparent" or "opaque".
+[FP-2746] Multi-domain inter-VM LocalConnection failure

Audio/Video:
+[FP-3567] Firefox Crash/Hang when running music on Playlist.com
+[FP-3921] Flash Player 10.1 beta 2 crashes Internet Explorer 8 in 32bit mode on Playlist.com
+In Firefox, clicking quickly on the stop music / play music button before it has completed loading
the music, causes a crash
+[FP-3675] Windows energy saving does not work after viewing video in full-screen mode
+Support for the Broadcom BCM70015 ("FLEA") hardware decoder support is not yet enabled.
+NetStream.Buffer.Full event is not fired correctly.
+On Broadcom graphics accelerators, NetStream.Step.Notify event doesn't fire when seeking
backwards on video playback.
+Video loads slowly or crashes on Internet Explorer when using Nvidia graphics card.
+Systems with NVidia graphics processors crash on certain videos on dailymotion.com
+Toggling between SD and HD on youtube.com causes a crash on Broadcom Graphics
Accelerators.
+Audio Stream stays open when playback is paused not allowing computers to be place to sleep
+Clicking on/off HQ or HD button on some of the Youtube and CastTV.com trailer videos causes
intermittent crash.
+On certain graphics cards, green artifacts appear when seeking in video.
+[FP-1399] Videos on nbc.com do not play on Linux OSes.
+With hardware decoding, cbs.com pause/play video buttons and seeking function intermittently.
+On Systems with XP and ATI Graphics cards, hulu.com video can hang after a seek
+On systems with a Broadcom Graphics Accelerator, seeking on youtube.com videos can result in
a crash.
+On the Mac PPC, Safari crashes when streaming a video from some web pages
+Audio sync issues when streaming FLV over RTMPE on systems with a Broadcom Graphics
Accelerator.
+Some videos have their first few frames dropped on systems with a Broadcom Graphics
Accelerator.
+Some videos crash intermittently on a Broadcom Graphcis Accelerator.
+[FP-3081] Some videos on http://www.cbc.ca/video/ never begin playing on Linux OSes
+Americanidol.com videos play only on mouse move in Firefox browser in Vista 64-bit OS
+Video freezes sometimes when using multi-bit rate streaming in conjunction with hardware video
decoding.
+Scaling of videos (fullscreen) causes blockiness or pixilation.
+Youtube video stalls after seek backwards.
+Calling close after calling seek without calling play first won't actually close stream.
+Attaching and detaching Audio while publishing with record option leads to loss of data.
+Problem in playing only audio or only video after audio video h264 streaming in same subscriber.
+When AAC is published from FME, setting buffer from default or 0 to something else e.g. 1 causes
playback stop with buffer length growing.
+Play video then stop, remove from the display list, the CPU usage is about 2.5 - 3.8% higher then
before playing the video.
+Live mp3 playback loses audio after 20 min or so.
+[FP-220] Video stops playing if one right clicks in the browser, even if its in a different tab.
+Screen dimming while playing video in fullscreen mode.
+Audio playback worsens on Mac while switching browser tabs with certain videos.
+[FP-178] -Video.clear fails. Clears only 1 pixel when Video.smoothing = true.
+[FP-1936] win32 microphone deadlocks on unplug active USB microphone.

Text/Text Input:
+[FP-3742, FP-3186] Characters appearing twice when typing in a text input field
+Escaping and then unescaping 4 Japanese characters doesn't unescape the last character.
+In multiline input text field, 'End' key does not work correctly. It moves caret to left of last character.
+[FP-3562] In certain situations (https://www.oceaniacruises.com/ships/dining.aspx) only one text line displayed in fields with multiple lines.
+[FP-777] Truncation occurs on fonts using advanced anti-aliasing in TextField instances with the autoSize property set to true.
+High memory usage when using a longer string in TextLine.
+Text with tracking applied does not align to tab stops correctly.
+Tracking should not visible after the last character of tcy block.
+ElementFormat.trackingLeft and ElementFormat.trackingRight are incorrectly applied to
GraphicElement.
+Justify all lines with "Track Right" and "Track Left" leave an empty space after and before each
line respectively.
+Kinsoku Can't-Begin-Line character and Can't End-Line character. settings is ignored if a
character in front or after is tcy.
+FTE TextLine.textWidth exceeds the specified width causing horizontal scrolling problem for
Gumbo TextArea.
+[FP-836, FP-838] Player needs Unicode character input: Hindi, and Maltese characters with
accents do not show up properly.
+[FP-40, FP-501] Cannot enter Chinese characters MS IME or even the @ symbol on a German
keyboard in input field on Firefox when wmode is set.
+Arial Black is not being measured correctly when used with FTE and TCAL/TLE, etc
+[SDK-18311] Setting scrollRect or mask on a DisplayObject breaks sub-pixel font rendering.
+Soft hyphenations don't appear in one-word text lines.
+SWF built to use CharacterRange and new InteractiveObject methods for IME and MSAA support
won't run on Flash Player 10.0.22.
+[FP-1877] Can't input Japanese characters in text field if wmode "opaque" or "transparent" is set
true except IE.
+[FP-40] International text entry broken in Linux reports in Flash Player 9.0.48 or higher.
+On Mac, a textInput event is fired after the users presses Command+Z. On other platforms, this
event is suppressed.
+TextLine using Bauhaus 93 font causes runtime exception.
+Double byte characters can't be input in Firefox Mac.
+TextField variable performance issue.
+Key-in 80 2-byte Chinese characters with MS Pinyin IME 2003 , display as "?" on Windows XP
and Vista in terms.
+Event flash.events.IMEEvent.IME_COMPOSITION does not fire in 'test movie' in Flash
Professional when composing Chinese, even using MS Pinyin IME 3.0.
+Arabic vocalization diacritics Tashkil are not rendered correctly.
+TextInput is newly broken in IE8 when running flash content in any windowless mode.
+Pressing ALT deletes selected text from a TextInput when wmod=transparent.
+Ideographic Space AKA Full Size Double Byte Space is changed into "@" with IE7, Flash 10 and
WinXP.
+Cursor and selection behavior is incorrect around control spaces. (2273650)

General:
+General stability and performance improvements
+[FP-383] ExternalInterface.objectID is not set
+Performance has decreased for the ByteArray and Vector objects.
+Settings UI does not respond to clicks. Firefox Only / PPC.
+[FP-3226] Flash objects have to be clicked once before interaction is possible using the mouse
+Clipboard keyboard shortcuts don't function in Safari 3 and Safari 4.
+[FP-3354] Certain games at the Atari site can cause a crash
+[FP-3411] Performance of ByteArray and Vector classes dramatically lower than Flash Player 10.
Runtime error 1221 is thrown on every third loaded image
+Performance of describeType() has degraded.
+File Reference filtering does not work properly on Mac OS.
+[Bugzilla 539328] describeType(Interface) output changed in FP v10.1
+[Bugzilla 487938] On Windows, invoking a modal dialog during a JavaScript animation with SWF
content causes Firefox to crash
+[FP-792] Class registered with registerClassAlias is accessible through different application
domain.
+[FP-3238] FileReference.download defaultFileName is broken in OS X.
+Rollover events don't work properly in Mac OS X and Firefox in certain circumstances
+AMF serialization doesn't work correctly with multiple ApplicationDomains
+jibjab.com videos control toolbar does not respond properly to the mouse moves in IE browser
+On Mac OS X 10.5 and 10.6, In the Google Chrome or Opera browsers, right-clicking to brings up
the context menu at the bottom left of the desktop.
+[Bugzilla 534857] Flash Player Beta 10.1 disables Crash-reporter (Breakpad) in Firefox on
Windows
+ActionScript object creation in 10.1 is more than 50% slower than it was in 10.0
+[FP-3526] On the Mac OS with Firefox, Flash Player playback pauses when bookmarks opened
+[FP-3530] Safari crashes or quit suddenly on the Mac when switching to next scenario during
play of http://www.scarygirl.com/world.php
+[FP-3568] Some games fail to load (http://www.greatdaygames.com/games/alus-revenge.aspx)
in Internet Explorer.
+[FP-2118] FileReference.upload does not support files 0-bytes in size.
+Cannot do paste with keyboard shortcut (CMD+v) in Flash Player applications on Safari/Mac.
+Clipboard keyboard shortcuts don't function in Safari3 and 4.
+Flash Player now offers scroll-wheel support in browsers that support Cocoa events, such as
Apple's Safari 4 browser.
+flash.trace.Trace doesn't return packages for methods in the classes which are internal.
+rollOut not received when a hovered descendant is removed from the display list.
+[FP-2563] Saving a SharedObject larger than 10MB always returns "SharedObject.Flush.Failed"
from Local Storage increase dialog.
+General webcam/microphone functionality not working.
+[FP-922] mouseX, mouseY value changes on external click in Mac plug-in.
+[FP-2009] CPU Utilization in an idle app is more than expected on Mac.
+Objects with negative origins fall out of the tab order.
+[FP-1034, FP-809] Flash Player can not save over files initially saved with a browser IE 7 on a clean Vista Home machine or Ultimate Vista with UAC enabled.
+Stage-placed SimpleButton references not defined in time for frame scripts
+[FP-1633] Full screen message is not localized in Czech.
+[FP-2630] Capabilities.os doesn't return specific Windows 7 string, but just a generic "Windows"
string instead.
+[FP-2428] Buttons are null when navigating from frame to frame if a button contains a MovieClip.
+Pressing a key causes a Sprite to be pinned in memory.
+Page Down and Page Up keys do not trigger key events when testing with Safari.
+[FP-702] PrintJob page size incorrectly returns values that include non printable margins.
+[FP-1025] Player 10 detection failure after reboot, Vista.

Browser
+[FP-3765] Full screen mode doesn't work in Chrome
+Firefox crashes when visiting Blackberry site while spoofing as IE
+In Chrome, Flash Player crash @ memcpy


Flash - An open interactive medium

DIGG IT!     Published Monday, February 22, 2010 at 9:06 AM .

Flash is an open interactive medium. In creative hands it can be used to build advertising, documents, video experiences, games, applications, art, music, graphs & charts, meetings, graphics, 3d content, and much much much much more. Flash was a success long before video arrived on the web and given open ended capability of the medium it will be around for a very very long time.



One problem with Flash is that as an open interactive medium, designers and developers can do anything with it and often do. There are no SWF approval police or terms of use for Flash content, it is the wild west of interactivity. This freedom has allowed Flash to create simultaneously both the best and worst user experiences on the web. Many users have a negative experience with web advertising but that doesn't make de-facto medium, Flash, bad. Many developers push Flash to its technical limits and fail to optimize their content in regards to CPU and memory consumption. Developers are allowed to openly succeed or fail with Flash without restriction. Platforms should never limit creativity, they should enable it openly and this strikes at the core as to why Flash has succeeded for so long. Flash is truly an open interactive medium where anyone can succeed or fail.

Flash will never stop innovating both inside and outside of Adobe. The Flash ecosystem is one of the greatest in terms of creativity and technical ingenuity. Internally we are constantly shocked by what developers are trying to accomplish with the medium. Internally Adobe is focused on building a quality high performance platform to support the new and emerging use cases of Flash. Moving forward we will see amazing capabilities added to Flash that rival the last 10 years of innovation on Flash Platform.



We are days from seeing the full scope of the Flash Player 10.1 and there are lots of improvement in quality and performance we have never talked about. For the next few weeks I am going to be highlighting key improvements within Flash Player 10.1 with the help of the Flash Player team. There is a ton of amazing engineering to talk about and I am very excited about Flash Player 10.1 Beta 3 arriving this week.

Flash is an amazing medium and is truly limited only by the design creativity and developer quality applied to it.

Flash Forward!

Ted :)

UPDATE: "open" links related to Flash
SWF Specification - Make your own player to run SWF.
AMF3 Specification - Exchange serialized data with Flash Player.
Tamarin Virtual Machine - The vm in Flash Player is open source here.
Open at Adobe Video


A breath of fresh AIR: AIR on Android

DIGG IT!     Published Sunday, February 14, 2010 at 9:01 PM .

Tonight Adobe announced AIR for Android at Mobile World Congress. The new AIR runtime allows any Flash/Flex developer to create standalone applications on Android. The runtime is very fast and is highly optimized for low cpu and low memory conditions on mobile devices. Given the explosion of Android devices, developers will be able to widely deploy AIR apps in late 2010.

Here are some screen shots of the apps running at the Adobe booth at Mobile World Congress. I would highly recommend trying some of these applications out at the show.














Special thanks to the Zephyr team and the external developers who build applications in partnership with Adobe for Mobile World Congress. You rock! :)

It is going to be a very exciting year ahead.

Cheers,

Ted :)


Improve Flash 10.1 and AIR 2.0

DIGG IT!     Published Sunday, February 07, 2010 at 7:53 PM .

Adobe engineering is headed into the final stretch of development of Flash Player 10.1 and AIR 2.0. We need community help to identify quality issues with your deployed and in-development content. While both Flash and AIR are tested extensively internally, every beta we receive valuable feedback from the Flash community and beyond.

Here is how you can get involved:

Download and install Flash Player 10.1 Beta 2 and AIR 2.0 Beta 2

Test the new beta runtimes with your content and applications.

Log bugs at bugs.adobe.com. Engineering teams use your bug reports to reproduce errors and improve the runtime quality.


As far as beta timelines, beta 3 releases are a few weeks away and release candidates are expected within 60 days. Your involvement and assistance during this critical development window is really important and will only improve Flash Player and AIR quality.

Please also help spread the word about the beta process via Twitter:
Improve Flash 10.1 & AIR 2.0 via Beta 2 http://bit.ly/cty7Nm READ & RT #Flash #AIR #QUALITY

Special thanks

Ted :)


Simple Method Closure in AS3

DIGG IT!     Published Friday, January 15, 2010 at 3:23 PM .

Method closures allow you to bind variables into the scope of an anonymous function. Watch the value of local variable 'i' in the example below in the returned anonymous function. It is a bit twisted but results show the scope of local variable 'i' is bound in the returned function from newCounter.

CODE AT PASTIE

package
{
import flash.display.Sprite;

public class ClosureAS3 extends Sprite
{
public function ClosureAS3()
{
init() //giv-em-the-jit :)
}

public function init():void
{
//create a counter
var counter1:Function = newCounter();
trace( counter1() ); //1
trace( counter1() ); //2
trace( counter1() ); //3
var counter2:Function = newCounter();
trace( counter2() ); //1
trace( counter2() ); //2
trace( counter1() ); //4 --> scope of i is still with counter1...cool! :)
}

public function newCounter():Function
{
var i:int = 0; //variable i gets bound into returned anonymous function via method Closure
return function():int
{
//i is available to the scope of the anonymous function
i=i+1;
return i;
}
}
}
}

Scary, functional AS3. :)

Cheers,

Ted :)


Making Su (sudoku)

DIGG IT!     Published Thursday, January 14, 2010 at 12:23 PM .

Mid November I wanted to develop a Sudoku puzzle for AIR/Flash Player/iPhone called Su. The geeky hidden goal of the project was to keep the game very simple relying on as few event listeners as possible and having as few display objects in the player at any one time. At first I went about exploring how to take a simple game data model (Array) and render out the state of the game using many display objects. In a 9x9 sudoku puzzle that meant 81+ displayobjects at a minimium. Not that player can't manage this number of items but keeping track of all the items got to be fairly tedius and memory intensive. This is when I switched over to using bitmaps and drawing bitmaps dynamically at runtime...aka blitting.



Blitting at its most basic is when you take one bitmap and draw it into another image potentially many times. AS3 has a great bitmap API that makes it easy to draw graphics. In moving to a rendered game board, 81+ displayobject were removed from the display list and better would not require any textfields, movieclips, sprites either. With 3 events listening at the stage I could create a 100% rendered game. Here is some simple rendering code I used to get started:

gameBoard.bitmapData.draw( m1.bitmapData , new Matrix( 1 , 0 , 0 , 1 , 100 , 100 ) );
//draw the bitmap "m1" into gameboard at x:100,y:100


It is that simple to render bitmaps into each other. If you want to remove image data simply do this:

gameBoard.bitmapData.fillRect( gameBoard.bitmapData.rect , 0 );
//fill gameBoard with empty data erasing the image.


or

gameBoard.bitmapData.fillRect( new Rectangle( 100, 100, 100 , 100 ) , 0 );
// cut a 100x100 hole at x:100,y:100 in gameBoard


Once I started bliting, I also noticed that my memory consumption was a flat line. Memory never went up or down as I was simply reusing the memory that had been allocated initially to the bitmaps. When you write one image to another, memory consumption does not change, you simply overwrite the data in place with new data.

The next step was organizing the data model to handle history and undo. Using a simple pattern I would change the gamedata array and keep an array history of all game changes, then rendering the single change. When you press undo, I would change the data model and render the deltas. The result was that only the initial game board rendering was expensive (I use expensive relative to rendering the whole gameboard every change).

The great part about this architecture was when I took the game to mobile. On iPhone and other phones (Flash 10.1 on Mobile) the game runs very very fast with no latency. Sudoku is not a fast paced game but it is played over a long period of time so I needed to be careful with resources consumed.

The other element I rather enjoyed was creating a VirtualHitArea class. Typically I use displayobjects to determine hitarea (buttons/movieclips/sprites) but you can virtualize this in stage event listeners. The VirtualHitArea class provides a way to add hitareas that conditionally react if clicked (MouseEvents) or touched (TouchEvents). The result is virtual buttons that add no displayobjects to the overall application but filter stage events to see what is hit when. One side effect of this was the ability to cancel all events in the capture phase. This truncates the DOM level 2 events bubbling across the displaylist and sort of hotwires it. Because events do not need to cascade across the displaylist, they are processed quickly in the VirtualHitArea class at the stage and then canceled.



Su was a fun expieriment in minimalistic programming using Flash Player/AIR and I learned a ton writing it.

cheers,

Ted :)


Sizing AIR NativeWindow to Stage

DIGG IT!     Published Wednesday, December 23, 2009 at 4:36 PM .

There is a big difference between nativeWindow size and the stage size within an AIR application. Depending on what type of window you are displaying and what OS you are using, the actual size of the stage may vary wildly. This post will cover how to determine the system chrome metrics and resize the nativeWindow in both Flex 4 and AS3. Here is how it works:

My application is a Sudoku puzzle app (320x480) and I wanted it to have chrome matching the native OS of the end user. Given I know the stage size, I needed to dynamically measure the system chrome metrics and resize the surrounding nativeWindow to provide a stage properly sized to 320x480. My app was written using AS3 but the same problem holds true with apps in Flex or Flash Pro and I have included source for both Flex and AS3 to help you get started.

When applications in AIR initiate, they have a logical process they go through.

1. NativeWindow is built from application.xml running ADL
2. Application constructor is called in SWF
3. During the first frame render, this.stage and this.stage.nativeWindow are available and sized correctly.

To be able to set this.stage.nativeWindow, it needs to be called after the first frame render or else metrics will not be fully set. To make sure, I test for the presence of this.stage and this.stage.nativeWindow in an enterFrame event when using AS3 and in Flex I use the applicationComplete event and everything is ready to go.

ASSUMPTION: We will assume that the width and height properties set in the application.xml are the desired stage size for the app (not nativeWindow size but stage size) and then adjust the nativeWindow larger depending on chome boundaries.

HINT:
AS3: nativeWindow is a property of this.stage
Flex: WindowedApplication has a nativeWindow property but also includes this.stage.nativeWindow. (they are the same object)

To determine the chrome width and height I used this calculation:

var chromeWidth:int = this.stage.nativeWindow.width - this.stage.stageWidth;
var chromeHeight:int = this.stage.nativeWindow.height - this.stage.stageHeight;

At the start of your application this.stage.width and this.stage.height will be 0!!! If you use this.stage.stageWidth and this.stage.stageHeight it will save you some level of frustration. In Flash the stage.width and stage.height are determined by content (no content they equal 0) but when empty, stageWidth and stageHeight will give you proper values.

Then I add chromeWidth and chromeHeight onto the nativeWindow size to make stageWidth and stageHeight match your content to the pixel.

this.stage.nativeWindow.width += chromeWidth;
this.stage.nativeWindow.height += chromeHeight;

To make this seamless and invisible to the end user, you make the nativeWindow invisible at start-up (the default) using application.xml and making it visible once you set the correct size of the nativeWindow width and height. This way the user does not see the window resize.

In Flex using WindowedApplication the window is made visible when the ApplicationComplete event occurs.

EXAMPLE DOWNLOAD
In this Flex 4 project there are 2 apps, one is AS3 and one is Flex. Simple select one or the other to run it. Both provide a stage that is 250x250. To change the size, simple change the width/height values within the application.xml file.

Go make some great apps with a properly sized nativeWindow!

Cheers,

Ted :)


CoolIris Express Launches - Put a 3D wall anywhere using Flash Player

DIGG IT!     Published Tuesday, December 08, 2009 at 9:53 AM .

CoolIris launched their Express online editing tool for making 3D walls. The app generates a Flash 3D wall with photos or videos. Here is one I made in a few seconds for MAX 2009:



Cheers,

Ted :)


Demos & MAX at Adobe - A new role

DIGG IT!     Published Thursday, November 19, 2009 at 9:24 AM .

Today I start a new role at Adobe focused on keynote demos and our annual conference, Adobe MAX. As a developer, I love building software and as an evangelist, I especially love highlighting the great work the community creates. Flash, as a platform, stands apart in that every day new experiences are released that shape the future of software. Over the past 5 years, Flash has moved far beyond its animation roots and now powers applications, video, ads, and gaming making both the public and private web a better experience.

My new role is focused on highlighting the work of our community, showcasing amazing uses of the Flash Platform inside and outside of the firewall, and building demos around new technology. We need to showcase great applications to move the ecosystem forward and when we have new technology to show we need to build demos in partnership with our ecosystem. In the weeks leading up to MAX 2009, I worked in partnership with Cynergy Systems, MLB.com, EA (Pogo.com) to deliver great demos for MAX keynotes. I am looking forward to expanding this work out to Adobe's ISVs, customers, and partners to both showcase amazing work and to highlight the road ahead.

I am also looking forward to another year of Adobe MAX. Although October 24-27, 2010 looks far away, work is already underway to make the event better. Having worked on MAX for 4 years in a row, things have come a very long way from the MAXUP in the hallway in Las Vegas and I know we can do better still. I look forward to working with everyone again making MAX 2010, the best one yet.

It is an exciting time for Flash and 2010 is looking to be one of the best years for the Flash Platform and the surrounding ecosystem. Feel free to contact me in regards to new applications and demos at ted@adobe.com. I look forward to working with you.

Cheers,

ted :)


Learning Fx4 from Scratch - Update 2

DIGG IT!     Published Tuesday, October 27, 2009 at 8:03 AM .

Yesterday I completed 4 new pages with 10 Flex 4 samples in Learn Flex 4 from Scratch. Now is really the time to start learning Flex 4 given the stability of Flex 4 Beta 2 and the volume of great session content available post Adobe MAX.

Here are the new sections in Learn Flex 4 from Scratch:

Element Creation
addElement, addElementAt, removeElement, removeElementAt
Element Properties
States

Have I told you that I really love States! They are my favorite feature in Flex 4 (thus far) and really make building applications much easier. The syntax change for States really makes them easy to read and use in your application. Prior to Flex 4 you placed all state property changes in tag so they were remote from the components they affected. In Flex 4, state code is added directly to the components themselves with dot notation.

I could go on and on about States but best to let you ready it over at Learn Flex 4 from Scratch!

Also I would love some feedback. If you feel I have missed something, I have enabled comments on the Learn Flex 4 from Scratch site. So feel free to leave feedback.

Cheers,

Ted :)







Learning Fx4 from Scratch - Part 1 - Application

DIGG IT!     Published Tuesday, October 20, 2009 at 5:45 AM .

Welcome to "Learning Fx4 from Scratch", this weekly series of blog posts will attempt to cover Fx4 beginning to end from a developer perspective.

Learning Fx4 from Scratch has MOVED!
Learning Fx4 from Scratch has MOVED!
Learning Fx4 from Scratch has MOVED!
Learning Fx4 from Scratch has MOVED!
Cheers!

ted ;)


Where to find me:

Ted on Twitter - @__ted__
Ted on Adobe Groups
Ted on LinkedIn
Ted on Facebook
Ted at Adobe

Latest

Lists

Links

Jobs

city, state, zip

Archives