Home > Flex, code > wmode – one little attribute makes all the difference

wmode – one little attribute makes all the difference

At my work, the business wanted a right click menu that did not have all of the default “Flash” items in it. Now, you can edit the context menu so that it hides *most* of the Flash options, but not all of them. I found a right click someone wrote that uses Javascript to intercept the right click event from the mouse before it propagates to the Flash swf. I created a right click class (I may show that class at some point) that handles the resulting event that Javascript passes and generates the menu options to the user. However, for some reason (although I was using what I thought was identical code to another page a co-worker wrote), I wasn’t able to get the right click to work. It kept showing the regular context menu. After puzzling over the code for about an hour, I then went digging through the html page. After comparing the code for a few minutes, I came across the “wmode=’transparent’” attribute added to the swf creation. “Of course”, I said to myself. The right click was not able to be intercepted by the page before it got to the swf, as the right click was always hitting the swf first. By setting the wmode to transparent (I’m guessing here slightly), gets caught by the page, rather than the swf. The Javascript can then fire off a callback event to the Flex/Flash swf, which then makes everything work great. Such a simple little attribute that is so vitally important.

  1. JasonMask
    February 12th, 2009 at 11:31 | #1

    hi gareth

    afaik wmode=”transparent” causes flashplayer to render all stuff and pass it to the browser to display it. leaving this set to normal lets flashplayer run “independetly” on top of the browser and pass the output to the os directly. also the have always been 3 wmodes. the third should be opaque which is similar to transparent with the difference that opaque dosnt force the browser to mashup the output with any underlying items from the html page. so wmode=”transparent” should only be used is you want things to be displayed behind your flash file.

    btw. somewhen in the passed (i think flash 6 or 7 or before) transparent and opaque caused some script errors we never where able to localize, so it should only be used if you realy need it…

    grz jason

  2. Gareth
    February 19th, 2009 at 22:04 | #2

    Hey Jason,
    That makes sense. I just got annoyed that I spent a couple of hours trying to figure out what was wrong, only to see that it was because I hadn’t added this attribute to my code :) I’ve had the same issue in the past, but forgot about it. Hopefully by noting it, I’ll actually be able to retain this in memory a bit. Thanks for reading.

  1. No trackbacks yet.