Gestureworks with AS 3
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 erro开发者_JS百科r 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);
}
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...
精彩评论