Flash Player 9.0.28 bug – embeded images and ContextMenu

In work for a particular client, we noticed an odd little bug with the latest Flash Player (9.0.28).  It seems that context menus (the items which appear when you right click) dont work when the right click is on an embeded image.  Take a look at this simple example:

main.mxml:

 <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns:v="*"
 layout="vertical">
 <v:DisplayIcon label="Embeded" useEmbeded="true" />
 <v:DisplayIcon label="Loaded" useEmbeded="false"/>
</mx:Application>

DisplayIcon.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
 creationComplete="buildContextMenu()" height="110" width="216">
 <mx:Image id="img" horizontalCenter="0"/>
 <mx:Label text="{label}"  horizontalCenter="0" bottom="0"/>
 <mx:Script>
  <![CDATA[
   import flash.ui.ContextMenu;
   import flash.ui.ContextMenuItem;
   [Embed(source="TapperNimer_logo.png")]
   public const yellowBevelPerson:Class;
   [Bindable]
   public var textStr:String;
   public var useEmbeded:Boolean
   public function doEmbed():void{
    if(useEmbeded){
     img.source = yellowBevelPerson;
    } else {
     img.source = "TapperNimer_logo.png";
    }
   }
   protected function buildContextMenu():void{
    var myContextMenu:ContextMenu = new ContextMenu();
    myContextMenu.hideBuiltInItems();
    var items:Array = new Array();
    var item:ContextMenuItem = new ContextMenuItem("Display Text");
    items.push(item);
    myContextMenu.customItems = items;
    this.contextMenu = myContextMenu;
    doEmbed();
    
   }
  ]]>
 </mx:Script>
</mx:Canvas>

As you can see, the DisplayIcon component has an image and a label, and based  on the value of the useEmbeded property, it will either embed the image, or load it dynamically at run time.  As you can see from these 2 screen shots, the problem arises when i right click on the top (embeded) image.  it shows the default context menu, rather than the custom one i have specified.

 
 

Fortunately, the work around is easy enough, if you set the mouseEnabled property of the image tag to false, it solves the problem

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
  creationComplete="buildContextMenu()" height="110" width="216">
 <mx:Image id="img" horizontalCenter="0" mouseEnabled="false" />
 <mx:Label text="{label}"  horizontalCenter="0" bottom="0"/>
 <mx:Script>
  <![CDATA[
   import flash.ui.ContextMenu;
   import flash.ui.ContextMenuItem;
   [Embed(source="TapperNimer_logo.png")]
   public const yellowBevelPerson:Class;
   [Bindable]
   public var textStr:String;
   public var useEmbeded:Boolean
   public function doEmbed():void{
    if(useEmbeded){
     img.source = yellowBevelPerson;
    } else {
     img.source = "TapperNimer_logo.png";
    }
   }
   protected function buildContextMenu():void{
    var myContextMenu:ContextMenu = new ContextMenu();
    myContextMenu.hideBuiltInItems();
    var items:Array = new Array();
    var item:ContextMenuItem = new ContextMenuItem("Display Text");
    items.push(item);
    myContextMenu.customItems = items;
    this.contextMenu = myContextMenu;
    doEmbed();
    
   }
  ]]>
 </mx:Script>
</mx:Canvas>
 
 

This bug has been filed and acknowleded by Adobe, so will hopefully be solved in the next release of the flash player…

 

 

1 Comment

    I ran into the same issue. However, I need to display a tooltip which stops working once you set the mouseEnabled to false.

    • by A visitor
    • 12:05 am, May 22, 2007
    • Reply

Leave a Reply