如何将 Papervision/Flex 应用程序 (SWF) 作为材质加载到 Papervision 平面上?
我正在尝试构建一个类似于 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 球体(正在旋转)位于错误的位置。我在这里缺少什么吗?
I am trying to build a portfolio application similar to the used by Whitevoid. I am using Flex 4 and Papervision3D 2. I have everything working except for one issue. When I try to load an external SWF as a material on one of the planes, I can see any native Flex or Flash components in their correct positions, but the papervision objects are not being rendered properly. It looks like the viewport is not being set in the nested swf. I have posted my code for loading the swf below.
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;
}
Below I have posted two pictures. The first is a shot of the application running by itself. The second is the application as a MovieMaterial on a Plane. You can see how the button created as a spark object in the mxml stays in the correct position, but papervision sphere (which is rotating) is in the wrong location. Is there something I am missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
男人。我有一段时间没看到那个网站了。仍然是最酷的光伏项目之一......
您的意思是:
您说您可以看到组件处于适当的位置,例如:您有一个飞机,其看起来像是正在加载的预期文件?但我猜你无法与之互动。
据我所知,我花了相当多的时间尝试做类似的工作,MovieMaterial(我假设你正在使用)绘制了你的MovieClip中存在的任何内容的位图,如果你设置它设置为animated=true,那么它将渲染出一系列位图——相当于动画。它没有做的是在平面上显示实际的 MovieClip(或 SWF)。因此,您可能会看到您的组件,但这就是这样的:
MovieMaterial.as line 137
请注意,在 WhiteVoid 中,您永远不会真正与电影交互,直到它“落地”= 他很可能在位图纹理平面顶部交换电影。
您正在与之交互的部分可能是另一个平面,其中包含“按钮”,该按钮在鼠标悬停时变得可见。
我认为 PV1.0 可以访问真实的 swf 作为材质,但这种情况在 2.0 中发生了变化。可悲的是。希望莫尔希尔会。
干杯
Man. I haven't seen that site in a while. Still one of the cooler PV projects...
What do you mean by:
You say you can see the components in their appropriate positions, as in: you have a plane with what looks like the intended file loading up? But I'm guessing that you can't interact with it.
As far as I know, and I've spent a reasonable amount of time trying to make something similar work, the MovieMaterial (which I assume you're using) draws a Bitmap of whatever contents exist in your MovieClip, and if you set it to animated=true, then it will render out a series of bitmaps - equating animation. What it's not doing, is displaying an actual MovieClip (or SWF) on the plane. So you may see your components, but this is how:
MovieMaterial.as line 137
Note in the WhiteVoid you never actually interact with a movie until it "lands" = he's very likely swapping in a Movie on top of the bitmap textured plane.
The part that you are interacting with is probably another plane that holds the "button" that simply becomes visible on mouseover.
I think PV1.0 had access to real swfs as a material but this changed in 2.0. Sadly. Hopefully Molehill will.
cheers