2011-06-23 36 views
0

我編寫了一個flex應用程序。我在上下文菜單中添加了一些自定義菜單項。當我使用flashplayer 10.0編譯此代碼時,它工作正常,並且當我單擊右鍵時顯示​​添加的上下文菜單項。但是,當我爲flashPlayer 10.1編譯相同的代碼時,我在右鍵單擊時不會顯示在上下文菜單中添加的菜單項。我該怎麼做才能解決這個問題? 我使用sdk 3.5。上下文菜單在flash player 10.1中不起作用

任何幫助或建議,將不勝感激。

我正在這樣做;

private var cm:ContextMenu = new ContextMenu();   
    var versionMenu:ContextMenuItem = null; 
    var dateMenu:ContextMenuItem = null; 
    if(model.appVersion.length > 0) 
    { 
     versionMenu = new ContextMenuItem(model.appVersion); 
    } 
    if(model.releaseDate.length > 0) 
    { 
     dateMenu = new ContextMenuItem(model.releaseDate); 
    } 

    cm.hideBuiltInItems(); 
    var cmArray:Array = new Array(); 
    if(versionMenu != null) 
     cmArray.push(versionMenu); 
    if(dateMenu != null) 
     cmArray.push(dateMenu); 
    cm.customItems = cmArray; 

謝謝。

+0

你上的Flash Player使用AIR?在AIR上下文菜單項中不能重用。 –

+0

它的一個靈活的應用程序。當我使用Flash Player 10.0時它工作正常,但在使用Flash Player 10.1時它不起作用。 –

回答

1

沒有理由。它在flashPlayer 10.1中適用於我。它也被列爲10.1支持在這裏:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/ContextMenu.html

警告代碼中的isSupported屬性進行仔細檢查(它肯定是真的)。

+0

我加了我的代碼。你能檢查一下嗎? –

+0

我敢打賭,如果你在versionMenu = new ContextMenuItem(model.appVersion);dateMenu = new ContextMenuItem(model.releaseDate);上放置斷點,它們將不會被擊中。刪除if語句並直接設置它們。 – basarat

+0

@ Basarat Ali:我在兩個ifs中都放置了警報。他們被擊中並顯示警報。但contextMenu中的條目未顯示。 –

1

如果你想創建一個上下文菜單Application那麼這裏是正確的代碼:

<s:Application ... initialize="init();"> 

    private function init():void 
    { 
     var versionItem:ContextMenuItem = new ContextMenuItem("Version 1.5.443"); 
     contextMenu.hideBuiltInItems(); 
     contextMenu.customItems = [ versionItem ]; 
    } 

</s:Application> 
相關問題