以下是用flash cs4自动套用格式后出来的错误: 套用前代码: protected function workspace (v:Event):void { //trace ("stage ->"+cur_workspace+" "+v.type); switch (v.type) { case "mouseDown" : pre_mouseX = mouseX; bg_mc.startDrag (false, new Rectangle(-640,0,640,0)); workspace_mc.startDrag (false, new Rectangle(-640,workspace_mc.y,640,0)); ws_move = true; break; case "mouseUp" : bg_mc.stopDrag (); workspace_mc.stopDrag (); //trace ("mouseX: "+ mouseX + " pre_mouseX:" + pre_mouseX); Xdirection = mouseX - pre_mouseX > 0 ? "left":"right"; Xdirection = mouseX - pre_mouseX == 0 ? "static":Xdirection; //trace (Xdirection + " cur_ws: " + cur_workspace); if (Xdirection == "left" && cur_workspace - 1 >= 0) { TweenLite.to (bg_mc, 0.2, {x:-320*(cur_workspace-1)}); TweenLite.to (workspace_mc, 0.3, {x:-320*(cur_workspace-1)}); cur_workspace = cur_workspace - 1; } else if (Xdirection == "right" && cur_workspace+1 <= ws_size-1) { TweenLite.to (bg_mc, 0.2, {x:-320*(cur_workspace+1)}); TweenLite.to (workspace_mc, 0.3, {x:-320*(cur_workspace+1)}); cur_workspace = cur_workspace + 1; } else { // add other condition here } //trace (Xdirection); ws_move = false; break; case "click" : //trace ("click"); break; } //trace ("stage After->"+cur_workspace); } // function workspace end /// 套用后: protected function workspace (v:Event):void { //trace ("stage ->"+cur_workspace+" "+v.type); switch (v.type) { case "mouseDown" : pre_mouseX = mouseX; bg_mc.startDrag (false, new Rectangle(-640,0,640,0)); workspace_mc.startDrag (false, new Rectangle(-640,workspace_mc.y,640,0)); ws_move = true; break; case "mouseUp" : bg_mc.stopDrag (); workspace_mc.stopDrag (); //trace ("mouseX: "+ mouseX + " pre_mouseX:" + pre_mouseX); Xdirection = mouseX - pre_mouseX > 0 ? "left":"right"; Xdirection = mouseX - pre_mouseX == 0 ? "static":Xdirection; //trace (Xdirection + " cur_ws: " + cur_workspace); if (Xdirection == "left" && cur_workspace - 1 >= 0) { TweenLite.to (bg_mc, 0.2, {x:-320*(cur_workspace-1)}); TweenLite.to (workspace_mc, 0.3, {x:-320*(cur_workspace-1)}); cur_workspace = cur_workspace - 1; } else if (Xdirection == "right" && cur_workspace+1 <= ws_size-1) { TweenLite.to (bg_mc, 0.2, {x:-320*(cur_workspace+1)}); TweenLite.to (workspace_mc, 0.3, {x:-320*(cur_workspace+1)}); cur_workspace = cur_workspace + 1; } else { }// add other condition here }; //trace (Xdirection); ws_move = false; break; case "click" : //trace ("click"); break; } //trace ("stage After->"+cur_workspace); } // function workspace end /// 明显的错误, 它自己添加了半个括号和分号。 不知道是不是我哪里用错了。 暂且记下。