View difference between Paste ID: em6YcMrm and XrHpCWgA
SHOW: | | - or go back to the newest paste.
1
package;
2
import flash.display.Bitmap;
3
import flash.display.BitmapData;
4
import flash.display.Loader;
5
import flash.display.Sprite;
6
import flash.geom.Point;
7
import flash.geom.Rectangle;
8
import flash.events.Event;
9
import flash.net.URLRequest;
10
11
class Tile extends Sprite
12
{
13
	public function new(url:String)
14-
    {
14+
	{
15-
        super();
15+
		super();
16-
        var loader = new Loader();
16+
		var loader = new Loader();
17-
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
17+
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
18-
        loader.load(new URLRequest(url));
18+
		loader.load(new URLRequest(url));
19-
    }
19+
	}
20-
    function onLoadComplete(event:Event):Void
20+
	function onLoadComplete(event:Event):Void
21-
    {
21+
	{
22-
        var loader:Loader = event.currentTarget.loader;
22+
		var loader:Loader = event.currentTarget.loader;
23-
        var content:Bitmap = cast(loader.content, Bitmap);
23+
		var content:Bitmap = cast(loader.content, Bitmap);
24-
        var source:BitmapData = content.bitmapData;
24+
		var source:BitmapData = content.bitmapData;
25-
        
25+
		
26-
        var sourceRect = new Rectangle(0,0,50,50);
26+
		var sourceRect = new Rectangle(0,0,50,50);
27-
        var destPoint = new Point(0,0);
27+
		var destPoint = new Point(0,0);
28-
        var bmd = new BitmapData(50,50);
28+
		var bmd = new BitmapData(50,50);
29-
        bmd.copyPixels(source, sourceRect, destPoint);
29+
		bmd.copyPixels(source, sourceRect, destPoint);
30-
        var bmp = new Bitmap(bmd);
30+
		var bmp = new Bitmap(bmd);
31-
        addChild(bmp);
31+
		addChild(bmp);
32-
    }
32+
	}
33
}
34
35
class Main extends Sprite
36
{
37-
    
37+
	
38-
    public function new()
38+
	public function new()
39-
    {
39+
	{
40-
        super();
40+
		super();
41-
        var tile = new Tile("image.jpg");
41+
		var tile = new Tile("image.jpg");
42-
	tile.x = 320;
42+
		addChild(tile);
43-
	tile.y = 0;
43+
		tile.x = 320;
44-
    }
44+
		tile.y = 0;
45-
    public static function main()
45+
	}
46-
    {
46+
	public static function main()
47-
        flash.Lib.current.addChild(new Main());
47+
	{
48-
    }
48+
		flash.Lib.current.addChild(new Main());
49
	}
50
}