我有一個空氣應用程序,其中用戶在textarea中鍵入javascript,並且它在mx:HTML組件中被評估,但即使使用圍繞eval的try/catch,圍繞eval中的代碼和HTMLUncaughtScriptExceptionEvent處理程序,它仍會引發錯誤。 htmlWindow是html.htmlLoader.window。eval與try/catch的投擲錯誤
try { htmlWindow.eval("try {" + script.text + "} catch (error:Error) { trace(error) }); } catch (error:Error) { trace(error) }
,只要我在script
輸入文本在該行的應用程序錯誤,與
ReferenceError: Can't find variable: d
at Main/reloadHTML()[C:\Users\Christian\Adobe Flash Builder 4.5\JavaScript plus Scratch\src\Main.mxml:264]
at Main/__script_change()[C:\Users\Christian\Adobe Flash Builder 4.5\JavaScript plus Scratch\src\Main.mxml:324]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at spark.components.supportClasses::SkinnableTextBase/textDisplay_changeHandler()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableTextBase.as:2265]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at spark.components::RichEditableText/textContainerManager_flowOperationCompleteHandler()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\RichEditableText.as:4808]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flashx.textLayout.container::TextContainerManager/dispatchEvent()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\TextContainerManager.as:1553]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flashx.textLayout.elements::TextFlow/dispatchEvent()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\elements\TextFlow.as:859]
at flashx.textLayout.edit::EditManager/finalizeDo()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\edit\EditManager.as:669]
at flashx.textLayout.edit::EditManager/doOperation()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\edit\EditManager.as:613]
at flashx.textLayout.edit::EditManager/flushPendingOperations()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\edit\EditManager.as:873]
at flashx.textLayout.edit::SelectionManager/enterFrameHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\edit\SelectionManager.as:1859]`
任何方式來阻止錯誤?我試過script.change="html.htmlText = '<script>' + script.text + '</script'>"
,但我有htmlWindow.log = log; htmlWindow.rotateSprite = rotateSprite;
,如果我在修改之前複製粘貼log('test')
,它會起作用,如果我在之前或之後對其進行更改,它將無法再工作,所以我希望能夠獲得此評估工作。