我正在尝试构建一个类似于Whitevoid使用的投资组合应用程序。我正在使用 Flex 4 和 Papervision3D 2。除了一个问题,我一切正常。当我尝试将外部 SWF 作为材质加载到其中一个平面上时,我可以看到任何本机 Flex 或 Flash 组件处于正确位置,但 papervision 对象未正确渲染。看起来视口没有在嵌套的 swf 中设置。我已经发布了用于加载下面的 swf 的代码。
private function loadMovie(path:String=""):void
{
loader = new Loader();
request = new URLRequest(path);
loader.contentLoaderInfo.addEventListener(Event.INIT, addMaterial);
loader.load(request);
}
private function addMaterial(e:Event):void
{
movie = new MovieClip();
movie.addChild(e.target.content);
var width:Number = 0;
var height:Number = 0;
width = loader.contentLoaderInfo.width;
height = loader.contentLoaderInfo.height;
//calculate the aspect ratio of the swf
var matAR:Number = width/height;
if (matAR > aspectRatio)
{
plane.scaleY = aspectRatio / matAR;
}
else if (matAR < aspectRatio)
{
plane.scaleX = matAR / aspectRatio;
}
var mat:MovieMaterial = new MovieMaterial(movie, false, true, false, new Rectangle(0, 0, width, height));
mat.interactive = true;
mat.smooth = true;
plane.material = mat;
}
下面我贴两张图。第一张是应用程序自行运行的照片。第二个是在飞机上作为 MovieMaterial 的应用程序。您可以看到在 mxml 中创建为 spark 对象的按钮如何保持在正确的位置,但 papervision 球体(正在旋转)在错误的位置。我在这里缺少什么吗?