<fx:Library> tag implemented by the compiler


You use the <fx:Library> tag to define zero or more named graphic <fx:Definition> children. The definition itself in a library is not an instance of that graphic, but it lets you reference that definition any number of times in the document as an instance.

MXML Syntax

The <fx:Library> tag has the following syntax:

    <fx:Library>
        <fx:Definition name=defName> 
            <!-- Non-visual declarations. -->
        </fx:Definition>
        ...
        <fx:Definition name=defName> 
            <!-- Non-visual declarations. -->
        </fx:Definition>
    </fx:Library>

The <fx:Library> tag must be the first child of the document's root tag. You can only have one <fx:Library> tag per document.

The following example defines a single graphic in the <fx:Library> tag, and then uses it three times in the application:

    <?xml version="1.0" encoding="utf-8"?> 
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:mx="library://ns.adobe.com/flex/halo" 
        xmlns:s="library://ns.adobe.com/flex/spark""> 
         <fx:Library> 
              <fx:Definition name="MyTextGraphic"> 
                   <s:Group> 
                        <s:TextGraphic width="75"> 
                             <content>Hello World!</content> 
                        </s:TextGraphic> 
                        <s:Rect width="100%" height="100%"> 
                             <stroke> 
                                  <s:SolidColorStroke color="red"/> 
                             </stroke> 
                        </s:Rect> 
                   </s:Group> 
             </fx:Definition> 
         </fx:Library> 
         <MyTextGraphic/> 
         <MyTextGraphic/> 
         <MyTextGraphic/> 
    </s:Application>