Archive for May, 2005


TransitionManager和Transition类

TransitionManager.start()静态方法

  • 在目标mc上建了一个TrainsitionManager实例。
  • 使该mc监听TrainsitionManager实例的allTransitionsInDone、allTransitionsOutDone事件。
  • 返回一个Transition实例,并使mc上的TrainsitionManager实例设置为Transition实例的manager属性;TrainsitionManager实例监听Transition实例的transitionInDone、transitionOutDone、transitionProgress事件。

综上所述:执行

var trns:mx.transitions.Transition = mx.transitions.TransitionManager.start(mc, transParams);

之后就生成以下事件处理函数:

trns.manager.transitionProgress
trns.manager.transitionInDone
trns.manager.transitionOutDone
mc.allTransitionsInDone
mc.allTransitionsOutDone

复制和粘贴快捷键

 
KeyListener = new Object();
KeyListener.onKeyDown = function() {
	if (Key.isDown(Key.CONTROL) and Key.isDown(67)) {
		if (Selection.getFocus() != null) {
			copy = Selection.getFocus();
		}
	} else if (Key.isDown(Key.CONTROL) and Key.isDown(86)) {
		if (Selection.getFocus() != null) {
			_root[Selection.getFocus()] = eval(copy);
		}
	}
};
Key.addListener(KeyListener);
 

流行的文字出现和消失效果

 
TextField.prototype.constructTextbyLetter = function(txt, speed, size) {
	if (!size) {
		size = 1;
	}
	if (!speed) {
		speed = 10;
	}
	var i = 0;
	var txt = txt;
	clearInterval(_root[this._name+'Int']);
	_root[this._name+'Int'] = setInterval(function (_txt) {
		// from start
		//_txt.text = txt.substr(0, (i+=size))
		// from start with acceleration
		_txt.text = txt.substr(0, _txt.length+(i += size));
		// from end
		//_txt.text = txt.substr(txt.length-(i+=size))
		// from end with acceleration
		//var first_letter = txt.length-(_txt.length+(i+=size))
		//_txt.text = txt.substr((first_letter < 0 ? 0 : first_letter))
		//
		updateAfterEvent();
		if (_txt.length>=txt.length) {
			clearInterval(_root[_txt._name+'Int']);
		}
	}, speed, this);
};
TextField.prototype.deConstructTextbyLetter = function(speed, size) {
	if (!size) {
		size = 1;
	}
	if (!speed) {
		speed = 10;
	}
	var i = 0;
	var len = this.length;
	clearInterval(_root[this._name+'Int']);
	_root[this._name+'Int'] = setInterval(function (_txt) {
		// from end
		//_txt.text = _txt.text.substr(0, len-(i+=size))
		// from end with acceleration
		//_txt.text = _txt.text.substr(0, _txt.length-(i+=size))
		// from start
		//_txt.text = _txt.text.substr(size)
		// from start with acceleration
		_txt.text = _txt.text.substr((i += size));
		updateAfterEvent();
		if (!_txt.length) {
			clearInterval(_root[_txt._name+'Int']);
		}
	}, speed, this);
};

Usage:

 
//Create a textfield in the main timeline, name it to test, make it dynamic.
//put this code to your _root.
test.constructTextbyLetter("Another sample text .", 100, 3);
// or
test.constructTextbyLetter("Another sample text .", 100);
//Deconstruct:
test.constructTextbyLetter(100);
Powered by KevinCao.com ©2010 | Platform: WordPress | Theme: Motion
kevincao.com