2011-09-14 51 views
0

我无法启动或捕获事件触发的结果。HTML控件的事件不会触发?

下面是当前的代码...

<s:Panel id="instructionsPanel" left="0" right="0" top="0" bottom="0" title="Register"> 
    <mx:HTML id="htmlViewer" left="10" right="10" top="0" bottom="10" 
      location="http://ramzsoft.com/software-optins/easyspinner.html"/> 
    <s:TextInput id="urlOutput" x="10" y="285" width="628" text="Not a test"/> 
</s:Panel> 

import flash.events.Event; 
import flash.filesystem.File; 
import flash.net.URLLoader; 
import flash.net.URLLoaderDataFormat; 
import flash.net.URLRequest; 

import mx.controls.Alert; 
import mx.managers.PopUpManager; 

import org.osmf.utils.URL; 

private var file:File = new File(); 
private const FIRST_RUN_TOKEN_FILE:File = 
    File.applicationStorageDirectory.resolvePath("firstrun"); 

init(); 

private function init():void { 
    htmlViewer.addEventListener(Event.LOCATION_CHANGE, onClosePanel); 
} 

private function onClosePanel(e:Event) { 
    urlOutput.text = "test"; 
    instructionsPanel.visible = false; 
} 

发生了什么事是,用户在HTML浏览器填写表单,然后当他们点击提交按钮,我想通知页改变的。

如果它们着陆在URL A上,那么它们将显示一条消息。如果他们着陆在网址B上,他们将被显示另一个。

但是,事件并未解雇。

我也试过COMPLETE和HTML_DOM_INITIALIZE。

任何想法,为什么这是行不通的?

+0

您使用的是哪个版本的Flex SDK? – Exort

+0

我正在使用2.6 SDK –

+0

好的,必须是AIR SDK版本,但实际上这正是我想知道的。我知道在AIR 2.7中为HmlLoader(特别是LOCATION_CHANGING)引入了一些事件,但我认为LOCATION_CHANGE应该可以工作。什么样的对象是htmlViewer? – Exort

回答

1

我不确定把init();在任何地方都没有任何影响。无论如何,你不需要那个init,你可以直接通过MXML来设置它。顺便说一句,我认为只有在点击链接(或重定向)时手动将位置设置为HTML组件,才会调度位置更改。

<s:Panel id="instructionsPanel" left="0" right="0" top="0" bottom="0" title="Register"> 
    <mx:HTML id="htmlViewer" left="10" right="10" top="0" bottom="10" 
      location="http://ramzsoft.com/software-optins/easyspinner.html" 
      locationChange="onClosePanel(event)"/> 
    <s:TextInput id="urlOutput" x="10" y="285" width="628" text="Not a test"/> 
</s:Panel> 
+0

谢谢。这现在完美了! –