Àíãëèéñêèå Flex è RIA áëîãè
| 2010-04-23 |
Swiz 1.0 alpha introduced a very cool new feature which lets you extend Swiz be creating custom metadata processors. This means that if you want to add a metadata like [MyCustomMetadata] you can now do so and Swiz offers you a very easy way to implement it. For the Swiz 360 Flex demo app I have build [...]
A few weeks ago I attended the SanFlashCisco usergroup meeting which was really great. After the meeting we moved to the Mars bar where I got to know Luke Bayes who founded Project Sprouts. Project Sprouts is a Ruby based open-source, cross-platform project generation and configuration tool for ActionScript 2, ActionScript 3, Adobe AIR and [...]
Thanks to all who joined the Swiz BOF session at 360 Flex in San Jose today.
John Yanarella and I got the opportunity to show Swiz and some examples. We even had Chris around via Skype and I hope you guys enjoyed it!
Here the links to the slides and code:
Slides Swiz1Example on GitHubMany thanks to John Wilker [...]
When you dispatch events I bet that most Flash/Flex devs don’t take advantage of the fact that dispatchEvent returns a Boolean value indicating wether or not the event has been canceled. Normally your code looks similar to this:
var event:MyEvent = new MyEvent(MyEvent.FOO); dispatchEvent(event)If you want to let something only happen if the event wasn’t canceled it [...]
GitHub with Pivotal Tracker is the killer agile combination. With the just release Tracker v3 API update it is now easy to connect them.
You only have to configure GitHub Post-Receive Hooks so you can automatically deliver stories/bugs by providing the Tracker ID in the commit statement like: Fixes #TrackerId
How to set it up:
Create a Pivotal Tracker [...]I ended up a few times with these kind of errors while migrating to newer Flex 4 builds:
Description Resource Path Location Type 1044: Interface method invalidateParentSizeAndDisplayList in namespace mx.managers:ISystemManager not implemented by class _Main_mx_managers_SystemManager. example-project line 23 Flex Problem
Description Resource Path Location Type 1144: Interface method callInContext in namespace mx.core:IFlexModuleFactory is implemented with an incompatible signature in class _Main_mx_managers_SystemManager. example-project line 23 Flex Problem
The location/resource for these errors is the main MXML [...]
I have a project based on Flex 4 Beta 2 and now I wanted to migrate to the latest nightly build since there were many important fixes. Things have changed so here what I did to get my project up and running again:
Halo is now mx
The namespace for halo (Flex 3) components changed from xmlns:mx=”library://ns.adobe.com/flex/halo” to xmlns:mx=”library://ns.adobe.com/flex/mx”. [...]
A while back I worked on an AIR client which had to be capable uploading very large files. In this scenario you have to upload files in little chunks. The research on how to solve this took me quite a while so I thought it would make sense to post my findings.
More or less I [...]
I have build a little Twitter AS3 library which handles Twitter OAuth authentication and let’s you update your Twitter status. The lib basically uses the OAuth AS3 lib and should be a good example how to use the actual OAuth lib.
This is still basic functionality but since it’s open source someone may fork and extend [...]
When you develop AIR applications you see repeating tasks which you have in all projects. You need to take care about the update process and online status. I am developing all my applications with the Swiz framework so I tried to come up with some re-usable code which fits nicely into Swiz.
Source and Download
Get source [...]| 2010-04-22 |
Lately, Adobe representatives and Flash fan boys alike became more vocal than usual about the alleged openness of Flash. This is probably spurred by the proposed feature set of HTML5, as well as the decisions of a certain vendor to ban Flash from some of their products, both potentially being threats to Adobe and the Flash Platform.
I originally posted the following article as comment to an article by Serge Jespers, “Flash is as open as HTML5“. Serge is an Adobe Platform Evangelist. I thought this comment deserves its own post, so here we go.
No, it isn’t.
And it is beyond me why so many independent Flash Platform developers fail to see it. I completely understand of course why Adobe evangelists downplay it.
It is irrelevant for the so called “open web” whether the Flash Player is going to get open sourced or not. That’s not the point. Microsoft won’t open source their browser, Opera won’t open source their browser, etc.
Relevant is who decides about the development of the data format that a runtime consumes, and the APIs a runtime provides to access that data. In the Flash world that’s SWF and the Flash Player APIs, both controlled by a single vendor: Adobe. In the HTML world that’s HTML and DOM, controlled by many vendors, including you and me, via standards bodies.
Adobe neither provides formal means for other companies and individuals to participate in the development of SWF and Flash Player APIs, nor does it provide detailed work-in-progress specs to the general public for discussion. This effectively rules out the possibility for third parties to provide alternative runtimes. The runtime and its specs are released to the public at the same time.
This is the exact opposite of “open”.
To make matters worse, the specs released by Adobe are incomplete and buggy (e.g. the SWF spec fails to explain how exactly shapes are supposed to be rendered and leaves out information on codecs, the ABC spec is plain wrong on some things) and generally infested with patented technologies.
Of course i understand why it is how it is (and likely always will be). If Adobe were to become truly open and put the development of SWF etc in the hands of standards bodies, the 1.5 year release cycle would become a 10+ years release cycle. Innovation would slow down significantly. I as a Flash Platform developer wouldn’t want that to happen.
However, sorry to say that, but to tout “Flash is as open as HTML5
| 2010-04-21 |
As the geek sits down to learn a new programming language or new programming platform, the first thing he or she must do is learn to make a program that successfully prints the words “Hello, world!” to the screen.
The main significance of this first minor feat as it relates to the programmer is not epistemological, technical, or temporal, but psychological. Crossing the — shall we call it the “Hello world” threshold? — brings with it the realization of the existence of a universe of infinite possibilities. But also the burden and intolerable vertigo that comes with that sense of unlimited freedom.
For, alas, there is no standard “second program” for the geek aspirant to sit down to write. The programmer is on her own. Of the potentially infinite paths that lie in front of her, which will she choose?
Actually though, the most common second program chosen with pedagogical motives in mind — I would submit — would be that venerated bouncing ball, colored 0xFF0000. If you come from a Flash background, you probably know of it well.
Here’s mine, on the Android platform- (Sure wish I could’ve used Flash 10.1… ;)
| 2010-04-20 |
I am working on a new document on Flash Ads performance, the idea of this document is to focus on graphical optimizations, cause ActionScript is rarely (sometimes it is) in fault in ads, and mainly created by designers. Flash ads talks to anyone, we all see them when browsing different websites, some of them are creative, some of them are not, some of them are optimized and some of them are not.
So what do I mean by saying optimized ?
As you can imagine, it is mainly related to CPU usage and memory, and how simple ads can sometimes require more CPU cycles than they should. So, I decided to browse the web for a day and gathered as much ads as possible, I had a large choice, and I decided to save different kind of ads, made of video, bitmaps, manually or programmatically animated. Let's just put this out there, the intention of this post is not to criticize people producing ads but better understand what kind of pitfalls designers and developers tend to fall into when producing ads and why. More than that, I am sure that most of these bad practices could be adressed by the tools by giving more feedback on how to produce optimized content.
First thing people tend to forget is how a shape can be simplified through tools like the Simplify tool in Adobe Illustrator or just through the Smooth tool in Flash Pro. A lot of control points can be removed from paths and dramatically reduce the size of the final SWF and improve rendering performance. Another issue, in order to bypass the size limitations and the usage of bitmaps, designers use dynamic filters for any effect they need. As you know it, filters are not CPU-friendly when overused, especially when nested and with attributes changing over frames. Each frame the filter has to be recalculated and this can slow down rendering performance and require extra CPU cycles. Same for transparency effects which can be avoided or truly removed by using opaque DisplayObjects (opaqueBackground).
Whatever coding environnement you use, assets may still be created inside of Flash, exported to SWC or SWF and then linked inside your project. For ads, most of the work is done in Flash Pro only, cause code used is not complex and can fit on the timeline only.
I am wondering what kind of things could be added to Flash Pro for for instance, to help designers and even developers to produce optimized assets in general.
Here are some features I thought about :
- Show Redraw Regions

This should be enabled by default in the IDE (when playing animations on the Stage) and animators, designers, developers, would better understand what is wrong and costing CPU cycles for nothing. Ex : DisplayObjects hidden by others and still being renderered and not deactivated.
- Expose the opaqueBackground feature in Flash Pro IDE just like cache as bitmap.
Sometimes transparency is not required, and designers could disable it by assigning a background color to any DisplayObject. This would make it easier for the Flash Player.
- Native Bitmap Rasterization
You select a MovieClip and rasterize each frame as a bitmap, produce bigger SWF's in some cases, but blazing fast in terms of rendering. This could be performed at runtime by the player too, but a first step would be doing it at authortime.
- Graphical effects presets for publishing
I create and save a publishing profile for Nike and I say, disable all the filters, the transparency effects and instantly see performance differences by checking and unchecking effects between different publishing.
- History Panel 2.0
The History panel in Flash CS5 would be enhanced by showing more than the size and time history but also average framerate, CPU and memory usage.
- Optimization Perspective and size limit
The tool could have an optimization perspective, which would audit your graphics and let you know about potential graphics optimizations to reach a specific framerate and size, with text rendering, fonts, control points reduction, etc.). It would allow you to specify a size limit and the tool would generate a report by saying you can compress that bitmap more, you can use device fonts here, etc.
- Having a "Warning Mode" for graphics.
The tool shows you a heat map of the graphics in your app, showing where rendering time is spent. Warn about what is costing a lot in memory and CPU like nested filters, animated filters, bad usage of cacheAsBitmap, non-simplified shapes, etc. This should be pretty cool in the profiler for Flash Builder too.
For the Flash Player, maybe an HTML tag (stricter than the hasPriority tag in Flash Player 10.1) which would restrict the SWF being played to consume a specific amount of memory and CPU, otherwise throttle down the SWF. Another solution would be automatically removing specific effects when the framerate and performance is critical ? Is that something you would prefer ?
Let me know if you think any topic should be covered in the whitepaper, I would be happy sharing your ideas about all that.
| 2010-04-19 |
My aim here was to get familiar with AIR 2’s new capability of interacting with external processes’ standard streams.
One useful way of learning how to use a new feature is to proceed directly to trying to abuse it.
To that end, this AIR application takes in a fairly continuous stream of uncompressed binary image data from a native process’ standard output. My hope was to get real-time screen capture updates into AIR at a decent frame rate.
Details and source code after the break–
The native process
For my “native process,” I created a Windows .NET application written in C#. When asked, it takes a screen capture of the desktop and sends the image data through the process’ standard output. For various reasons, I chose to set it up as a Windows form rather than as a plain vanilla console or as a real system service. The relevant C# code is only a few dozen lines long. One interesting function there is bitmapToBytes(), which converts a bitmap into a byte array in the correct format for Flash to be able to apply it directly to a BitmapData without any further (costly) conversion.
The AIR application
On the “client-side,” the Flash AIR application has little to do. It simply sends a command to the native process, telling it to take a screen grab, along with image dimension and offset parameters. Because the client takes in the resulting stream of data in packets whose length should not be assumed to be of any given size, it needs to know where in the data a new image starts and where it ends. So it checks the stream for an arbitrary 4-byte start code as well as a termination code. When the transfer is complete, it just applies the resulting data, collected over time into a ByteArray, using BitmapData.setPixels(). It then requests a new image, and so on.
Performance considerations
On a mid-range quad-core PC using 1280×1024 images (5MB per uncompressed frame), I’m getting about 8 frames per second, or 125ms per frame. The time it takes for the 5MB image to transfer through the standard stream is about 65ms, or 50% of the total time for one iteration; without setting up an honest benchmark test, it’d be unfair and/or impolitic to declare that AIR represents a bottleneck here, so … yeah.
The AIR app eats up about 2/3 of one CPU core using the runtime’s main application thread. The remaining 1/3 represents the amount of time the AIR app has to wait while the native process constructs the screengrab. If the app were re-architected in such a way that the native process always has a new screencap queued up and ready to send – leading to little or no idle time between request and response – the AIR app would easily soak a full CPU core. Since the AIR app is doing little of significance besides reading the process’s standard stream and collecting that info into a byte array, it appears that merely handling large amounts of stdout data is quite costly.
Of course, AIR 2 isn’t even final yet. Nevertheless, I thought these preliminary findings were interesting. (This build targets Beta 2, which is the most recent public beta of AIR 2; compiling and running it against the most recent non-public beta of the SDK and runtime dated April 9, 2010 gave the same results.)
Source files
Setting up a native process for use with AIR 2 is well documented so I didn’t bother commenting on that here. However, the included source is I believe a good starting point for adapting to whatever native process craziness you may be cooking up…
Main AS3 class file
Main C# class file
Full project source (Flash Builder 4 + Visual Studio 2008)
For another implementation of AIR 2 screen capture, see this post by Mihai Corlan, also with source, using Java. There are also a few other related examples out there as well.
Licensed under a Creative Commons Attribution 3.0 License.
| 2010-04-09 |
A year ago, I announced I would be working on a new open-source book called "What can you do with bytes?" distributed as a PDF (Note that the O'Reilly style cover on the left is just pure imagination and created to illustrate the PDF, no printed version planned).
With some delay, due to many projects lately, here is the first chapter covering the basics of binary data in Flash. This first chapter covers all you need to know to get started, from the roots of binary to counting and thinking in binary with bitwise operators in ActionScript 3 and your first steps with the ByteArray class. Each concept is illustrated with real world examples so that you can really see and understand its usage. Those who read "Pratique d'ActionScript 3" will recognize some parts of the ByteArray chapter. I completely refactored it, translated it and included more technical details.
This chapter illustrates that the ByteArray class can be used everyday even for simple stuff you did not imagine. I will post each chapter when they are available on the book page here. Grab this first one and let me know if you have any comments (errata or stuff you'd to like to add).
I am starting now the second chapter entitled "Everyday bytes" focused on using binary stuff on everyday life as an ActionScript 3 developer, from handling binary stream (XML, fonts, etc.) to RSL and runtime compression. This chapter should cover also the great AS3SWF and FZip projects from Claus and other funky byte-oriented libraries like AlivePDF, or FLVSlicer and more.
That`s what you get if you give little unpriviliged kids too much power.
Just imagine if a company like Microsoft would act like this megalomoniac a$$ho%6es.
I was really waiting for the new MacBook Pro with my credit card ready but now I`m honestly thinking about switching back to M$$ after 3 years.
It`s like finding out your new hot girlfriend listens to Nickelbag – what a dissapointment but at the same time maybe a refreshing eye opener.
Glad I can now save like 1500 bucks on my new PC and don`t have to spend them just to be cool – because Apple isn`t cool anymore.
| 2010-03-22 |

Apologies for the hiatus. Here I’m just expanding upon the ‘texture extraction’ idea posted before. This version maps video onto 3D objects in a much more direct manner by using ray-casting, like the examples in the last several posts.
Controls:
- Mouse rotates object
- Mouse drag moves object
- [SPACE] remaps the texturing of the 3d object
- [ENTER] cycles through different 3D primitives
- [H] shows full list of kludgey hotkey controls
Although this piece dispenses with the encumbrances of an AR marker or any application-like functionality, I think the method being used here has some potentially interesting uses for an augmented reality-based design application. (Or for more whimsical uses like “upload-your-face” done in 3D). I’ve disabled backface detection, so the imagery gets mapped on all sides of the object rather than just the camera-facing polys, which makes it more visually interesting.
Requires a webcam. Hopefully I’ll add a demo video soon.
| 2010-02-25 |
I am very happy to announce that I will be joining the Flash Player team as a product manager in the following months. I will be joining an exciting team in San Francisco and I will be reporting to Emmy Huang that you guys may know. Working in the Flash Player team has always been like a dream for me, I feel like crazy right now ready to work hard on the future of the Flash Player. I got everything ready, my pens, rubber and ruler and a lot of ideas, from a language perspective but also in terms of Flash Player APIs.
As I was saying during my interviews, Flash Player is a lot more than a simple video player, you can have 4 people using the Flash Player differently, from cartoons, to games, to websites (with video streaming) with ActionScript on top of it to make all that interactive to pure ActionScript projects without any external asset. This is what we saw again at the FITC this week in Amsterdam. So many people, using the same technology but differently. Erik Natzke will create amazing interactive design experiences and paintings, Chris Georgenes will animate a cute little monster in a cartoon, and advanced ActionScript coders will do crazy frameworks, work on CPU emulation or runtime audio tools or even complex data vizualisation applications for bank companies. To me, this is the power of the Flash technology, it talks to anyone, from design to code. I even met a team this year using Flash Professionnal, who did not even know what was a SWF, they were using the tool to animate and then export high definition PNG's to target HD TV's for broadcasting. The day after, I could meet a team who did not even know what was Flash Professional, and thought that Flash was just the Flash Player.
Oh there is a tool called Flash Pro ? Wow, did not know that
More generally, I also want the Flash Player to perform beautifully everywhere, and we are already stepping into this (See Tinic's post related to CoreAnimation). So many things come into my mind when I think about new stuff or improvements for an animator, an interactive designer or an ActionScript developer. I look forward to work with this incredible team and help driving the future of the Flash Player. Damn, I am excited!
| 2010-02-22 |
Michael and I wanted to show you the Flash Player 10.1 running on the Google Nexus One, we tried different kind of websites, from typical FWA websites to games to video players. All of these applications from Yamago, Soleil Noir, Deezer, Canal+ or Ecodazoo were built for previous versions of the Flash Player some of them were even compiled for Flash Player 6 actually using AS1, like the two first games and look how all these websites perform.
Flash Player 10.1 on Google Nexus One from michael chaize on Vimeo.
| 2010-02-18 |
Do you remember Banana Slice ? I already blogged about native rasterizing (bitmap slicing) in the Flash Player (here), but I realize I did not log a feature request in the Adobe bugs jira. I would love to see a native rasterizer in the Flash Player, which would rasterize or caches each frame of a MovieClip in order to get an animated bitmap to get nice rendering performance improvements when the MovieClip is played :

We could have a rasterize property to dynamically rasterize a MovieClip as bitmap frames to get super performance improvements :
MovieClip.rasterize = true
The MovieClip could contain a BitmapSequence extending InteractiveObject allowing you to access each bitmap frames. In some cases, this would consume more memory, but the developer should be able to choose between more memory usage and nice rendering improvements, just like cacheAsBitmap where you have to counter balance the pros and the cons. This feature could also be used by a designer or animator in the Flash Pro authoring tool. If you like the idea, please vote for this feature request :
http://bugs.adobe.com/jira/browse/FP-3945
When trying to create your own rasterizing engine, you may come into the situation where you want to know the real width and height of a DisplayObject having filters applied, like a BlurFilter for instance, in order to create each BitmapData frame, the following image illustrates the idea :

The code below retrieves the width and height of the MovieClip with getBounds, you notice that you got the same results for both MovieClips :
// outputs : (x=46.5, y=154.45, w=198, h=117.94999999999999) trace( mc1.getBounds ( this ) ); // outputs : (x=299.5, y=153.45, w=198, h=117.94999999999999) trace( mc2.getBounds ( this ) );
Same with the width and height properties. Of course you can calculate an approximation based on the filter properties and deduce an approximate width or height. You can also iterate through the filters property create a BitmapData object then use the generateFilterRect() method to evaluate the pixels dissolution value and estimate the final width, but well, that's not a really smooth way to achieve that. Having a DisplayObject.getFiltersRect() and DisplayObject.generateFilterRect() methods would be sweet. If you like the idea, please vote for this feature request :
| 2010-02-15 |
Paul Robertson and I just finished writing a paper about optimization for producing mobile content with the Flash Player 10.1. This whitepaper (87 pages) covers best practices for applications running inside a browser, but these best practices also apply to Adobe AIR or even the iPhone packager available in Flash CS5. It also covers some technical details behind some of the new features in Flash Player 10.1 through 9 chapters. From simple memory optimizations, to more complex rendering tips, you'll see that a single line of code can have a high impact on memory or CPU usage. Here are the chapters :
- Introduction
- Conserving memory
- Minimizing CPU usage
- ActionScript 3.0 performance
- Rendering performance
- Optimizing network interaction
- Working with media
- SQL Database performance
- Benchmarking and deploying
For the past few months, I have been playing with the Flash Player 10.1 on the Palm Pre, Windows Mobile. I just saw it running now on the Google Nexus, and I am really excited about it, it just feels good seeing a SWF running in a mobile browser
I hope you guys will enjoy the paper, you can browse the beta (some tiny modifications will be added to the document during the week) whitepaper online here, or just download everything packed as a PDF to always have it with you.
| 2010-02-11 |
So did you ever try to play Shoutcast streams in Flash? Did you run into memory leaks? Did the playback sound pitched or otherwise screwed? Fear no more. Let me introduce you to as3icy.
as3icy is a drop-in replacement for the Flash Player’s Sound object that can reliably play Shoutcast, Icecast and Limewire MP3 streams. And it extracts metadata info from the stream in real time. It also reliably plays VBR MP3.
DISCLAIMER IN CAPITAL LETTERS. This is experimental code. I basically threw this code together in two 24 hour coding sessions. Also, i know as much about sound engineering as i know about pottery – i blind-ported a big chunk of Java code (the excellent JLayer MP3 decoder, originally ported from C if i’m not mistaken) to Actionscript 3 without really knowing what i was doing. So expect a few WTF moments when reading through the code, and do not expect everything to work perfectly just yet.
Some known issues
- IT IS SLOW AND STRESSES YOUR CPU. Depending on the encoding, i get around 20-50% load on my 2.4GHz Core 2 Duo (Vista), which is way too much. On my MacBook Air 2.16 GHz: full load and playback chokes, which is unacceptable. There is plenty of room for optimization though, the code is currently not optimized at all. It’s probably worth taking a look at Apparat, or Alchemy in general for more performant alternatives to decode MP3..
- Only Layer III is supported (Layer I and II decoders not ported yet).
- Only 44100Hz playback is supported (up/down-sampling to 44100Hz not implemented yet).
- Only stereo modes are supported (mono not implemented yet).
- The stream parser seems to be with problems yet, sometimes it happens that it runs out of sync for some reason.
Also, Adobe AIR is recommended to play Shoutcast streams, for two reasons: The meta data interval is passed back to the client via HTTP response headers, which are not available in the plugin version of the Flash Player, and as soon as you put the thing online you need the streaming server to host a crossdomain.xml file. If you happen to have access to the streaming server, you can of course solve these issues by hardcoding the meta data interval and have the streaming server serve an appropriate crossdomain.xml, or by using a proxy script of some sort. Also, this only applies to playing Shoutcast streams. You can play static MP3 files (for example VBR MP3s) using as3swf in the plugin version of the Flash Player without any problem (security restrictions still apply of course).
A simple example: Shoutcast stream playback
package
{
import com.codeazur.as3icy.ICYSound;
import com.codeazur.as3icy.events.ICYMetaDataEvent;
import flash.display.Sprite;
import flash.events.HTTPStatusEvent;
import flash.net.URLRequest;
import flash.net.URLRequestHeader;
public class SimpleShoutcastPlayer extends Sprite
{
protected static const URL:String = "http://72.233.14.70/hype";
protected var icySound:ICYSound;
public function SimpleShoutcastPlayer()
{
var req:URLRequest = new URLRequest(URL);
req.requestHeaders = [ new URLRequestHeader("Icy-Metadata", "1") ];
icySound = new ICYSound();
icySound.addEventListener(ICYMetaDataEvent.METADATA, metaDataHandler);
icySound.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpResponseStatusHandler);
icySound.load(req);
icySound.play();
}
protected function httpResponseStatusHandler(e:HTTPStatusEvent):void {
// The HTTP_RESPONSE_STATUS event is fired when the stream is opened and starting to load.
var s:String = "Connected!";
if (icySound.icyName.length > 0) { s += "\rName: " + icySound.icyName; }
if (icySound.icyDescription.length > 0) { s += "\rDescription: " + icySound.icyDescription; }
if (icySound.icyUrl.length > 0) { s += "\rURL: " + icySound.icyUrl; }
if (icySound.icyServer.length > 0) { s += "\rServer: " + icySound.icyServer; }
if (icySound.icyMetaInterval > 0) { s += "\rMeta Interval: " + icySound.icyMetaInterval; }
trace(s);
}
protected function metaDataHandler(e:ICYMetaDataEvent):void {
// The METADATA event is fired when new metadata is available.
if (e.metaData.length > 0) {
trace("Now playing: " + e.metaData.slice(13, -2));
}
}
}
}
This code (Adobe AIR required) plays the Hype Machine live radio stream, and traces out general information about the station, as well as the names of currently playing songs.
Note that we set a custom request header, Icy-Metadata: 1. This tells the server to periodically send meta data with the stream. Under the hood, as3icy transparently extracts this meta data from the stream in real time and passes it to the application via the ICYMetaDataEvent. This event won’t be fired when the request header above is not sent.
The trace output should look something like this:
Connected!
Name: Hype Radio
Description: Radio powered by music blogs
URL: http://hypem.com/radio/
Server: Icecast 2.3.1
Meta Interval: 16000
Now playing: Collider - Time Concerns
Now playing: Rogue Wave - Birds (Neil Young cover)
Now playing: The Big Pink – Dominos
[..]
| 2010-02-06 |
Open Flash CS4, create new AS3 FLA, add as3swf.swc and paste this on frame 1:
import com.codeazur.as3swf.SWF;
var swf:SWF = new SWF(root.loaderInfo.bytes);
trace(swf);
Trace output:
[SWF]
Header:
Version: 10
FileLength: 149405
FileLengthCompressed: 149405
FrameSize: (550,400)
FrameRate: 24
FrameCount: 1
Tags:
[69:FileAttributes] AS3: true, HasMetadata: false,
UseDirectBlit: false, UseGPU: false, UseNetwork: false
[09:SetBackgroundColor] Color: #FFFFFF
[86:DefineSceneAndFrameLabelData]
Scenes:
[0] Frame: 0, Name: Scene 1
[82:DoABC] Lazy: true, Length: 149219
[76:SymbolClass]
Symbols:
[0] TagID: 0, Name: Untitled_fla.MainTimeline
[01:ShowFrame]
[00:End]
Excercise: Draw something on stage, and run the code again.
Want more? Drop by my session Hacking SWF at FITC Amsterdam (Feb 22th, 16:00).
[Edit] Jim Cheng deserves credits. He was the one who whispered “root.loaderInfo.bytes” into my virtual ear on IM.
| 2010-02-04 |
Started my first serious app with Flex 4 and i can`t tell how much I enjoy it.
Have not heard so many AHHHS, WOW, F$%CK Yipiiiiiiiee from myself while developing for quite some time.
Don`t really want to add to the fake HTML 5/Flash is dead discussion (have not yet seen a year without this talk
)
Only thing I can say is that great tooling and proved frameworks really matters to me…
Flex 4 – I love you!
| 2010-01-19 |
Connecting game controllers to the Flash Player is something I experimented in the past with FlashStick and a few years ago with WiiFlash with Joa. One of the limitations with those implementations is that you had to launch a standalone server acting as a gateway between the hardware and Flash. This was usually done through the use of binary socket which usually could bring some headaches due to the Flash Player security restrictions. The server also had to be started manually and this was a required dependency making applications deployment harder.
With AIR 2.0 and the native processes things are now made easier if you want to connect a physical device to ActionScript. Just embed your native application (Java, C, C#, F#, etc.) and communicate with it through STDIN and STDOUT. Of course, the Java runtime will be required if you are using a Java app, and .NET if you need it in your C# or F# code.
Yesterday, I thought about connecting game controllers to AIR in a simple and more abstract way so that any game device, whatever it is could be connected and its info retrieved in the AIR application. This way, a game could be distributed and whatever the device plugged (XBox, PS3, etc.) this would work. I came across JInput, a Java library which does the hard job for me :
The JInput Project hosts an implementation of an API for game controller discovery and polled input. It is part of a suite of open-source technologies initiated by the Game Technology Group at Sun Microsystems with intention of making the development of high performance games in Java a reality. The API itself is pure Java and presents a platform-neutral completely portable model of controller discovery and polling. It can handle arbitrary controllers and returns both human and machine understandable descriptions of the inputs available.
I created a simple Java wrapper as a prototype to communicate between Jinput and AIR and reverse, the Java code is incredibly simple :
class Main
{
public static void main (String[] args)
{
Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
Controller currentController;
List<Controller> currentGameControllerArray = new ArrayList<Controller>();
int lng = ca.length;
for (int i = 0; i < lng; i++)
{
currentController = ca[i];
System.out.println( "Found Device : " + currentController.getType() + " known as " + currentController.getName() );
if ( currentController.getType() == Controller.Type.GAMEPAD )
currentGameControllerArray.add(currentController);
}
System.out.println(currentGameControllerArray.size() + " game controllers found!");
}
}
On the ActionScript side, you just read the stream using the ProgressEvent.STANDARD_OUTPUT_DATA event :
output += process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);
Just like a socket server, the Java code is pushing the real data to ActionScript just like a socket connection :
DataOutputStream dataOutputStream = new DataOutputStream(System.out); dataOutputStream.writeChars(controllerName); dataOutputStream.writeInt(controllerId); dataOutputStream.writeFloat(analogX); dataOutputStream.writeFloat(analogY); dataOutputStream.flush();
This way, just like in WiiFlash, a simple AS3 wrapper could be created to let you communicate with any game controller connected to the computer :
var controllers:Vector.<IController> = Controllers.getControllers();

The image on the left illustrates the early prototype. By clicking the Scan Devices button, the Java library scan devices and send the report to AIR.
The cool thing with JInput is that any kind of device can be detected and interacted with like a joystick, a fingerstick, a wheel mouse, a headtracker, a trackpad, etc. As soon as I got more time, I will post an early version of it with sources so that people can contribute and test it!
| 2009-12-28 |
Let me introduce the new version of ScaleBitmap :
I have totally rewritten ScaleBitmap to suit my needs :
The outer drawing & ScaleBitmapSprite allows you to :
Usage 1 : ScaleBitmap
ScaleBitmap.draw( bitmap : BitmapData, // the bitmap source graphic:Graphics, // the destination graphic width:Number, // width (defined by outer rectangle if not null) height:Number, // height (defined by outer rectangle if not null) inner : Rectangle, // inner rectangle for scale 9 outer : Rectangle=null // outer rectangle : visual size reference ):void
If outer is not null, ScaleBitmap use a negative offset for drawing (according to outer properties)
If outer is null, ScaleBitmap works as a classic Scale9 grid drawer
Usage 2 : ScaleBitmapSprite
ScaleBitmapSprite( bitmap : BitmapData, // the bitmap source inner : Rectangle, // inner rectangle for scale 9 outer : Rectangle=null) // outer rectangle : visual size reference var s:ScaleBitmapSprite=new ScaleBitmapSprite(mySkin, new Rectangle(20,20,80,20), new Rectangle(15,15,90,30)); addChild(s); s.width=80; s.height=40;</a>
ScaleBitmapSprite override public size setter & getter : you can move & resize a ScaleBitmapSprite object without taking care of bitmap outer drawing.
Simple MyButton class using ScaleBitmapSprite (click the button) :
Sources FCS4 [ require Eaze to compile]
Download ScaleBitmap & ScaleBitmapSprite :
Repository : http://gist.github.com/264250
Some of you prefer gist, so as possible, I will share my new projects via gist.
Hope this class help & merry Xmas to bytearray readers.
| 2009-12-18 |
If there is one thing that I love in AIR 2, it is the Native Processes. It allows you to interact with any native application on the client. The really cool thing is that such an app can be embedded within the AIR application which can be bundled as a .dmg file for MacOS and .exe for Windows. So many projects can benefit from that, WiiFlash would be one of those. I am working right now on a PDF Reader in AIR 2.0 cross-platform, around 5mb handling PDF's up to version 1.7, a C PDF rendering engine is bundled, does all the heavy work and output bitmaps to AIR. But one of the funny thing I wanted to achieve was MP3 compression.
So here is a demo using the new Microphone API, AS3 code saves the raw samples coming from the mic to a WAV buffer file, then, the command line MP3 Lame Encoder which is bundled into the AIR app does all the MP3 compression for you. Files are then saved on your desktop. It's an early demo version, do not pay attention to the crappy code, I will add more options to it and visually tune it.
It works very nicely and I was pretty impressed by how simple it was to communicate with the command line app, through the NativeProcessStartupInfo class. A complete AS3 wrapper could be built to use all the lame encoder features. Kudos to the AIR team for this crazy feature.

Download the AIR app here, and make sure you installed the AIR 2 beta runtime.
| 2009-12-15 |
Do you remember Mouse Gesture ?
I am currently working on its good friend : Voice Gesture.
Well, the name is not very explicit, but it's a voice recognition library based on the Flash Player 10.1 Microphone new feature.
I just want to show you a very early demonstration :
Voice Gesture from didier.brun on Vimeo.
As you can see, it works pretty fine ( > 95% accuracy ) but I have to admit that, for now, the algorithm require these 2 points :
- The user is the trainer (I have recorded my own voice models into the library)
- A silent place
I have some more work to optimize the algorithm and build an AIR application to record and organize the sound library.
So keep in touch, I will publish this library soon...
PS : Voice Gesture works in a simple web-based Flash Player 10.1 (I have recorded this demo using FireFox), it is not specific to AIR 2.0.
| 2009-12-07 |
Yeah yeah it`s been a while….
But here is something I just have to show. I guess you`ve all played with the awesome AIR 2.0 Beta so you know about the NativeProcess class and all the options we have now.
Basically the only thing you have to do is google for some cool cross platform command line apps and build a nice AIR user interface and you can build beautifull and powerfull desktop apps.
So one of the first things I tried was something that was on my wishlist for the flash platform for a long time – SCREENRECORDING!
This app records the users screen and encodes it to flash friendly mp4 files with h264 video.
Check out this screenrecording of my screenrecording app
I really plan to write an article about how to do this but i`ll never promise anything again


