Flash Creations – a quick catalog

April 19, 2008

With no clear category to post these in, but wanting to share with those who may visit, and bookmark for a reminder to myself, here are “galleries” of beautiful, and instructive, actionscript creations.  Most of these are provided along with source code.  A bestiary, gallery, or compendium, call it what you will.  (And some of these talk back, if your sound is turned on):









For Historical Reasons, Opcode Value 186 is not Used.

July 20, 2007

I run across obscure references from time to time, and they have a tendency to stick in my mind, like part of a pattern that needs to be matched.  As perfect as an abstraction as mathematics may appear to some, it carries its own set of special cases and exceptions.  We assume that these are naturally occurring and just accept them at face value.  It is not very useful to try to figure out why Pi is not a round number.  It is what it is.

  The domain of computer languages and software carries its own set of special cases and exceptions, but often these are the result of human conditions.  And in carrying out whatever pursuits we are engaged in, they are accepted and we say “it is what it is.”  Following is a brief catalog of numbers, mostly with a computer related historical description, but some with related cultural references:

186  (oxBA)-Java opcode which was not used in the first Java virtual machine, for historical reasons.

3:16 – Lecture and Book by Don Knuth, author of the Art of Computer Programming.

0xCAFEBABE – Magic number which appears at the start of every Java class file (bytecode).  Note the presence of 0xBA in 0xCAFEBABE, in the third byte position.

0xCAFEDEAD – Rumored to be the originally desired magic number for Java class files, as the developers were fans of the Grateful Dead. It had already been used for other things, so CafeBabe was used instead.  Note that Java 1.0 was released January 23, 1996, 167 days after the death of Grateful Dead guitarist Jerry Garcia.

0x504B – Magic number at the begining of every ZIP format file.  These are the hex codes for ASCII characters ‘PK’ initials of  Phil Katz, the author of the original zip compression program.

0x4D5A – Magic number at the beginnng of every DOS executable program.  These are the hex codes for ASCII characters ‘MZ’, initials of the developer of the file format, Mark Zbikowski.

8675309 – Seen in many, many more oscure contexts for computing.  From unlock codes for games, to causing a mode change for Microsoft’s WebTV, and various others.  This was Jenny’s Phone Number, in the hit song by Tommy Tutone.

420 – A cultural reference to cannibas. 

404 – Page Not Found Error Code in HTML

2600 – The frequency originally used by AT&T to signal a ready state for a long distance phone line.  Also the same frequency which was produced by a toy whistle which was given as a toy surprise in Captain Crunch Cereal in the mid 1960’s.  As an added curiosity, to no one except for myself, I happen to have the home printer, HP Photosmart 2600.

90125 – The original catalog number of the Yes album, by the same name.

9:15 – Time of the train referenced in The Who’s Quadraphenia in the song by the same name.

90210 – The zip code for a Bevery Hills neighborhood in which a popular 1990’s tv series was based.

The appearance of numbers and codes like those listed is frequent.  The presence of codes and oddities in the digital domain offer an endless supply of curiosities.  The crossing of domains has become more and more commonplace as computers and digital electronics settle into their place in our culture.  Phone numbers become song titles, and song titles become codes in computer file formats, and will continue to do so.  And most of the time, “they are what they are.”

Handling Results in Flex from RemoteObject calls in ColdFusion

July 2, 2007

I’m putting together a music library for a client, and I thought I’d take the opportunity to measure the return results from ColdFusion in various forms, and see how they appear in Flex:

1) Calling the songService.cfc to get a list of songs as and ArrayCollection of SongVO So, in the ModelLocator.as, the songList is declared as:

[ArrayElementType("SongVO")]public var songList:ArrayCollection = new ArrayCollection();

The SongVO is tied to the cfc with a meta tag like this:

package com.musiclib.fx.vo
      import flash.events.EventDispatcher;
         public class SongVO extends EventDispatcher         
         public var song_id:Number = 0;         
         public var owner_id:Number = 0;         
         public var category_id:Number = 0;         

Finally, the value is returned from the cfc as the ColdFusion equivalent of the AS class. In this case, I am calling getSongList(). In order to type all of the rows, each query result row must be cast into the coldfusion component type. So, when we receive the result, we get:

Charles network capture of result In the debugger, we see the modelLocator songList as null or Empty. Time to reach into the bag of tricks

debugger view of cfc call result

A quick look in the Flex manual tells me:

“Handling service resultsAfter an RPC component calls a service, the data that the service returns is placed in a lastResult object. By default, the resultFormat property value of HTTPService components and WebService component operations is object, and the data that is returned is represented as a simple tree of ActionScript objects. Flex interprets the XML data that a web service or HTTP service returns to appropriately represent base types, such as String, Number, Boolean, and Date. To work with strongly typed objects, you must populate those objects using the object tree that Flex creates.WebService and HTTPService components both return anonymous Objects and Arrays that are complex types. If makeObjectsBindable is true, which it is by default, Objects are wrapped in mx.utils.ObjectProxy instances and Arrays are wrapped in mx.collections.ArrayCollection instances.

NOTE Macromedia ColdFusion is case insensitive, so it internally uppercases all of its data. Keep this in mind when consuming a ColdFusion web service.

But, returning to a previous post, I pull this code, and plop it in:

 var result:Array = resultEvent.result as Array; 

    for (var i:String in result) 


result[i] = new ObjectProxy(result[i]); 


    ModelLocator.getInstance().myArray = result as ArrayCollection; 

Well, that didn’t help one bit. I have the same results.

Now, if I return a query, directly from the cfc, and assign what comes back directly to the target arrayCollection songList, then everything works just fine.

MVC Framework for AS3

June 27, 2007

The Cairngorm framework has proven exception in providing a simple, lightweight methodology for Flex development, but its strength rested on application to database communications. Intense visual development was left without much support, or overuse of the Singleton ModelLocator, creation of ViewManagers and other constucts. PureMVC Diagram

I have been reading up on this framework, Pure MVC, which looks like it offers a complementary approach to Cairngorm for Flex/AS3 development. It’s possible elements of this could be adapted for use in Cairngorm framework implementations, and vice versa, but I’ll need to try it on its own first, and see. It’s definitely worth a look: http://www.puremvc.org

Matrices in Java and Flash (Flex)

June 20, 2007

Ran into an interesting detail concerning differences between Flex and Java, having to do with their matrix representations.  If you are unfamiliar with Matrices, as I am, you can review Matrices and Transformations in Flash at http://www.senocular.com/flash/tutorials/transformmatrix/.  The detail is this:  Java and Flash have their second and third at the opposite to each other.  So, for example, in this matrix:

Matrix Picture

In Flash, you would say:

matrix = new Matrix(a, b, c, d, tx, ty);

and in Java, it look like:

matrix = new Matrix(a, c, b, d, tx, ty);

(Well, their matrix is spelled a little differently.  See the javadoc page at : http://java.sun.com/j2se/1.4.2/docs/api/java/awt/geom/AffineTransform.html

[  m00  m01  m02  ] 

[  m10  m11  m12  ]

 This was one thorny detail on top of the rest of the great fun of the iText library.  The other interesting piece is that the y coordinates are reversed.  The PDF was designed for print media, so the y starts at the bottom of the page, with increasing values as it goes up.  In Flash, it is the opposite.  The y origin is at the top of the screen, increasing in value as you go downward.  This is all in general, and default.  It is possible to apply a transformation to the PDF to reverse the Y values, and likewise with the Flash.

With the PDF, you can apply the following transofmation:

matrix(1.o, 0.0, 0.0, -1.0, 0.0,  h*)

using concatCTM most likely.  The d value reverses the direction of the y axis, and the h* is a special value which is on the overall height of the page.   Because once you reverse the y value, it is still originated at the bottom left.  But when it increases it goes off the page into oblivion.  The h* value moves the origin to the upper left hand corner of the page.

Object Proxy (cont)

June 8, 2007

I ran across the topic again, and again this week, and I haven’t even been working in Flex.  It’s been all Java this week.  I was cruising through the blogs of the European Union, and found this comment:

“Yep already… I fixed the annoying “Lazy Loading”-issue. I found a little hack and it goes something this:

  1. Store openDuration and closeDuration;
  2. Set openDuration and closeDuration to 0;
  3. Call open and close methods;
  4. Restore openDuration and closeDuration;
  5. TADA… lazy loading be gone….. “


Is it possible that the standard use of Delayed Instantiation of Objects, is emerging as an Anti-Pattern, as programmers worldwide come up with various solutions and workarounds to make the objects behave as procedural Objects would?

And at the same time, other programmers are adding additional Proxy wrappers, to achieve the effect they need.  Utilizing the Double Proxy Pattern, the first access to the object would release the inner proxy, and fire off a request to fill in the proxy with “real” data.  Hopefully, by the next time the object is accessed, it will be populated.  This is related to the re-wrapping with ObjectProxy which I have seen.


  Earler this week, a colleague was putting together a dashboard application view, and had a coldfusion remote service all wired up in ColdSpring, and was at the point of getting the data back in the ResultEvent of the Service Delegate, and was getting strange results.  The ResultEvent.result was an ObjectProxy, or nothing.  He was not getting a list of data for his view to bind to.  He was returning an array of some type, but the remote object declared it was returning type “any”.  Well, when we fired up Charles, and looked at the AMF result coming from the Coldfusion server, the type was a custom coldfusion recordset.  So, he changed the declaration of the return type to “Array”, and lo and behold, while observing in Charles, we saw that the  AMF return type was ArrayCollection.  And the rest of his code worked, and the dashboard element filled up, because the data was in a format that Flex recognized.  I don’t know exactly what this tells me, except that the return type declaration in Coldfusion is important.  As is the RemoteObject type meta tag in the Flex Value Object declaration.

  He did not try another test, wrapping the result in ObjectProxy to see if that would have taken care of the problem.  I don’t know that it would *solve* it, but it would probably yield different results.

  And then I am reminded of this post:

“Accessing proxied object

Under some circumstances Flex wraps object with special mx.utils.ObjectProxy wrapper class. Documentation describes special object_proxy “object” property containing reference to real object. But accessing this property at runtime always returns “null”, althought this property is visible in debuger watch window with “package” icon. Code below demonstrates the problem, and shows “Real object: null” message:

 import mx.utils.ObjectProxy;
 import mx.controls.Alert;
 var o1:Object = { f1:”aaa”, f2:123 };
 var o2:Object = new ObjectProxy(o1);
 var o3:Object = ObjectProxy(o2).object;
 Alert.show(“Real object: “+o3);
Matt Chotin pointed me to the solution. It’s special namespaced property and need in special code handling. So updated example listed below:

 import mx.utils.ObjectProxy;
 import mx.utils.object_proxy;
 import mx.controls.Alert;
 var o1:Object = { f1:”aaa”, f2:123 };
 var o2:Object = new ObjectProxy(o1);
 var o3:Object = ObjectProxy(o2).object_proxy::object;
 Alert.show(“Real object: “+o3);”

from http://www.docsultant.com/site2/articles/flex_internals.html

(to be continued)

Flex 3 is coming soon

June 5, 2007

Ted Patrick has been hinting that Flex 3 will be released soon.  He’s generating some buzz anyway.

Last week : Ted announced that this week he will be giving out details on Flex 3