簡體   English   中英

FileReferenceList不會觸發事件

[英]FileReferenceList doesn't fire events

SELECT和CANCEL事件沒有觸發,我在一個新項目中這樣做,以確保問題不出自我代碼的另一部分。

使用FileReferenceList.Browsing對話框選擇文件后,單擊“打開”時,“事件觸發”永遠不會出現在輸出中。 我也嘗試了FileReference,但是它沒有用。 其他元素的其他事件也可以工作(例如,addedToStage,Click,touch等)。 我在Flash開發中使用Air 14和Flex 4.6.0的Air AS3投影儀項目。

這是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.0參考》后,我看到了以下內容:

注意:在Adobe 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");
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM