Action Script 'include' statement example
Example below shows two consequent action script files: GeometricalFigures.as and Sqrt.as, and the third example, i.e. Figure.mxml is our main flex file inside which the working of include statement has been demonstrated. Above mentioned action script files are in the includes folder that has been called by include statement in the main mxml file. The root directory of includes folder should match with the root directory and folders of your main mxml file and ant build file, here it is obvious that your build file and mxml file have same root directory. Now in the main mxml file, <mx:Script> tags are made in which two include statements are used to call two action script files. Action script files posssess .as extension. For calling the files their relative paths are used.
Syntax for using include statement:-
include ' ';
Action script files can also be called through the source attribute property in
<mx:Script> tag, but in that case only a single action script file will be called.
Syntax for using 'source' attribute:-
<mx:Script source = ' '> ...... </mx:Script>
In Our first action script file, GeometricalFigures.as two packages flash.dispaly and mx.core has been imported for getting the instances of Sprite and UIComponent classes. Further in the code, two geometrical figures have been created and for creating these figures two Sprite type variables have been created. Now graphics feature of Sprite class provides two static methods: .beginFill() and .drawCircle/Rect(), and among these methods the first one fills color in the figure and the second one creates the figure. Now our Sprite variables that we have created are called inside the UIComponent variable through .addChild function, now the UIComponent variable is called inside the flex Canvas container through the container's id property, which means figures will form inside the Canvas.
Download the code
[an error occurred while processing this directive]