Starling [color]
Starling [color]
[AS3.0] Starlingを試すのだ! (4)
http://www.project-nya.jp/modules/weblog/details.php?blog_id=1622
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ifIi
*/
////////////////////////////////////////////////////////////////////////////////
// Starling [color]
//
// [AS3.0] Starlingを試すのだ! (4)
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1622
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.events.Event;
import flash.display.BitmapData;
import flash.display.Bitmap;
import starling.core.Starling;
[SWF(backgroundColor="#000000", width="465", height="465", frameRate="60")]
public class Main extends flash.display.Sprite {
private var starling:Starling;
//private var source:BitmapData = new BitmapData(465, 465, false, 0x000000);
public function Main() {
Wonderfl.disable_capture();
//addChild(new Bitmap(source));
//
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
init();
}
private function init():void {
starling = new Starling(MainView, stage, null, null);
starling.enableErrorChecking = true;
starling.start();
//addEventListener(Event.ENTER_FRAME, ready, false, 0, true);
}
/*
private function ready(evt:Event):void {
removeEventListener(Event.ENTER_FRAME, ready);
starling.shareContext = true;
addEventListener(Event.ENTER_FRAME, update, false, 0, true);
}
private function update(evt:Event):void {
starling.context.clear();
starling.render();
starling.context.drawToBitmapData(source);
starling.context.present();
}
*/
}
}
//////////////////////////////////////////////////
// internal class MainView
//////////////////////////////////////////////////
import starling.core.Starling;
import starling.display.Sprite;
import starling.display.Quad;
import starling.events.Event;
class MainView extends Sprite {
private var background:Quad;
public function MainView() {
addEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(Event.REMOVED_FROM_STAGE, remove);
}
private function init(evt:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
//
background = new Quad(465, 465, 0x000000);
background.setVertexColor(0, 0x3366FF);
background.setVertexColor(1, 0x00CC00);
background.setVertexColor(2, 0xFF0099);
background.setVertexColor(3, 0xFFCC00);
background.width = 465;
background.height = 465;
addChild(background);
}
private function remove(evt:Event):void {
removeEventListener(Event.REMOVED_FROM_STAGE, remove);
}
override public function dispose():void {
removeEventListener(Event.ADDED_TO_STAGE, init);
removeEventListener(Event.REMOVED_FROM_STAGE, remove);
super.dispose();
}
}