Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

AbstractInterpolateFilter.as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.senocular.gyro {
	
	public class AbstractInterpolateFilter extends Interpolate {
			
		protected var _isFilter:Boolean;
		
		override public function set owner(value:*):void {
			_owner = value;
			updateIsFilter();
		}
		
		override public function set property(value:Object):void {
			_property = value;
			updateIsFilter();
		}
			
		public function AbstractInterpolateFilter(owner:* = null, property:Object = null){			
			super(owner, property);
			updateIsFilter();
		}
		
		protected function updateIsFilter():void {
			_isFilter = Boolean("filters" in _owner && _property != null && !isNaN(Number(_property)));
		}
		
		protected function assign(target:*):void {
			if (target == null) return;
			
			if (_isFilter) {
				var filters:Array = _owner.filters;
				filters[_property] = target;
				owner.filters = filters;
			}else if (_owner && _property != null){
				_owner[_property] = target;
			}
		}
	}
}