我已经被这样的错误困住了2天了,然而我从前面提出的关于这个错误的问题的数量上搜索解决这个问题,我似乎仍然无法让它工作,主要是因为我根本不明白。
这是我的代码:
package {
import flash.events.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import org.libspark.flartoolkit.support.pv3d.FLARBaseNode;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cone;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.materials.MovieAssetMaterial;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.objects.primitives.Cube;
[SWF(width=640, height=530, backgroundColor=0x808080, frameRate=30)]
public class Earth extends PV3DARApp {
private var _earth:DAE;
private var _teapot:DAE;
private var _bone:DAE;
protected var _baseNode:FLARBaseNode
public function Earth() {
addEventListener(Event.INIT, _onInit);
init('Data/camera_para.dat', 'Data/paris.pat');
}
private function _onInit(e:Event):void {
bulet.addEventListener(MouseEvent.CLICK, _tombolbulet);
teapot.addEventListener(MouseEvent.CLICK, _tombolteapot);
tulang.addEventListener(MouseEvent.CLICK, _tomboltulang);
addChild(bulet);
addChild(teapot);
addChild(tulang);
_earth = new DAE();
_earth.load('model/earth.dae');
_earth.scale = 10;
_earth.rotationX = 90;
//_markerNode.addChild(_earth);
_teapot = new DAE();
_teapot.load('model/teapot.DAE');
_teapot.scale = 10;
_teapot.rotationX = 90;
//_markerNode.addChild(_teapot);
_bone = new DAE();
_bone.load('model/bone.DAE');
_bone.scale = 10;
_bone.rotationX = 90;
//_markerNode.addChild(_bone);
function _tombolbulet (event:MouseEvent):void
{
remove_all();
_baseNode.addChild(_earth);
}
function _tombolteapot (event:MouseEvent):void
{
remove_all();
_baseNode.addChild(_teapot);
}
function _tomboltulang (event:MouseEvent):void
{
remove_all();
_baseNode.addChild(_bone);
}
function remove_all () : void
{
_baseNode.removeChild(_earth);
_baseNode.removeChild(_teapot);
_baseNode.removeChild(_bone);
}
//addEventListener(Event.ENTER_FRAME, _update);
}
/*private function _update(e:Event):void {
_earth.rotationZ += 0.5
_teapot.rotationZ += 0.5
_bone.rotationZ += 0.5
}*/
}
}
答案 0 :(得分:0)
您应首先给孩子打电话new DAE()
,然后通过addChild()
添加,而不是相反。此外,没有声明bulet
,但有一个bone
。此外,您删除remove_all()
中的所有子项,而其中只有一个似乎一次在屏幕上。此外,你有很多错误的变量,这会使代码混乱。