【问题标题】:FileReferenceList doesn't fire eventsFileReferenceList 不会触发事件
【发布时间】:2014-08-17 19:46:36
【问题描述】:

SELECT 和 CANCEL 事件不会被触发,我在一个新项目中这样做是为了确保问题不是来自我的代码的另一部分。

在使用 FileReferenceList.Browsing 对话框选择文件后单击“打开”时,输出中永远不会出现“事件触发”。我也尝试了 FileReference,但它没有用。其他元素的其他事件有效(如 addedToStage、Click、touch 等)。我正在使用 Air 14 和 Flex 4.6.0 在 FlashDevelop 上使用 Air AS3 Projector 项目。

这是 Main.as :

public class Main extends Sprite 
{
    public function Main():void 
    {
        var asd:FileReferenceList = new FileReferenceList();
        asd.addEventListener(Event.SELECT, traceResult);
        asd.browse();

        trace("FileReferenceList is browsing...");
    }

    public function traceResult(e:Event):void
    {
        trace("Event Fired");
    }
}

application.mxml:

<?xml version="1.0" encoding="utf-8" ?> 
<application xmlns="http://ns.adobe.com/air/application/14.0">

<id>FileReferenceListTest</id> 
<versionNumber>1.0</versionNumber> 
<filename>FileReferenceListTest</filename> 

<name>FileReferenceListTest</name> 
<description></description> 
<copyright></copyright> 

<initialWindow> 
    <title>FileReferenceListTest</title> 
    <content>FileReferenceListTest.swf</content> 
    <systemChrome>standard</systemChrome> 
    <transparent>false</transparent> 
    <visible>true</visible> 
    <minimizable>true</minimizable> 
    <maximizable>true</maximizable> 
    <resizable>true</resizable> 
</initialWindow> 

</application>

在 SetupSDK.bat 中,我使用的 SDK 是: FlashDevelop\Apps\flexairsdk\4.6.0+14.0.0

功能版本是:WIN 14,0,0,176(在另一个类似这样的问题中提出)。我是 Flash 新手,所以如果您的答案包含编译器更改或不容易找到(或检查)的内容,请准确说明如何操作。谢谢你的时间:)。

【问题讨论】:

    标签: actionscript-3 apache-flex events air filereferencelist


    【解决方案1】:

    您的上述代码正在运行。请检查其他内容。我觉得还有一个问题

    【讨论】:

    • 在一个新项目中重新解决了我的问题。
    【解决方案2】:

    仔细阅读 actionScript® 3.0 参考后,我看到了这个:

    注意:在 Adob​​e AIR 中,扩展 FileReference 的 File 类 类,提供更多功能并且具有更少的安全限制 比 FileReference 类。

    所以这里是好的代码:

    public class Main extends Sprite 
    {
        public function Main():void 
        {
            var f:File = new File();
            f.addEventListener("selectMultiple", traceResult);
            f.browseForOpenMultiple("Browse...");
    
            trace("FileReferenceList is browsing...");
        }
    
        public function traceResult(e:Event):void
        {
            trace("Event Fired");
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-18
      • 2015-06-25
      • 2014-11-30
      • 2012-06-12
      • 1970-01-01
      • 2014-09-13
      • 1970-01-01
      相关资源
      最近更新 更多