flash on 2010-8-16
/**
* Copyright Tamanegi_kenshi ( http://wonderfl.net/user/Tamanegi_kenshi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ryVw
*/
package {
import flash.accessibility.Accessibility;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.PixelSnapping;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
import flash.text.TextField;
import flash.events.*;
//
import flash.system.Security;
public class FlashTest extends Sprite {
private var file:String = "http://assets.wonderfl.net/images/related_images/4/46/46b4/46b43fe6e70bed538a247d1cbde929be12baac9e";
//頂点座標
private var _vertices:Vector.<Number> = new Vector.<Number>();
//頂点番号
private var _indices:Vector.<int> = new Vector.<int>();
//UV座標
private var _unData:Vector.<Number> = new Vector.<Number>();
private var bd:BitmapData;
private var btm:Bitmap;
private var xNum:uint = 5;
private var yNum:uint = 5;
private var xInterval:Number;
private var yInterval:Number;
private var ballArr:Array;
private var dragginBall:Ball;
public function FlashTest() {
init();
}//FrashTest
private function init():void{
Security.allowDomain("assets.wonderfl.net");
Security.loadPolicyFile("http://assets.wonderfl.net/crossdomain.xml");
//
var load:Loader = new Loader();
var url:URLRequest = new URLRequest(file);
load.load(url);
load.contentLoaderInfo.addEventListener(Event.INIT, onInit);
}
private function onInit(event:Event):void{
btm = event.target.content;
// bd = new BitmapData(300, 300, true, 0xcccccc);
setVertices();
// setIndices();
drawImage();
}
private function setVertices():void{
/* var bw:int = btm.width;
var bh:int = btm.height;
xInterval = bw / (xNum - 1);
yInterval = bh / (yNum - 1);
for(var i:int = 0; i < yNum; i++){
for(var j:int = 0; j < xNum; j++){
var ball:Ball = new Ball(8, 0x660000);
ballArr.push(ball);
ball.x = xInterval * j - bw / 2 + stage.stageWidth ;
ball.y = yInterval * i - bh / 2 + stage.stageHeight;
addChild(ball);
_vertices.push(ball.x, ball.y);
_unData.push(j / (xNum -1) , i / (yNum - 1));
}
}
*/
var ball:Ball = new Ball(8, 0xff0000);
addChild(ball);
//頂点座標
_vertices.push(80, 100);
_vertices.push(400, 100);
_vertices.push(80, 350);
_vertices.push(400, 350);
//頂点番号
_indices.push(0, 1, 2, 1, 2, 3);
//UV座標
_unData.push(0, 0);
_unData.push(1, 0);
_unData.push(0, 1);
_unData.push(1, 1);
ball.x = btm.x;
}
private function drawImage():void{
graphics.lineStyle(1, 0xff0000);
graphics.beginBitmapFill(btm.bitmapData);
graphics.drawTriangles(_vertices, _indices, _unData);
graphics.endFill();
}
/* private function setIndices():void{
for(var i:int = 0; i < ballArr.length; i++){
if((i + 1) % xNum == 0 || i / xNum == yNum - 1){
} else {
var i1:int = 1;
var i2:int = i + 1;
var i3:int = i + xNum;
var i4:int = i + 1;
var i5:int = i + xNum;
var i6:int = i + 1 + xNum;
_indices.push(i1, i2, i3, i4, i5, i6);
}
}
}
*/
}//class
}//package
import flash.display.Sprite;
class Ball extends Sprite{
function Ball(radias:int, color:uint){
graphics.beginFill(color);
graphics.drawCircle(0,0,radias);
graphics.endFill();
}
}