且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Flash Player10 3D测试

更新时间:2022-09-07 23:13:55

在Adobe于5.15 发布Flash Player 10beta版以来一直想试试这个牛X的功能:3d支持
今天抽空玩了下3d旋转,性能上比之前pv3d,sandy,away3d等模拟出来的牛X很多

演示:(需要Flash Player 10 ActiveX for IE / Plugin for Firefox ,否则看不到上面的效果)

package
{
import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.StageAlign;
public class main extends Sprite
{
public function main()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = "noScale";
//load a picture as display object
var ldr:Loader = new Loader();
ldr.load(new URLRequest("photo1.jpg"));
ldr.contentLoaderInfo.addEventListener("complete",onloaded);
addChild(ldr);

function onloaded(e:Event):void
{
//trace(e.target.content)
var bmp:Bitmap = Bitmap(e.target.loader.content);
//bmp.width /= 2
//bmp.height /= 2
bmp.x = -bmp.width/2;
bmp.y = -bmp.height/2;
stage.addEventListener(Event.ENTER_FRAME, rotateMovieClip);
}

function rotateMovieClip(e:Event):void
{
ldr.rotationX -= (stage.stageHeight/2-mouseY)/50;
ldr.rotationY += (stage.stageWidth/2-mouseX)/50;
//ldr.rotationZ += 5;
ldr.x = stage.stageWidth/2;
ldr.y = stage.stageHeight/2;
}
}
}
}
本文转自jiahuafu博客园博客,原文链接http://www.cnblogs.com/jiahuafu/archive/2010/05/12/1733510.html如需转载请自行联系原作者

jiahuafu