-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathFlatImage.as
More file actions
79 lines (62 loc) · 1.73 KB
/
FlatImage.as
File metadata and controls
79 lines (62 loc) · 1.73 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
package darkBox
{
import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.geom.Rectangle;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import myMultiTouch.zoomer2;
public class FlatImage extends DefaultImage
{
private var imageLoader:Loader;
private var imageMC:MovieClip;
public function FlatImage()
{
super();
}
override public function hide():void
{
super.hide();
if(imageLoader!=null)
{
try
{
imageLoader.close();
}
catch(e){};
}
}
override public function show(target:String=''):void
{
super.show();
this.removeChildren();
imageMC = new MovieClip();
this.addChild(imageMC);
imageLoader = new Loader();
var loaderContext:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageLoaded);
imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,imageNotLoaded);
imageLoader.load(new URLRequest(target),loaderContext);
}
protected function imageLoaded(event:Event):void
{
var image:Bitmap = (imageLoader.content) as Bitmap ;
image.smoothing = true ;
imageMC.addChild(image);
image.width = rect.width;
image.height = rect.height ;
image.scaleX = image.scaleY = Math.min(image.scaleX,image.scaleY);
image.x = (rect.width-image.width)/2;
image.y = (rect.height-image.height)/2;
zoomer2.zoomAct(imageMC,rect.clone());
}
protected function imageNotLoaded(event:IOErrorEvent):void
{
trace("Image type is unknown");
}
}
}