您的位置:首页 > 编程语言 > Go语言

away3d 4.0.9Gold 学习笔记 开始 自我封装 (2)

2012-10-02 22:24 141 查看
按照以前学习3.6的习惯,因为每次都要添加view3d 等。。我就直接封装一个好了

放在template文件夹下面名字为 AwayTemplate.as 这样我每次要用直接实例化及好了。

package template
{
import away3d.containers.View3D;
import away3d.debug.AwayStats;
import flash.display.Sprite;
import flash.events.Event;

public class AwayTemplate extends Sprite
{
protected var _view:View3D;
private var stats:AwayStats;
public function AwayTemplate()
{
if (stage)
{
init();
}
else
{
addEventListener(Event.ADDED_TO_STAGE,init);
}
}
protected function init(e:Event=null):void
{
removeEventListener(Event.ADDED_TO_STAGE,init);
initView();
addEventListener(Event.ENTER_FRAME,onEnter);
}

protected function initView():void
{
_view = new View3D  ;
_view.backgroundColor = 0x0c0c0c;
addChild(_view);
stats = new AwayStats(_view);
addChild(stats);
}
protected function render():void
{
trace("rendering....");
}
protected function onEnter(e:Event):void
{
_view.render();
render();
}
}
}


这里我提供一份完整的away3d 4.0.9 GOLD版本的下载(包含上面的自我封装类) 下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: