Gestureworks 与 AS 3
我在Flex 4上使用gestureworks和papervision 3d,并且使用AS 3。我遇到一个问题,那就是我在行-container.addChild(cone)中不断收到错误,它给出的输出是 “1067:将 import org.papervision3d.objects.primitives.Cone 类型的值隐式强制转换为不相关的类型 flash.display:DisplayObject”
我可以知道出了什么问题吗?
公共类 TouchApp 扩展应用程序
:
:
:
公共函数 TouchApp():void
{
cone = new Cone();
scene = new Scene 3D;
cam = new Camera 3D();
viewport = new Viewport3D(800,600);
addChild(viewport);
container = new TouchSprite();
rendEng = new BasicRenderEngine();
addEventListener(Event,ENTER_FRAME, gestCone);
}
public function gestCone(E:Event):void
{
container.blobContainerEnabled = true;
container.addEventListener(TouchEvent.TOUCH_DOWN, downCone);
container.addEventListener(TouchEvent.TOUCH_UP, upCone);
**container.addChild(cone);**
addChild(container);
rendEng.renderScene(scene,cam,viewport);
}
I am using gestureworks with papervision 3d on Flex 4, and i am using AS 3. I experience one problem, which is that i keep getting error in the line - container.addChild(cone), and it give the output which is
"1067 : Implicit coercion of a value of type import org.papervision3d.objects.primitives.Cone to an unrelated type flash.display:DisplayObject"
May i know what went wrong?
public class TouchApp extends Application
:
:
:
public function TouchApp():void
{
cone = new Cone();
scene = new Scene 3D;
cam = new Camera 3D();
viewport = new Viewport3D(800,600);
addChild(viewport);
container = new TouchSprite();
rendEng = new BasicRenderEngine();
addEventListener(Event,ENTER_FRAME, gestCone);
}
public function gestCone(E:Event):void
{
container.blobContainerEnabled = true;
container.addEventListener(TouchEvent.TOUCH_DOWN, downCone);
container.addEventListener(TouchEvent.TOUCH_UP, upCone);
**container.addChild(cone);**
addChild(container);
rendEng.renderScene(scene,cam,viewport);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到该错误是因为 TouchSprite 期望将 DisplayObject 添加到其显示列表中,而您尝试添加不从 DisplayObject 类继承的 pv3d 对象“Cone”...您可以尝试使用 container.addChild(cone .container)但我不确定这是否有效......
You are getting that error because TouchSprite expects a DisplayObject to be added to it's displaylist, whilst you are trying to add a pv3d object "Cone" which does not inherit from the DisplayObject class... You can try to use container.addChild(cone.container) but I'm not sure that will work...