Actionscript, Ninja style

Garbage Collector, weak references and all that jazz

header_post3

Last time i was working on a project, already almost done by another developer. When looking at the code, i was surprised to see all the call to the addEventListener function made like that:

_myObject.addEventListener(Event.AN_EVENT, myEventHandler, false, 0, true);

I knew that the addEventListener function has 3 optional parameters, but i had just never taken the time to look at them. After seing that i though that it would be a good idea to check what exactly were those parameters.

Here is the exact signature of the addEventListener function from the Adobe LiveDocs:

addEventListener(type:String, listener:Function, useCapture:Boolean  = false,
priority:int  = 0, useWeakReference:Boolean  = false):void

Ok so the three optional parameters are the useCapture flag, the priority and the useWeakReference… Read the rest of this entry »

Down with the .swc (ness)

header_downwiththeswcness

If you’ve read my previous article (Assets management, the .swc way) you know how i generally organize and manage assets in my Flex Project. In this article, i found that even if i found the .swc tec hnique to be the best way to deal with assets, it was giving less control over the preloading process.
After writing this, i though that as .swc files are just archives and contains the same exact .swf file with our assets, it should be possible to link .swc as external librairies, which would allow us to have all the benefits of the .swc format, ie auto-completion, and direct instanciation.

Read the rest of this entry »

Assets management, the .SWC way

header

As a Flash developer, for every project you work on, you have to manage assets. You know, all those graphical things that usually comes from very nice and organized .psds files given to us by our beloved designers :).

The “common” way

There is many ways to manage assets in a Flash poject. Usually you woul have a workflow similar to this:

1) Isolate and generate the elements you need from the .psds file
2) Create a .fla file and import those elements to your library
3) Create your symbols. For this step depending on the way you work you’re going to add some timeline code.
4) Set all the properties for your symbols (ie linking names)
5) Publish your .swf file
6) Once preloaded, you’d use your symbols using the getDefinitionByName technique, like that :

var mySymbolClass = getDefinitionByName("mySymbolLinkName") as Class;
var mySymbol:MovieClip = new mySymbolClass() as MovieClip;

Ok. This works fine, but this method is really painful (event you have make a nice function that does the getDefinitionByName call). So here is another way to manage and use your assets.

Read the rest of this entry »

SWFObject and centered Flash Content

Here is a little technique to make sure that your Flash object will be horizontaly and vertically aligned on your page. This technique is pure CSS and do not use a Table. Notice that this will only works for Flash objects that have a specific width and height (in pixels). If you have a 100% width or heght Flash, the standard css way to center a box (margin:auto) will do the job.

Here are the css styles needed:

html, body {
	background:#000000;
	margin:0;
	width:100%;
	height:100%;
	overflow:hidden;
}
#container {
	position:absolute;
	width:1000px;
	height:600px;
	left:50%;
	margin-left:-500px;
	top:50%;
	margin-top:-300px;
}

Note that the margin-left and margin-top must be equals to the half of the width and the half of the height of your Flash Object.

Now, just use SWFObject to embed your Flash object:


That’s it ! the Flash Object is vertically and horizontally aligned, no tables, and if you resize the window, everything stays in place :)

Wordpress Flash Integration #1

Here it is ! this is a demo of a Flash front end for a Wordpress blog. I'm using AmfPhp for the AMF implementation (if you haven't read the previous post about Flash and Wordpress Integration, it's here :)).

And i've used the NoPonies Flash Press service for the wordpress connection (i've just had to change it a little bit to make some SQL requests easier to use).

Just click on the pix to launch the demo (maximize your window :p)

FlashWordpress_exp1_preview_547x158

As for now it's still a demo, but i've got a wordpress proxy class that can get all the needed data from the blog, and as you can see i find that it works pretty well and respond really quickly, even considering the fact that i'm preloading most of the data at the beginning.

So here is the list of working features:

  • List recent posts, with their author and post date
  • List tags, clicking on a tag will display the posts matching the selected tag
  • Display a post

As the goal was to have a working demo fast, i haven't put too much effort on the look 'n feel, everything is just skined using a CSS file.

Wordpress + Flash + Integration = ???

After playing for now 5 months with Wordpress, i must say that i really like it. Easy to install, very easy to skin, to customize, using Template Tags or directly Wordpress functions.

So last time i was thinking that it would be very nice to have a Flash Blog, having a big fullscreen .swf connecting to my wordpress database and doing all the job…   As a good developer is always lazy, i've started to look for that on the web, netherless to say i've found a lot of stuff about Flash and Wordpress integration. After reading a lot of posts i decided that i would write one myself to sum-up the current state of it so, here we go ! Read the rest of this entry »

Gimme FIVe! (3D)

Just a quick demo of the FIVe3D Lib and the KulerProxy, i'll write a complete post about it when i'll have the time :).

For now just click on the pix to launch the demo (opens another window). Enjoy !

  FIVe3D_KulerDemo_preview_547x175

No more crappy colors (or Playing with the Kuler API)

I've always loved Kuler, i don't know maybe it's just the site itself, its slick design. Even if to be honest i've never taken the time to build themes myself (yeah i still found the theme creation process a little bit complicated… i probably miss some color theory lessons…) i really found it usefull.  
Everytime i'm asked to design something, an app, a website, a logo, i always start by thinking about typography and colors and that's when Kuler comes in a handy, in a few seconds i can browse thousands of nice color themes.

Ok but nothing really knew here, websites with colors stuff have been around for a while i know, but what's interresting with Kuler is that you also get a Web service and an funny to use API.   So here is a little application i've made to demonstrate the use of the Kuler service.

All the Kuler calls are made through a simple class called the KulerProxy which is responsible for downloading and parsing the request XML responses. Then a list of KulerTheme objects is created and can be browsed. 

  

Here you can choose between 4 "channels", the popular Themes, the most recent ones, the highest rated or just get some random themes. To begin just on the desired channel button, then you can browse the results using the top corners previous and next buttons.  

Full AS3 Menu demo

Ok, here is a little menu i've been working on lately. It's pure AS3 (using Flex Builder), the only asset being the .png file for the BackGround fill (Embedded) and of course the font Moo! : http://www.dafont.com/moo.font .

  Read the rest of this entry »

The Fonts Nightmare (part 1)

Okay, playing with fonts in Flex Builder can sometimes be very tricky. So after spending some time (yeah a lot, ok) trying to find out the best way to embed font in Flex Builder, i tought i'll write a post about it. Actually it's more gonna be a post trilogy (yeah like the Lord of the rings). So let's start with the first part… Embedding a font directly in the actionscript code. Read the rest of this entry »