⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sequence.as

📁 flash as编程的库和源代码
💻 AS
📖 第 1 页 / 共 2 页
字号:
			} else {
				percentages[i] = {start:100, end:0};
			}
		}
		child = childsArr[roundedPosEnd];
		child.addEventListener(AnimationEvent.END, onEnd);
		if(backwards) {
			percentages[roundedPosEnd] = {start:100, end:end_loc};
		} else {
			percentages[roundedPosEnd] = {start:0, end:end_loc};
		}
		
		var details:Object = new Object();
		details.backwards = backwards;
		details.position = roundedPosStart+1;
		details.roundedPosStart = roundedPosStart;
		details.roundedPosEnd = roundedPosEnd;		
		details.percentages = percentages;		
		return details;
	}	
	public function onStart(event:AnimationEvent):void {	
		this.dispatchEvent(new SequenceEvent(AnimationEvent.START, 
						this.getStartValue(),
						this.childDuration));
	}	
	
	public function onUpdate(event:AnimationEvent):void {	
		this.dispatchEvent(new SequenceEvent(AnimationEvent.UPDATE, 
						this.getCurrentValue(),
						this.childDuration));
	}
		public function onEnd(event:AnimationEvent):void {		
		event.currentTarget.removeEventListener(AnimationEvent.END, onEnd);		var successor:IAnimatable = this.sequenceArr.shift();
		if(successor == null) {			this.setTweening(false);
			
			this.dispatchEvent(new SequenceEvent(AnimationEvent.END, 
									this.getEndValue(),
									NaN,
									IAnimatable( event.target ),
									null));

		} else {			/*backwards will only be true in Sequence mode JOIN*/			if(this.animateMode == Sequence.JOIN && this.backwards) {				this.position--;			} else {				this.position++;			}
			this.elapsedDuration += event.target.getDurationElapsed();
			this.currentChild = successor;
			this.childDuration = successor.duration;
														
			this.dispatchEvent(new SequenceEvent(SequenceEvent.UPDATE_POSITION, 
															this.getCurrentValue(),
															this.childDuration,
															IAnimatable(event.target),
															successor));
			
			successor["animate"].apply(successor, [this.percentages[this.position-1].start, 
												this.percentages[this.position-1].end]);		}			}
	override public function animationStyle(duration:Number, easing:* = null):void {		super.animationStyle(duration, easing);		var i:Number, len:Number = this.childsArr.length;		var dividedDuration:Number = this.childDuration = duration / len;		for (i = 0; i < len; i++) {
			this.childsArr[i].animationStyle(dividedDuration, easing);					
		}
	}
	public function setAnimateMode(animateMode:String):Boolean {		if(animateMode == Sequence.EACH || animateMode == Sequence.JOIN) {				this.animateMode = animateMode;		} else {			return false;		}		var i:Number, len:Number = this.childsArr.length;		for (i = 0; i < len; i++) {			var child:* = this.childsArr[i];			if(child is Sequence) {				child.setAnimateMode(animateMode);			}		}		return true;		}	public function getAnimateMode():String {		return this.animateMode;	}
		public function getChild():IAnimatable {				return IAnimatable(this.currentChild);
	}

	public function getChildren():Array {
		return this.childsArr;
	}

	public function getNextChild():IAnimatable {
		if(this.animateMode == Sequence.JOIN && this.backwards) {
			return IAnimatable(this.childsArr[this.position-2]);
		} else {
			return IAnimatable(this.childsArr[this.position]);
		}
	}

	public function getPreviousChild():IAnimatable {		
		if(this.animateMode == Sequence.JOIN && this.backwards) {
			if(this.position-1 == this.childsArr.length) {
				return IAnimatable(this.childsArr[this.position-1]);
			} else {
				return IAnimatable(this.childsArr[this.position]);
			}			
		} else {
			return IAnimatable(this.childsArr[this.position-2]);
		}
	}
	public function getChildDuration():Number {				return this.childDuration;	}
	public function addChild(component:IAnimatable):IAnimatable {		this.childsArr.push(component);		return component;	}	public function removeChild(component:IAnimatable):void {				var i:Number, len:Number = this.childsArr.length;		for (i = 0; i < len; i++) {			if(this.childsArr[i] == component) {				this.childsArr.splice(i, 1);			}		}	}

	override public function roundResult(rounded:Boolean):void {
		var i:Number, len:Number = this.childsArr.length;
		for (i = 0; i < len; i++) {
			this.childsArr[i].roundResult(rounded);		
		}
	}

	override public function forceEnd(forceEndVal:Boolean):void {
		var i:Number, len:Number = this.childsArr.length;
		for (i = 0; i < len; i++) {
			this.childsArr[i].forceEnd(forceEndVal);		
		}
	}

	override public function setOptimizationMode(optimize:Boolean):void {
		this.equivalentsRemoved = optimize;
		var i:Number, len:Number = this.childsArr.length;
		for (i = 0; i < len; i++) {
			this.childsArr[i].setOptimizationMode(optimize);		
		}
	}	

	override public function setTweenMode(tweenMode:String):Boolean {
		super.setTweenMode(tweenMode);
		var isSet:Boolean;
		var i:Number, len:Number = this.childsArr.length;
		for (i = 0; i < len; i++) {
			isSet = this.childsArr[i].setTweenMode(tweenMode);		
		}
		return isSet;
	}

	override public function setDurationMode(durationMode:String):Boolean {
		super.setDurationMode(durationMode);
		var isSet:Boolean;
		var i:Number, len:Number = this.childsArr.length;
		for (i = 0; i < len; i++) {
			isSet = this.childsArr[i].setDurationMode(durationMode);		
		}
		return isSet;
	}
	
	override public function accept(visitor:IVisitor):void {
		var i:Number, len:Number = this.childsArr.length;
		for (i = 0; i < len; i++) {
			visitor.visit(this.childsArr[i]);			
		}
	}

	override public function stop():Boolean {		
		var success:Boolean = this.getChild().stop();
		if(success) {
			this.setTweening(false);
			this.paused = false;
			
			this.dispatchEvent(new SequenceEvent(AnimationEvent.END, 
									this.getEndValue(),
									NaN,
									null,
									this.getChild()));										
		}
		return success;
	}	
	override public function pause(duration:Number = 0):Boolean {		
		var success:Boolean = this.getChild().pause(duration);
		if(success) {
			this.setTweening(false);
			this.paused = true;
		}
		return success;		
	}	
	override public function resume():Boolean {	
		var success:Boolean = this.getChild().resume();
		if(success) {
			this.setTweening(true);
			this.paused = false;
		}
		return success;
	}	
	override public function getStartValue():Number {		
		var startValue:Number = super.getStartValue();
		if(isNaN(startValue)) {
			startValue = 0;
		}		
		return startValue;
	}

	override public function getEndValue():Number {		
		var endValue:Number = super.getEndValue();
		if(isNaN(endValue)) {
			endValue = 100;
		}
		return endValue;
	}
		override public function getCurrentValue():Number {
		return this.position;
	}
	
	override public function getCurrentPercentage():Number {
		var pos:Number = this.getCurrentValue()-1;
		var perc:Number = this.currentChild.getCurrentPercentage();
		if(isNaN(perc)) {
			perc = 0;			
		}
		if(this.animateMode == Sequence.EACH && this.backwards == true) {
			pos = this.getEndValue() - (pos - (this.getStartValue() - 1));
		}
		var currentValue:Number = pos + perc / 100;
		var currentPerc:Number = currentValue / (this.childsArr.length) * 100;		
		return currentPerc;
	}
	override public function getDurationElapsed():Number {
		return this.elapsedDuration + this.currentChild.getDurationElapsed();
	}
	override public function getDurationRemaining():Number {
		return this.duration - this.getDurationElapsed();
	}}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -