请各位flash大侠帮忙看看这段代码 为什么老是TypeError: Error #1034: 强制转换类型失败:无法将 flash.eve
varbeta:Number=Math.PI/3;vartheta:Number=.5;varpressing:Boolean=newBoolean(false);var...
var beta:Number=Math.PI/3;
var theta:Number=.5;
var pressing:Boolean=new Boolean(false);
var oldx:Number,oldy:Number;
var points:Array=new Array(8);
var mc:Sprite=new Sprite();
mc.x=100;
mc.y=120;
addChild(mc);
loadObject("cube");
bg_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragMouse);
bg_mc.addEventListener(MouseEvent.MOUSE_UP,dropMouse);
addEventListener(Event.ENTER_FRAME,adjustDrag);
bt_cube.addEventListener(MouseEvent.MOUSE_DOWN,showCube);
bt_trapezia.addEventListener(MouseEvent.MOUSE_DOWN,showTrapezia);
bt_pyramid.addEventListener(MouseEvent.MOUSE_DOWN,showPyramid);
function showCube(e:MouseEvent) {
loadObject("cube");
}
function showTrapezia(e:MouseEvent) {
loadObject("trapezia");
}
function showPyramid(e:MouseEvent) {
loadObject("pyramid");
}
function loadObject(type:String) {
switch (type) {
case "cube" :
points[0]=new ThreeDpoint(-30,30,30);
points[1]=new ThreeDpoint(30,30,30);
points[2]=new ThreeDpoint(30,-30,30);
points[3]=new ThreeDpoint(-30,-30,30);
break;
case "trapezia" :
points[0]=new ThreeDpoint(-20,20,30);
points[1]=new ThreeDpoint(20,20,30);
points[2]=new ThreeDpoint(20,-20,30);
points[3]=new ThreeDpoint(-20,-20,30);
break;
case "pyramid" :
points[0]=new ThreeDpoint(0,0,30);
points[1]=new ThreeDpoint(0,0,30);
points[2]=new ThreeDpoint(0,0,30);
points[3]=new ThreeDpoint(0,0,30);
break;
}
points[4]=new ThreeDpoint(-30,30,-30);
points[5]=new ThreeDpoint(30,30,-30);
points[6]=new ThreeDpoint(30,-30,-30);
points[7]=new ThreeDpoint(-30,-30,-30);
}
function dragMouse(e:MouseEvent) {
pressing=true;
oldx=mouseX;
oldy=mouseY;
}
function dropMouse(e:MouseEvent) {
pressing=false;
}
function adjustDrag(e:MouseEvent) {
if (pressing==false) {
return;
}
var newx=mouseX;
var newy=mouseY;
var xLength=newx-oldx;
var yLength=newx-oldy;
var distance=Math.sqrt(xLength*xLength+yLength*yLength);
theta=distance=20;
oldx=newx;
oldy=newy;
if (theta==0) {
return;
}
beta=Math.acos(xLength/distance);
if (yLength<0) {
beta=- beta;
}
beta+=Math.PI/2;
}
输出面板:TypeError: Error #1034: 强制转换类型失败:无法将 flash.events::Event@dbfb0d1 转换为 flash.events.MouseEvent。 展开
var theta:Number=.5;
var pressing:Boolean=new Boolean(false);
var oldx:Number,oldy:Number;
var points:Array=new Array(8);
var mc:Sprite=new Sprite();
mc.x=100;
mc.y=120;
addChild(mc);
loadObject("cube");
bg_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragMouse);
bg_mc.addEventListener(MouseEvent.MOUSE_UP,dropMouse);
addEventListener(Event.ENTER_FRAME,adjustDrag);
bt_cube.addEventListener(MouseEvent.MOUSE_DOWN,showCube);
bt_trapezia.addEventListener(MouseEvent.MOUSE_DOWN,showTrapezia);
bt_pyramid.addEventListener(MouseEvent.MOUSE_DOWN,showPyramid);
function showCube(e:MouseEvent) {
loadObject("cube");
}
function showTrapezia(e:MouseEvent) {
loadObject("trapezia");
}
function showPyramid(e:MouseEvent) {
loadObject("pyramid");
}
function loadObject(type:String) {
switch (type) {
case "cube" :
points[0]=new ThreeDpoint(-30,30,30);
points[1]=new ThreeDpoint(30,30,30);
points[2]=new ThreeDpoint(30,-30,30);
points[3]=new ThreeDpoint(-30,-30,30);
break;
case "trapezia" :
points[0]=new ThreeDpoint(-20,20,30);
points[1]=new ThreeDpoint(20,20,30);
points[2]=new ThreeDpoint(20,-20,30);
points[3]=new ThreeDpoint(-20,-20,30);
break;
case "pyramid" :
points[0]=new ThreeDpoint(0,0,30);
points[1]=new ThreeDpoint(0,0,30);
points[2]=new ThreeDpoint(0,0,30);
points[3]=new ThreeDpoint(0,0,30);
break;
}
points[4]=new ThreeDpoint(-30,30,-30);
points[5]=new ThreeDpoint(30,30,-30);
points[6]=new ThreeDpoint(30,-30,-30);
points[7]=new ThreeDpoint(-30,-30,-30);
}
function dragMouse(e:MouseEvent) {
pressing=true;
oldx=mouseX;
oldy=mouseY;
}
function dropMouse(e:MouseEvent) {
pressing=false;
}
function adjustDrag(e:MouseEvent) {
if (pressing==false) {
return;
}
var newx=mouseX;
var newy=mouseY;
var xLength=newx-oldx;
var yLength=newx-oldy;
var distance=Math.sqrt(xLength*xLength+yLength*yLength);
theta=distance=20;
oldx=newx;
oldy=newy;
if (theta==0) {
return;
}
beta=Math.acos(xLength/distance);
if (yLength<0) {
beta=- beta;
}
beta+=Math.PI/2;
}
输出面板:TypeError: Error #1034: 强制转换类型失败:无法将 flash.events::Event@dbfb0d1 转换为 flash.events.MouseEvent。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询