2009-08-25 70 views
1

我在使用庫中的MovieClip創建交互式動畫飛機時遇到了一些麻煩,以顯示任何類型的動畫或接收任何鼠標事件。交互式飛機遇到問題

具體來說,我遇到了MovieClip中Button實例的不同狀態問題。

下面是我與測試的基本代碼:

private function init3D():void 
    { 
     viewport = new Viewport3D(1024, 768, false, true); 
     addChild(viewport); 

     camera = new Camera3D(); 
     camera.z = -500; 
     camera.zoom = 1; 
     camera.focus = 500; 
     camera.target = DisplayObject3D.ZERO; 

     scene = new Scene3D(); 
     renderer = new BasicRenderEngine(); 

     stage.addEventListener(Event.ENTER_FRAME, loop); 
    } 

    public function addChild3D(link:String):Plane 
    { 
     //var demoPlane:DemoPlane = new DemoPlane(link); 
     //return scene.addChild(demoPlane.getPlane()); 

     var material:MovieAssetMaterial = new MovieAssetMaterial(link, false, true, false, false); 
     material.interactive = true; 
     //material.smooth = true; 
     material.animated = true; 

     var plane_mc:Plane = new Plane(material, 0, 0, 10, 10); 
     scene.addChild(plane_mc); 

    } 

    private function loop(evt:Event):void 
    { 
     renderer.renderScene(scene, camera, viewport); 
    } 
+0

糾正我,如果我錯了,但我看不出有什麼處理程序代碼中的任何按鈕。 – 2009-08-25 18:28:17

+0

處理程序位於我使用addChild3D添加的MovieClip中: start_btn.addEventListener(MouseEvent.CLICK,startDemo); – 2009-08-25 18:34:19

回答

0

package{ 

    import org.papervision3d.*; 
    import org.papervision3d.view.*; 
    import org.papervision3d.cameras.*; 
    import org.papervision3d.materials.*; 
    import org.papervision3d.objects.*; 
    import org.papervision3d.objects.primitives.*; 
    import org.papervision3d.scenes.*; 
    import org.papervision3d.render.*; 

    import flash.display.*; 
    import flash.events.*; 

    public class PV3DPlane extends MovieClip{ 

     private var viewport:Viewport3D; 
     private var camera:Camera3D; 
     private var scene:Scene3D; 
     private var renderer:BasicRenderEngine; 
     private var plane:Plane; 

     public function PV3DPlane(){ 
      init3D(); 
     } 

     private function init3D():void 
     { 
       viewport = new Viewport3D(1024, 768, false, true); 
       addChild(viewport); 

       camera = new Camera3D(); 
       camera.z = -500; 
       camera.zoom = 1; 
       camera.focus = 500; 
       camera.target = DisplayObject3D.ZERO; 

       scene = new Scene3D(); 
       renderer = new BasicRenderEngine(); 


       plane = addChild3D('asset'); 

       stage.addEventListener(Event.ENTER_FRAME, loop); 
     } 

     public function addChild3D(link:String):Plane 
     { 
       var material:MovieAssetMaterial = new MovieAssetMaterial(link, false, true, false, false); 
       material.interactive = true; 
       //material.smooth = true; 
       material.animated = true; 
       material.doubleSided = true; 

       var plane_mc:Plane = new Plane(material, 0, 0, 10, 10); 
       scene.addChild(plane_mc); 
       return plane_mc; 
     } 

     private function loop(evt:Event):void 
     { 
       plane.rotationY++; 
       renderer.renderScene(scene, camera, viewport); 
     } 
    } 
} 

我工作正常,我...我只是創建了一個名爲一個虛設夾子我剛纔想你的代碼按鈕並補充:

button.addEventListener('click', function(){trace('click')}); 

我得到的痕跡,一切正常。 您正在使用什麼papervision版本? 在這個機器上我有一老一 Papervision3D的公開測試版2.0 - 大白(25年8月20日)

這裏是flaas文件我使用。

+0

我認爲問題在於我正在嘗試使用SimpleButton,而那些不受PV3D支持。 – 2009-08-27 18:04:10