I. Introduction:
Feathers is a lightweight, easy-to-Customize skin and extended UI component (applicable to mobile devices and desktops ). Feathers uses the Starling framework and powerful GPU rendering components to achieve a smoother and more friendly experience. It is now a Class Library Supported by Adobe!
Purpose: Use GPU graphics to accelerate rendering for a better user experience. It is suitable for transferring the value of a pc flash game platform game to a mobile game.
Ii. Main Structure
Feathers provides the main class libraries and main methods
Iii. describes in detail the main implementation mechanisms and classes:
1. DisplayListWatcher-core class
Important methods:
Public function setInitializerForClass (type: Class, initializer: Function, withName: String = null): void
This method uses the class name as the KEY, the method function as the value, and stores the _ initializerNoNameTypeMap: Dictionary = new Dictionary (true); (here there are two dictionaries, one with the name parameter, with or without name parameters)
Rendering implementation process:
Listeners
This. root. addEventListener (Event. ADDED, addedHandler );
Then, by judging that the type (Class) of the event target object is KEY, find the pre-stored function from the Dictionary and call it. (Function is usually bound to texture)
2. Custom theme skin: override protected function initialize (): void
The main implementation process is as follows:
// Parse the image textrue
Const atlasBitmapData: BitmapData = (new ATLAS_IMAGE (). bitmapData;
This. atlas = new TextureAtlas (Texture. fromBitmapData (atlasBitmapData, false), XML (new ATLAS_XML ()));
This. defaultTexture = this. atlas. getTexture ("hslider-thumb-up-skin ");
Call the method of the parent class for binding
This. setInitializerForClass (Button, buttonInitializer );
// Set topic attributes for the corresponding component class in buttonInitializer
Button. defaultSkin = defaultTexture;
3. UIcomponent custom component implementation class
3.1 declare the attribute, and set the defamthskin: Texture value for customeme.
3.2 override protected function initialize (): void-initialize the corresponding operation data
3.3 redraw method override protected function draw (): void
1. Obtain the Invalidation flag (which is used to notify the component of any changes, and some definitions are provided in FeathersControl). When changing the component attributes, you need to call this of the parent class. invalidate (INVALIDATION_FLAG_SIZE); for notification.
FeathersControl listens to the invalidate method and has verified whether to re-call the draw () method for re-painting.
2. Based on the flag, determine which parts need to be re-painted
3. Layout
You can also refer to another article I wrote with detailed code:
Feathers ui skin replacement
Http://www.cnblogs.com/tankaixiong/archive/2013/01/05/2845165.html