-
Notifications
You must be signed in to change notification settings - Fork 1
Undocumented
Some part of ActionScript 3 are not documented or poorly documented or almost unknown.
TODO
TODO: connect with compiler option -frames.frame [label] [classname] […]
frames.frame=label,class_name[,...]
Specifies a SWF file frame label with a sequence of class names that are linked onto the frame; for example:
-frame=MyLabel,Class1,Class2
This option lets you add asset factories that stream in after the application that then publish their interfaces with the ModuleManager class. The advantage to doing this is that the application starts faster than it would have if the assets had been included in the code, but does not require moving the assets to an external SWF file.
This is an advanced option.
When publishing a SWF from Flash CS/CC trace(this)
gives [object MainTimeline]
in short
package filename_fla
{
import flash.display.MovieClip;
public dynamic class MainTimeline extends MovieClip
{
public function MainTimeline()
{
addFrameScript( 0, frame1,
1, frame2,
2, frame3 );
}
internal function frame1():void
{
// code
}
internal function frame2():void
{
// code
}
internal function frame3():void
{
// code
}
}
}
The equivalent could be done with the compiler options
$ mxmlc -frame=0,Frame1Class -frame=1,Frame2Class -frame=2,Frame3Class
It allows you to compile all your code over multiple frames instead of just one frame.
For example, you could have classes for audio assets, font assets, etc. spread over multiple frame (by their index, -frame=MyLabel
is misleading you can also do -frame=index
) and at the last frame use the Main
class that starts the application.
see
- Mommy, where do framescripts come from?
- AS3: MovieClip.addFrameScript
- Adobe Flex 4.6 - About the application compiler options
Found in another Jackson Dunstan blog post The Goto Keyword.
AS3 has a controversial new keyword: goto. It’s not documented,
but this article will tell you how it works. It’ll also talk about
why you might want to use it to improve performance or even make
your code more readable (gasp!).First, goto isn’t documented in Adobe’s documentation so what I’m
writing here I’ve learned only by experimentation with the AIR 13 SDK.
let's make a quick test with as3shebang
#!/usr/bin/as3shebang
trace( "hello world" );
var visited:Boolean = false;
someblock:
trace("someblock");
if (visited) goto after;
visited = true;
trace("now have visited");
goto someblock;
after:
trace("after");
output
hello world
someblock
now have visited
someblock
after
Not exactly not documented at all but not in the official Adobe documentation.
Remember the AS3Trace=1 option in mm.cfg
?
or the redshell
flag -Dastrace
?
Well, all these are accessible via the flash.trace
package.
Except if you go to the ActionScript® 3.0 Reference for the Adobe® Flash® Platform, you will not see this package listed.
If you look into the avmplus source code you can find it here
avmplus/extensions/Trace.as
and with Redtamarin I documented it a bit more ;)
redtamarin/src/extensions/Trace.as
And here the nice asdoc output from Redtamarin documentation.
Here how to use it
import flash.trace.Trace;
//custom trace function
function traceListener( file_name:String, linenum:int, method_name:String, method_args:String):void
{
trace( method_name + "( " + method_args.join( ", " ) + " )" );
}
//start the tracing
Trace.setListener( traceListener );
Trace.setLevel( Trace.METHODS_AND_LINES_WITH_ARGS, Trace.LISTENER );
//more code here
//stop the tracing
Trace.setLevel( Trace.OFF, Trace.LISTENER );
In redshell
you can see the command-line documentation
[-Dastrace N] display AS execution information, where N is [1..4]
but it does not really say what is the different from 1
to 4
Here a little helper
Index | Constant | Description |
---|---|---|
1 | Trace.METHODS |
Logs method entry only. |
2 | Trace.METHODS_WITH_ARGS |
Logs method entry and arguments. |
3 | Trace.METHODS_AND_LINES |
Logs method entry and line numbers. |
4 | Trace.METHODS_AND_LINES_WITH_ARGS |
Logs method entry, arguments and line numbers. |
You basically have 4 levels of trace, with the following format "AVMINF: LINE/MTHD".
If you want to define your own function listener use this function signature
function traceListener( file_name:String, linenum:int, method_name:String, method_args:String):void;
TODO
More related to the compilers and specifically Flex but can be useful to know for pure AS3 development.
Some metadata tags are documented (were undocumented before like [SWF]
) but not very well known or used (eg. [Deprecated]
, [Alternative]
, etc.).
Some others are undocumented or poorly documented.
ex: [Mixin]
, [Frame]
, [Inline]
Also a whole chapter can be written about using custom metadata and reuse them trough code reflection with describeType()
, see for ex BinaryData in Redtamarin.
etc.
see
- Adobe Flex 4.6 - Metadata tags
- Modular Applications (part 2)
- old maashaack wiki
- Introducing ASC 2.0
- Using the New Inline Metadata in ASC2
- ActionScript Compiler 2.0 Backward Compatibility
- Annotating ActionScript Classes with Custom Metadata
- FCNG - Flex et tous les metadata meme les undocumented (me posting in 2007 :p)
- Simple preloader for AS3 Flash Builder projects