Skip to Content »

FlashApe » archive for 'Flex'

 Mate Flex Framework

  • May 5th, 2008
  • 11:01 am

I just heard about the new Flex framework Mate (pronounced ma-tay) from asfusion. After spending some time going through their site I gotta say I am VERY impressed, both by the framework itself, and the documentation they have put together (considering how many times I’ve been let down by poor documentation in the past, Mate’s is great by comparison) .

The framework is tag-based, easy to follow, and looks like it should be pretty easy for people to pick up. It uses EventMap files which contain EventHandler child tags which describe what to do in response to a certain event….call service, set a property on an object, etc. Some cool things I noticed right off the bat:

  • the way their system works, you can use model objects in the Cairgorm style (one ModelLocator singleton) or in the PureMVC style (proxy/”manager” objects managing their data) and it works the same either way.
  • Objects can be created and cached for future reference in response to an event
  • The framework uses “injector” tags to set/bind properties of one an object to another.

There’s definitely a lot more cool stuff going on in Mate. Go check it out at http://mate.asfusion.com/

 Flex Builder vs. TextMate

  • April 16th, 2008
  • 3:19 pm

I was doing a bunch of Flex work for the past few months, and get really comfortable with Flex Builder. There are so many awesome features to aid development it simply kicks ass.

However, my current project is Flash CS3-based, so I went back to TextMate, which I also love. There are many great features in TextMate which eclipse does not do that really make me miss working in it.

My main points of comparison:
TextMate:

  • Perceptual Bulk - TextMate feels so lean, where FlexBuilder just feels so heavy. Probably due to eclipse not being a native mac app, but still, I just feel ‘cleaner’ working in TextMate.
  • Tab Triggers - I can’t count how much typing I’ve saved using tab triggers in TextMate. Type in a few key strokes and hit tab, and some templated code gets placed…with tabstops mixed in so you can simply tab to the next appropriate place to type. I only pray that someone tells me you can do that in eclipse.
  • Column Selection - Another tool of TextMate that i find incredibly timesaving. being able to select a rectangular area of text, and have whatever you type repeated on each of the selected lines, is a blessing. Another thing I wish eclipse would support.

Flex Builder (eclipse):

  • Integrated debugger - That pretty much puts the smack down right there.
  • Code Sense/Code Completion - Another swift backhand. For being such an awesome text editor, why can’t TextMate handle this better? (yes I know about using the escape key for auto-complete, but that’s pretty weak compared to what you get in eclipse).
  • Find in Language Reference - I use this constantly, and as far I know it doesn’t exist in TextMate (for actionscript anyway)

There’s probably a few more but those are what jump out at me. If anyone knows how to get some of the features listed above into the other app, please do tell :)

 Sending Negative Integers through AMFPHP

  • April 11th, 2008
  • 12:55 pm

There is a weird bug in AMFPHP regarding sending negative integers. If you try and send a number such as -87, it shows up as 4294967209 in php. I did some digging and found on the amfphp forums that it has to do with amfphp's readAmf3Int() method in AMFDeserialzer.php. Here is the updated function that was posted on the forum:

PHP:
  1. function readAmf3Int()
  2.     {
  3.         $res = 0;
  4.         $int = $this->readByte();
  5.        
  6.         if($int <128) {
  7.             return $int;
  8.         } else {
  9.             $int = ($int & 0x7f) <<7;
  10.            
  11.             $tmp = $this->readByte();
  12.            
  13.             if($tmp <128) {
  14.                 $int |= $tmp;
  15.             }else{
  16.                 $int = ($int | ($tmp & 0x7f)) <<7;
  17.                 $tmp = $this->readByte();
  18.                 if($tmp <128){
  19.                     $int |= $tmp;
  20.                 }else{
  21.                     $int = ($int | ($tmp & 0x7f)) <<8;
  22.                     $tmp = $this->readByte();
  23.                     $int |= $tmp;
  24.                 }
  25.             }
  26.         }
  27.  
  28.         $mask = 1<<28;
  29.         $res = -($int & $mask) | $int;
  30.  
  31.         return $res;
  32.     }

 For those unfamiliar: An overview of Flex, FlexBuilder, and the Flex SDK

  • April 4th, 2008
  • 4:05 pm

I wrote this up for a client, and realized I had given some version of this many times, so since I had it all written out I figured I'd post it here. I was trying to keep it somewhat high-level, as it's generally targeted towards the non-developers.

Originally there was Flash. Flash was built as an animation tool and followed a timeline-based approach. When i say timeline-based, think of a filmstrip, and how it is made of a strip of individual, consecutive frames....that was the concept behind Flash, to make editing those long sequences of animation easier. If you open up an .fla file, you can clearly see that each layer is made up of consecutive frames...those consecutive frames are collectively referred to as a ‘timeline’.
Eventually, people figured out that they could build really cool stuff in flash, even full-blown applications that didn’t really have too much to do with traditional animation. Eventually the timeline metaphor, more than just becoming irrelevant, started getting in the way. People were building apps based more an an individual screen-based metaphor, and creating each of those screens on individual frames of the timeline could often be a chore.

So, in order to accommodate Flash application developers, as well as developers coming from other languages into Flash development that were getting scared off by Flash’s awkward development environment, the Flex framework and FlexBuilder were created. In general, the Flex framework is a code library of components which help to facilitate building applications that run within Flash Player. FlexBuilder is the Flex IDE (integrated development environment...big term for a code editor with some other development-related features thrown in) offered by Adobe, which really just a specialized build of Eclipse, which is an industry-standard open source IDE.

In addition to (or instead of) using FlexBuilder, the Flex SDK (software development kit) is open source, and it contains the Flex source code library and compiler, so you can develop Flex apps in any IDE. Setting up and using the SDK will provide the same results as using FlexBuilder, but requires more time and effort to set up...so you get all the tools for free, but you have to set them up yourself. That’s the tradeoff to using FlexBuilder where everything is prepackaged and set up for you already.

Flex application are written using a tag-based approach, so Flex apps are generally made up of text files containing a mix of markup that looks like html (this is called mxml), and Actionscript 3 code. When the flex application source code is compiled, the compiler turns the mxml tags are into normal Actionscript 3 code, and a .swf file is produced. That .swf file runs in Flash Player, the same as a .swf file produced from Flash.

 AMFEXT doesn’t handle incoming arraycollections

  • March 30th, 2008
  • 12:15 pm

Ran into an issue today with AMFPHP trying to send an ArrayCollection...it kept choking when trying to decode the collection. I knew this was already possible, but forgot I had installed the php extension AMFEXT, which handles the encoding/decoding for amfphp when it is installed. Turns out that it doesn't like incoming arraycollections. Disabling the extension fixed my problem, but I would sure like find a way to get them working together.

 BorderSkin on top of children

  • March 27th, 2008
  • 1:39 pm

Sheesh...I just wasted half a day trying to figure out how to get a borderSkin to appear on top of all the children in a custom component I was building. It was a subclass of Canvas, so it was really easy...now that I know, it seems so obvious I want to kick myself. Anyway, you just need to do:

Actionscript:
  1. override protected function layoutChrome(unscaledWidth:Number,unscaledHeight:Number):void{
  2.     super.layoutChrome(unscaledWidth, unscaledHeight);
  3.    
  4.     //move the border in front of the children
  5.     rawChildren.setChildIndex(rawChildren.getChildByName('border'), rawChildren.numChildren - 1);         
  6.  
  7. }

 Notes on Control Bars in Flex

  • March 21st, 2008
  • 8:39 am

Two quick notes related to Control Bars in Flex. First, I was trying to get an ApplicationControlBar to dock to the bottom of the app, which I couldn't get to work. Maybe someone could point out a better solution, but I went with using a DockableToolbar from the awesome flexlib and setting draggable=false.

The other thing is if you want a ControlBar at the top of a panel, you can just actually just use an ApplicationControlBar wrapped in a VBox.

 Flex container rounded corners

  • March 19th, 2008
  • 5:32 pm

Just putting this up there in case anyone else needs it: if you are trying to get rounded corners on your container (like HBox) by setting the cornerRadius style, you need to make sure that you also set the borderStyle to 'solid' or the rounded corners won't render. You can set the borderThicknessProperty to "0" to hide the border.

 Detroit-Area AIR developer needed

  • March 19th, 2008
  • 4:04 pm

If you are in, or can get to, or would like to travel (travel expenses paid) to Detroit next week to work on a small AIR (Flex) project then please leave a comment or shoot me an email.

 Client.Error.DeliveryInDoubt

  • February 1st, 2008
  • 2:36 pm

Finally getting back into using Flex again, and was trying out the Remote Object tutorial here. Everything went fine for the Hello World tutorial, but I kept getting 'Client.Error.DeliveryInDoubt' messages from the PersonService. I read a couple of places that there had been issues with charset handling in amfphp, so spent a bunch of time with that, but still no luck. Then I remembered that I created the php file for HelloWorld in TextMate, and create the 2 php files for the PersonService in Flex Builder. Sure enough, after recreating the php files in TextMate everything worked. I'm not sure if it was an encoding issue, since it seems like both TextMate and FlexBuilder default to utf-8. I did notice that in FB, the preference for 'New Text File Line Delimiter' (under General/Workspace) was set to default, so I changed it to Unix to line up with TextMate.

Then I went out and installed PDT to set up a PHP perspective within FB.