【ASQuery 1.0.2】
---------------- Table of contents------------------
This project is a FlashBuilder library project.
src: Source file directory
bin: Generate the ASQuery.swc directory
doc: API Document Directory
demo: Test example directory
---------------- illustrate------------------
Basic design ideas refer to the open source framework JQuery.
Design and build based on the characteristics of flash. Used to simplify display programming.
--------------------------------------------------------------------------------------------------------------------------------
1. Good compatibility: You can embed the project at any time without modifying the original code structure.
2. Powerful selectivity: Use the selector to easily select display objects, and support the selection of objects in name, class, and instance.
3. Support chain programming: Through chain programming, the amount of code can be greatly reduced. For example, set coordinates and click events for a component named ball:
$("ball").attr({"x":100,"y":100}).click(ballClickHandler);
4. Optimized event binding and unbinding mechanisms to get rid of the release method of the native event mechanism without modifying the inheritance system.
监听释放方式如下:
//释放ball的所有监听
$("ball").unbind();
//释放ball的所有CLICK事件监听
$("ball").unbind(MouseEvent.CLICK);
//释放ball的用ballClickHandler绑定的点击事件监听
$("ball").unbind(MouseEvent.CLICK,ballClickHandler);
5. Release the display object resource occupancy with one click: $("ball").dispose().
6. Extensible helper functions, which can add more convenient functions for your development.
7. Have good code prompts.
---------------- API ------------------
The API generated document is in the doc directory. The text API description I have compiled: [Selector]
Name selector: $("ball") => Get all instances with the name ball, there are multiple instances that can be separated by spaces, such as $("ball1 ball2 ball3") Class selector: $(Sprite) => Get all instances with the class or base class Sprite: $(myBall) => Get the instance array selector with the instance myBall: $(ballArr) => Get all instances in the ballArr array
【General Functions】
Initialization: ready(fun:Function) Set the internal attribute of the element: attr(name: ,value: =null) Get the internal attribute of the element: getAttr(param:String) Run the internal method of the element: fun(name:String,params:Array=null) Execute method on all elements: all(fun:Function) Find the internal element through the new selector: find(selector:*,onlyChild:Boolean = false) Bind event listening: bind(type:String,handler:Function) Unbind(type:String,handler:Function) Manually trigger the event: trigger(event:Event) Get the internal actual element: get(index:int):DisplayObject Get the number of internal actual elements (if it is 0, it means that no element was obtained): length() Get the internal container: getContainer(index:int = 0):DisplayObjectContainer
【Helpful Function】
Binding click event: click(handler:Function) Toggle the attribute state of Boolean type: toggle(name:String = null) Add child element: append(child: ) Add to parent element: appendTo(parent: ) Remove yourself: remove() Remove all child elements: empty() Release resource: dispose() Set your own depth to top level: setIndexTop() Set your own depth to bottom level: setIndexBottom() Set position: setPosition(x:Number,y:Number) Change position: addPosition(x:Number,y:Number) Set rotation angle: setRotation(r:Number) Easing: tween(duration:Number, vars:Object)
--------------------------------------------------------------------------------------------------------------------------------
The first step is to refer to the library import cx.asQuery.*; the second step is to initialize it
--------------------------------------------------------------------------------------------------------------------------------
1. The selector may cause performance problems by traversing all subsets. If you just traverse a subset of a layer, you can call it through optimization:
$("ball",ball的父容器,true);
或
$(ball的父容器).find("ball",true);
2. If the filter is used too frequently, too many ASQueryObject objects will be generated. If the same filter needs to be used many times, by cache the selector as a variable, filtering overhead can be saved:
var $ball:ASQueryObject = $("ball");
$ball.attr("x",100);
$ball.click(clickHandler);
3. The above articles are just to introduce the areas where optimization can be done, and do not need to be developed in an optimized way from the beginning, which will lose the flexibility of ASQuery.
4. It is recommended to use the selection operations in projects with more modules (not affecting each other at levels):
$(this).find("ball",true).xx().xx();
--------------------------------------------------------------------------------------------------------------------------------
Add easing animation support - OK Optimize the performance of selectors Add more helper functions Add more selectors Add plug-in extensions
--------------------------------------------------------------------------------------------------------------------------------
Please send the email to submit a bug or contribution code: [email protected] or [email protected]