views:

957

answers:

3

I found a lot of interesting info in the 'hidden features of...' series. I'm a AS3 developer so I want to add this question about AS3 as well for all the flash/flex developers out there. So, what are the lesser-known but useful features of AS3 and Flex framework that you know ?

+5  A: 

about AS3

well the coolest hidden feature with flash player 10 was the hidden alchemy opcodes ... but that has nothing to do with AS3 in fact ... well there is some option for inline assembly for that matter ...

i don't know ... AS3 actually is pretty boring compared to AS2, which was fully packed of really great hidden features, that allowed you to change the whole API at runtime ... :D

apart from some hidden or sparsely documented metatags, there is not too much ... with an older version of the flex SDK, there was a funny feature, that if you embedded fonts, the first font was also available under the ID of foobar ... but yeah ... that's not to cool either ...

uhm, then there's a few hidden classes and interfaces ... you can get most things with an SWC-reader ... (for example, there were some undocumented classes in the flash.html package) ...

maybe there is some stuff CS3/CS4 uses, but when it comes to pure AS3 compiled with the flex SDK, that's really all ...

and then there is this very funky global object ... everyon claims it was lost in AS3 ... well it was not ... you can get it easily ...

var global:Object;
var f:Function = function ():void {
    global = this;
}
f();

but it is nothing like _global in AS2 ... it seems to be completely empty ... this is funny though ... but it is quite funky ... consider this code:

var object:Object = new Object();
trace(getQualifiedClassName(object));//Object
trace(getQualifiedClassName(global));//global ... huh?
trace(global.constructor == object.constructor);//true ... this seems a little strange considering the fact, that they come from different classes

trace(describeType(global));
trace(describeType(object));

last 2 statements generate following two XMLs ...

<type name="global" base="Object" isDynamic="true" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constant name="Main" type="Main"/>
</type>

<type name="Object" isDynamic="true" isFinal="false" isStatic="false">
  <method name="hasOwnProperty" declaredBy="Object" returnType="Boolean" uri="http://adobe.com/AS3/2006/builtin"&gt;
    <parameter index="1" type="*" optional="true"/>
  </method>
  <method name="isPrototypeOf" declaredBy="Object" returnType="Boolean" uri="http://adobe.com/AS3/2006/builtin"&gt;
    <parameter index="1" type="*" optional="true"/>
  </method>
  <method name="propertyIsEnumerable" declaredBy="Object" returnType="Boolean" uri="http://adobe.com/AS3/2006/builtin"&gt;
    <parameter index="1" type="*" optional="true"/>
  </method>
</type>

you cannot resolve that global class either ... you can also generate a very confusing output with global = 5 and object = 4.5 ... will give you int, Number and true, for the first three statements ... but its the only other two "types" i know where that works ... although i really don't know what that "global" type is ...

[edit] just checked: the global object is 4 bytes bigger in memory, then an empty object, which is 24 bytes big ... now 4 bytes seems like a 32 bit address, but who nows, where that points to ... :D [/edit]

but i guess, i you are waiting for a "wow, how cool, why didn't they document that" feature, i'm rather pessimistic ...

adobe tries to really sell all features of the flash player ... at the same time, they want it to stay safe ... so they cannot really have tons of hidden APIs built in to the flash player ... also, the VM is open source and the compiler is ... and the open source community has been very successfull in finding any possibilities the flash player offered, be it inclusion of malicious code to use it as a security loop hole, or simply discovering features, that did not seem to be scriptable with AS ... the only bigger hidden thing there was recently, were the alchemy opcodes ... but noone used them ... they decided to include them, before alchemy was ready for first public releases ...

one cool thing, that was never really talked about a lot, since flash player was announced, is flash player's UDP p2p-ability with NAT-punchthrough, enabled through an update in the player core, when going to version 10 ... this is also probably due to the fact, there has not yet been an official release of stratus, which is still beta ... however, this in not a real language or API feature ... it is some magic happening behind the scenes ... the API stays the same (well except that you cannot use Remote Shared Objects) ...

about Flex

honestly, i don't know ... i am not that much of a Flex crack ... Flex is written in AS3 and open source ... so it's difficult to hide too many things ... some classes are excluded from documentation using [ExludeClass] (i did some debugging on the remoting package because it did not interface to well with some home made PHP)... but most of them are not of particular interest ... simply some internals that are hidden, so your mind does not get blown even more by this quite bloated framework ...

back2dos
A: 

Custom metaData tags are really cool, we use them for all sorts, making inputs readOnly, defining validation rules, calculation rules etc.

What this means is that the code stays generic, for the validation example for instance the actual property defines validation rules it is subject to so we never have to set any rules concretely i.e. in code or mxml. Really good feature well worth investigating.

Jon