-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractComponent.as
95 lines (86 loc) · 2.51 KB
/
AbstractComponent.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* __ __
* /\ \/\ \ __________
* \ \ \_\ \/_______ /\
* \ \ _ \ ____/ / /
* \ \_\ \_\ \ \/ / /
* \/_/\/_/\ \ \/ /
* \ \ /
* \_\/
*
* -----------------------------------------------------------------------------
* @author: Herbert Veitengruber
* @version: 1.0.0
* -----------------------------------------------------------------------------
*
* Copyright (c) 2010-2012 Herbert Veitengruber
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/
package as3.hv.components
{
import flash.display.MovieClip;
import fl.motion.Color;
import flash.geom.ColorTransform;
// =========================================================================
// Abstract Class AbstractComponent
// =========================================================================
// Base for all swc components
//
public class AbstractComponent
extends MovieClip
{
// =====================================================================
// CONSTANTS
// =====================================================================
// Class version
public static const VERSION:String = "1.0.0";
/**
* =====================================================================
* Constructor
* =====================================================================
*/
public function AbstractComponent():void
{
super();
}
// =====================================================================
// FUNCTIONS
// =====================================================================
/**
* ---------------------------------------------------------------------
* recolorElement
* ---------------------------------------------------------------------
* This helper function can be called from all setters with color/alpha
* adjustments.
*
* @param mov The MovieClip that is recolored
* @param newcolor The new color as uint(0x000000)
* @param newalpha The new alpha value as int (von 0-100)
*/
protected function recolorElement(
mov:MovieClip,
newcolor:uint,
newalpha:int
):void
{
var c:Color = new Color();
c.color = newcolor;
// first set the color
// then set alpha
// otherwise alpha is not set correct!
mov.transform.colorTransform = new ColorTransform(
0,
0,
0,
1,
c.redOffset, // red value
c.greenOffset, // green value
c.blueOffset, // blue value
0
);
mov.alpha = newalpha/100;
}
}
}