2009/04/20

Javascript library & relative soruce

I introduce some javascript libraries on the internet.

The Yahoo! User Interface Library (YUI)
http://developer.yahoo.com/yui/

Dojo

JSLint :

Packer / Javascript compressor :

Jsmin / Javascript compressor :

2009/02/26

private VS. private static in Class

Main Class:(document )
package{
import flash.display.Sprite;
import flash.events.MouseEvent;
import fl.controls.Button;
public class Main extends Sprite{
public var obj1:Obj;
public var obj2:Obj;
public function Main(){
obj1=new Obj();
obj2=new Obj();
var button:Button=new Button();
button.label='click';
addChild(button);
button.addEventListener(MouseEvent.CLICK,onButtonClick);
}
private function onButtonClick(evt:MouseEvent):void{
obj1.name='obj_1';
trace(obj1.name);
obj2.name='obj_2';
trace(obj2.name);
trace(obj1.name);
}
}
}
Obj Class:
package {
public class Obj {
private var nameObj:String;
public function Obj() {
}
public function set name(nameObj:String):void{
this.nameObj=nameObj;
}
public function get name():String{
return nameObj;
}
}
}
//export the flash then click the button will result=======================//
obj_1
obj_2
obj_1
//==============================================================//

if Obj class modifies as follows and others are the same:

Obj Class:
package {
public class Obj {
private static var nameObj:String;
public function Obj() {
}
public function set name(nameOb:String):void{
nameObj=nameOb;
}
public function get name():String{
return nameObj;
}
}
}
//export the flash then click the button will result=======================//
obj_1
obj_2
obj_2
//==============================================================//
Summary:
I ever cofused the access control attribute when  add private static differentiate only private  in class. private variable in class alreay can't use except inside the class and why add static to use( to access by using class property)??

you see elarly codes  show add static with private:
1. private static variable will be one variable in class when using multi-objects
2. attention when use the  this keyword & arguement name confict when add static status.