In-depth analysis of feathers ui Implementation Mechanism (feathers ui source code analysis-original) feathers ui skin replacement

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.