Reputation: 449
I just started programming flash/actionscript and I am confused as to what the meaning of the square brackets inside classes mean. I appreciate this might answered before but searching for square brackets actionscript yields 0 useful results.
Here are some examples
public class FlxGame extends Sprite
{
//Flex v3.x SDK only (see note above):
[Embed(source="data/nokiafc22.ttf",fontFamily="system")] protected var junk:String;
or inside a package:
package
{
import org.flixel.*;
[SWF(width = "640", height = "480", backgroundColor = "#000000")]
public class PepperEngine extends FlxGame
What is this doing? Any help would be appreciated.
Upvotes: 2
Views: 732
Reputation: 61
Here's the list of the complete metadata tags That you can use with the Mxmlc flex compiler. I'm not sure if you can use this tags with the regular Flash compiler though.
Upvotes: 2
Reputation: 202
It's giving the compiler some info on what it's supposed to do. In the [Embed] bracket it's saying that that .ttf file will be loaded and that it's gonna be used as a protected var called junk of type string. It's like when in the Flash IDE you declare something in the library and then you put a linkage class to it so that it can be referenced in an .as file. The package one is saying that the file is gonna be of a certain width, height and backgroundColor. In overall, it's just giving info to the compiler so that it can interpret certain things in a certain way.
Upvotes: 3