如何检测Adobe Flash崩溃的原因?

时间:2012-08-24 04:25:56

标签: actionscript-3 debugging crash mesh vertex

Edit02:闪存崩溃的原因是错误的距离导致程序将某些东西除以0 - 我自己发现了错误,但我的问题仍然是,是否有像crashreport这样的东西可以添加/编辑?

编辑:我发现脚本中的错误位于此处

          if(baseVerticies[vertX]-boneObj.x < 0){
                distance = distance*-1;
            }

有一点它会产生错误的距离,但这不是程序导致崩溃的原因,我知道如何解决这个问题但是如何添加函数以检测闪存崩溃原因仍然会很有趣

OLD: 嘿,我目前正在测试CS6 Flash演示,但是一个函数总是杀死flash而我没有收到任何错误信息,所以我的问题是......我怎么能找到这个bug呢?

我所知道的唯一的事情:当我调用某个功能(我在下面发布的那个)时它会崩溃 - 它在第一次调用时没有崩溃...更像是在第三次或第二次

有没有办法添加debugEvents或其他有助于跟踪错误的内容?

提前=)

public function rotateBone(boneObj : Bone, point : Point){
            //rotates the boneGrafik
            boneObj.rotation = (point.x+boneObj.old_rotation)/2;

            if(axis == "horizontal"){
                var firstV : int = selected_bone*(squares+1)*2;
                var lastV : int = selected_bone*(squares+1)*2 + squares*2;
                var radius : Number = Math.sqrt((verticies[lastV]-verticies[firstV])*(verticies[lastV]-verticies[firstV])+
                    (verticies[lastV+1]-verticies[firstV+1])*(verticies[lastV+1]-verticies[firstV+1]));

                //will be exectued for every single vertex
                for(var s = 0; s<=squares; s++){
                    var vertX : int = selected_bone * (squares+1) * 2 + s*2;

                    var distance : Number = Math.sqrt((verticies[vertX]-boneObj.x)*(verticies[vertX]-boneObj.x)+
                        (verticies[vertX+1]-boneObj.y)*(verticies[vertX+1]-boneObj.y));

                    //calculates Vector
                    var rads:Number = boneObj.rotation / 180 * Math.PI;
                    var p:Point = new Point();
                    p.x=Math.cos(rads);
                    p.y=Math.sin(rads);

                    //baseMesh is used in order to check if the vertex pos is positiv / negative
                    if(baseVerticies[vertX]-boneObj.x < 0){
                        distance = distance*-1;
                    }

                    verticies[vertX] =  boneObj.x +  p.x * radius * (distance/radius);
                    verticies[vertX+1] =  boneObj.y +  p.y * radius * (distance/radius);

                }
            }else if (axis == "vertical"){
                for(var r = 0; r<=rows; r++){
                    vertX = r * (squares+1) * 2 + selected_bone * 2;

                }
            }
            updateMesh();
        }

1 个答案:

答案 0 :(得分:2)

我不确定你的意思是它毫无例外地崩溃了。你在浏览器中测试吗?如果是这样,那么您可以从以下列表中下载并安装相应的Flash调试器播放器:http://www.adobe.com/support/flashplayer/downloads.html

每当FlashPlayer崩溃时,这会给你一个错误窗口,其中包含调试信息。它还会将崩溃和调试数据写入日志文件。这里有更多信息:http://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html

最后,如果要捕获并处理其他未处理的异常,可以在FP10.1及更高版本中执行此操作。以下是关于它的Adobe文档:http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/events/UncaughtErrorEvent.html,以下是该页面的示例代码:

package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.ErrorEvent;
import flash.events.UncaughtErrorEvent;
import flash.net.URLRequest;

public class LoaderUncaughtErrorEventExample extends Sprite
{
    private var ldr:Loader;

    public function LoaderUncaughtErrorEventExample()
    {
        ldr = new Loader();
        ldr.load(new URLRequest("child.swf"));
        ldr.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
    }

    private function uncaughtErrorHandler(event:UncaughtErrorEvent):void
    {
        if (event.error is Error)
        {
            var error:Error = event.error as Error;
            // do something with the error
        }
        else if (event.error is ErrorEvent)
        {
            var errorEvent:ErrorEvent = event.error as ErrorEvent;
            // do something with the error
        }
        else
        {
            // a non-Error, non-ErrorEvent type was thrown and uncaught
        }
    }
}
}