The First and Only Magazine for Macromedia MX™
   
 
Notes from the Flash, Flex and ColdFusion trenches

Category List

Quick Poll

Where are you located?
North America
South America
Europe
Asia
Africa
Australia

My RSS Feeds








Hit Counter

Total: 1,305,972
since: 20 Jan 2005

Search Box

 

Search The Web

Google

MAX 2008

Fun Stuff

Mailing List

Got A Question?

Got A Question?

Leave a comment by the appropriate Entry, or email me

Tag Cloud

                                                                                                                       

Flash Player 9.0.28 bug - embeded images and ContextMenu

posted Thursday, 1 February 2007

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...


 


 

links: digg this    del.icio.us    technorati    reddit




1. Oscar left...
Tuesday, 22 May 2007 1:43 pm

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