Hidden features/tricks of Flash development, Flash

2019-01-21 02:42发布

Guys, I am thoroughly surprised that there is no Flash Hidden Features post yet in the Hidden Features series that I've been tracking for a while now.

There is a recent AS3/Flex one but it's not very active and I don't exactly mean just AS3 when I say Flash here.

The Hidden Features series is great for people who are new to a certain language. It shows the ropes and certain valuable tricks, all in one place. I think it's a brilliant idea. Even experts sometimes find tricks they'd never heard about.

When I started with Flash, I was taken aback by the Flash IDE and odd concepts of Flash, compared to other programming languages.

So, here goes: what are some hidden features of Flash as a language (AS2/3) and the Flash IDE?

Let the fun begin.

24条回答
\"骚年 ilove
2楼-- · 2019-01-21 03:26

Not exactly hidden, but what about the often overlooked "include" macro (yes, it still exists in as3)? - very useful for faking multiple inheritance (when used side by side with an interface), even if it usually is a bad practice.

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-21 03:27

You can create weak references in ActionScript3 by using the Dictionary object.

查看更多
【Aperson】
4楼-- · 2019-01-21 03:28

[AS3]

When you use the trace statement in AS3 you can pass in multiple parameters and AS3 will format the output so that there is a space between each.

trace("Hello","World");

would output "Hello World".

AS2 does not support multiple parameters for trace so you are forced to do something like

trace("Hello "+"World");
查看更多
地球回转人心会变
5楼-- · 2019-01-21 03:29

[Flash IDE]

When you export a MovieClip as a swc you can add it to the components panel of by dropping it into the folder

C:\Documents and Settings\USER_NAME\Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\Components\SOME_COMPONENT_FOLDER

Restart flash and it'll be in the components panel for you to use.

查看更多
Animai°情兽
6楼-- · 2019-01-21 03:29

Custom metadata isn't something that's well documented or promoted, but it's very helpful - without modifying a variable or changing its namespace, you can give it custom annotations similar to the way that you can in Java.

It is gone over in depth by Christophe Conraets on his blog.

The simplicity of it is that you can put all of your own metadata, and then you just use describeType() and you will see all of your custom metadata at run time :)

查看更多
唯我独甜
7楼-- · 2019-01-21 03:32

For those of you using FlashDevelop, there is some nifty conditional compilation functionality:

// Use it to generate different code paths
CONFIG::debug {
   txt.text = "Debug Version running...";
}
CONFIG::release {
    txt.text = "Welcome to Stark Industries";
}

// Or use it as a const in code
if ( CONFIG::debug && yourCondition ) {
    // Do stuff
}

read more about it here

查看更多
登录 后发表回答