ActionScript (library)
Overview
Summary
Provides ActionScript 3 related functionality
Contents
API
getClass(element, nameOnly)
Gets the AS3 class of an element or item
Getting the ActionScript 3 class of an element can be a bit of an involved process, depending on a variety of factors such as the original element type, IDE-set object type, and whether the element's library item is itself an exported class, or not.
The following example lists the actual AS3 class for a variety of elements on the stage:
function processElement(element) { var elementType = element.elementType; var symbolType = element.symbolType; var itemType = element.libraryItem ? element.libraryItem.itemType : ''; var class = ActionScript.getClass(element); data.push({name:element.name, elementType:elementType, symbolType:symbolType, itemType:itemType, class:class}); } var data = []; $(':scriptable').each(processElement); Table.print(data);
+---------------+-------------+------------+------------+----------------------------+ | name | elementType | symbolType | itemType | class | +---------------+-------------+------------+------------+----------------------------+ | dynamicText | text | | | flash.text.TextField | | inputText | text | | | flash.text.TextField | | button | instance | movie clip | component | fl.controls.Button | | checkbox | instance | movie clip | component | fl.controls.CheckBox | | embeddedVideo | instance | | video | flash.media.Video | | linkedVideo | instance | | video | flash.media.Video | | simpleButton | instance | button | button | flash.display.SimpleButton | | movieclip | instance | movie clip | movie clip | flash.display.MovieClip | | filtered | instance | movie clip | graphic | flash.display.Sprite | | threeDee | instance | movie clip | graphic | flash.display.Sprite | | scripted | instance | movie clip | movie clip | display.elements.Scripted | | audible | instance | movie clip | movie clip | display.elements.Audible | | empty | instance | movie clip | movie clip | flash.display.Sprite | +---------------+-------------+------------+------------+----------------------------+
getBaseClass(item)
Gets the AS3 base class of an item or element
If the base class of an item in the library is the default one, the linkageBaseClass property is an empy string. This method determines the actual class from the element or item and its properties.
The following example gets the AS3 base class of the selected, exported, items in the library:
/** * Grabs some data from the item * @param {SymbolItem} item The Symbol Item */ function getData(item) { var properties = { name:item.name, linkageClassName:item.linkageClassName, // flash linkageBaseClass:item.linkageBaseClass, // flash baseClass:ActionScript.getBaseClass(item) // xJSFL }; data.push(properties); } var data = []; $$(':exported:not(/*Component*)').sort().each(getData); Table.print(data);
+-------------------------------------+---------------------------+------------------+-------------------------+ | name | linkageClassName | linkageBaseClass | baseClass | +-------------------------------------+---------------------------+------------------+-------------------------+ | 1 - assets/audio/damage.wav | sounds.Damage | | flash.media.Sound | | 1 - assets/audio/explosion.wav | sounds.Explosion | | flash.media.Sound | | 1 - assets/audio/laser shoot.wav | sounds.Laser | | flash.media.Sound | | 1 - assets/audio/notify.wav | sounds.Notify | | flash.media.Sound | | 1 - assets/audio/power-up.wav | sounds.PowerUp | | flash.media.Sound | | 1 - assets/bitmaps/icon_attach.png | display.icons.AttachIcon | | flash.display.Bitmap | | 1 - assets/bitmaps/icon_music.png | display.icons.MusicIcon | | flash.display.Bitmap | | 1 - assets/bitmaps/icon_new.png | display.icons.New | | flash.display.Bitmap | | 1 - assets/bitmaps/icon_recycle.png | display.icons.RecycleIcon | | flash.display.Bitmap | | 1 - assets/bitmaps/icon_update.png | display.icons.UpdateIcon | | flash.display.Bitmap | | 1 - assets/bitmaps/icon_widgets.png | display.icons.WidgetsIcon | | flash.display.Bitmap | | 1 - assets/fonts/Droid Sans | text.fonts.DroidSans | | flash.text.Font | | 1 - assets/fonts/Fresh | text.fonts.Fresh | | flash.text.Font | | 2 - elements/interactive/Button | fl.controls.Button | | | | 2 - elements/interactive/CheckBox | fl.controls.CheckBox | | | | 2 - elements/movieclips/animated | display.elements.Animated | | flash.display.MovieClip | | 2 - elements/movieclips/audible | display.elements.Audible | | flash.display.MovieClip | | 2 - elements/movieclips/scripted | display.elements.Scripted | | flash.display.Sprite | +-------------------------------------+---------------------------+------------------+-------------------------+
Comments are closed.