-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBitmapImage.as
More file actions
130 lines (121 loc) · 2.35 KB
/
BitmapImage.as
File metadata and controls
130 lines (121 loc) · 2.35 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package image
{//image.BitmapImage
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
public class BitmapImage extends MovieClip
{
private static var acitvateAnimation:Boolean = true
private var W:Number=0,
H:Number=0,
loadInThisArea:Boolean;
private var _bitmapdata:BitmapData;
private var newBitmap:Bitmap;
private var keepImageRatio:Boolean;
public var id:int;
override public function get width():Number
{
if(W==0)
{
return super.width
}
return W
}
override public function get height():Number
{
if(H==0)
{
return super.height
}
return H
}
public function BitmapImage()
{
super();
}
public function setup(Bitmapdata_p:BitmapData,ImageW:Number=0,ImageH:Number=0,ImageX:Number=0,ImageY:Number=0, LoadInThisArea_p:Boolean=false,keepImageRatio_p:Boolean=true):void
{
_bitmapdata = Bitmapdata_p
if(_bitmapdata==null)
{
trace('Bitmapdata is null')
return
}
loadInThisArea = LoadInThisArea_p
keepImageRatio = keepImageRatio_p
if(ImageH!=0)
{
H = ImageH
}
else
{
H = super.height
}
if(ImageW!=0)
{
W = ImageW
}
else
{
W = super.width
}
if(ImageX!=0)
{
this.x = ImageX
}
if(ImageY!=0)
{
this.y = ImageY
}
if(this.stage!=null)
{
load(null)
}
else
{
this.addEventListener(Event.ADDED_TO_STAGE,load)
}
}
private function load(event:Event=null):void
{
clearTheBitmap()
if(newBitmap)
{
newBitmap.bitmapData.dispose()
Obj.remove(newBitmap)
}
var newBitmapData:BitmapData
if(W!=0 && H!=0)
{
newBitmapData = BitmapEffects.changeSize(_bitmapdata,W,H,keepImageRatio,loadInThisArea)
}
else
{
newBitmapData = _bitmapdata
}
newBitmap = new Bitmap(newBitmapData)
newBitmap.smoothing = true
var imageContainer:Sprite = new Sprite()
this.addChild(imageContainer)
imageContainer.addChild(newBitmap)
if(acitvateAnimation)
{
this.alpha = 0
AnimData.fadeIn(this)
}
this.dispatchEvent(new Event(Event.COMPLETE))
}
public function clearTheBitmap():void
{
if(newBitmap!=null)
{
if(newBitmap.bitmapData!=null)
{
newBitmap.bitmapData.dispose() ;
}
}
}
}
}