Compile Flash Builder Project Against a Different PlayerGlobal

I have always struggled with the limited right click functionality in Flash Player.  There are several Javascript workarounds for intercepting the click before Flash Player receives it, but depending on the wmode this might not work.  Using the out of the box context menu lets you add some basic menu items, but there are limits to the number of menu items and you always get the standard menu items at the bottom of the list.

So when Flash Player 11.2 was announced I was excited to read about the new functionality added for right and middle click events. See Flash Player 11.2 Release Announcement. I updated the Flash Player in my browser to 11.2 and then went to Flash Builder to try out the new right click functionality.  Unfortunately I ran into several problems and only after much trial and error and searching was I able to get it working.  I am using Flash Builder 4.7 with Flex SDK 4.6.23201.

Things I learned

  1. The Flex SDK has a minimum version of player version it will work with defined in the frameworks/flex-config.xml file of the SDK.
  2. The Flex SDK comes with at least one version of playerglobal.swc library which contains the class information for the version of Flash Player. The versions can be found in the frameworks/libs/player directory of the Flex SDK
  3. Each version of playerglobal.swc has a specific swf version that needs to be used when building your Flex swfs.
  4. Flash Builder can compile against any of the player version defined in the frameworks/libs/player directory of the Flex SDK
  5. The swf projects in Flash Builder need an additional compiler argument -swfVersion={XX} in order to compile correctly.

Steps to follow in order to get it working

  1. Get the PlayerGlobal.swc 
    1. Go to Adobe’s Archived Flash Player Versions Page 
    2. Find the PlayerGlobal.swc Archives section.
    3. Download the playerglobal.swc library for the version of Flash Player you want to compile against.  
  2. Install the PlayerGlobal into your SDK
    1. In your OS navigate to the frameworks/libs/player directory of the Flex SDK.
    2. Create a new directory with the name set to the version of Flash Player you are trying to compile against.
    3. Copy the downloaded playerglobal.swc file into the new directory.
    4. Rename the file playerglobal.swc.
  3. Update your Flash Builder Project to compile against the new Flash Player version
    1. Open up Flash Builder.
    2. Right click on the project you want compiling against the new version of Flash Player
    3. Select the Properties menu item from the context menu to show the Properties Window
    4. Click on the Flex Compiler item in the list
    5. In the Adobe Flash Player Options box select the Use a Specific Version radio button
    6. Enter in the version of the Flash Player you want to compile against.
    7. Look up the correct SWF version
      1. Go to Chart of Flash Player and SWF Versions. If the version you want to use is not here then you will need to do a web search for it
    8. In the Additional Compiler Arguments enter a new argument -swfVersion={version from above}
    9. Click the OK button to save the changes
    10. Close the project
    11. Reopen the project
    12. Select Project > Clean… from the menu bar and clean the project
At this point you should be all set to use the new Mouse Events.  


Here are some errors I received along the way
Error Message: unable to open ‘C:\dev\tools\adobe\sdks\4.6.0.23201\frameworks\libs\player\11.3\playerglobal.swc’ Unknown Flex problem
Reason: The Flex SDK didn’t contain the version I entered in the Adobe Flash Player Options specific version field of the project properties.

Error Message: TypeError: Error #2007: Parameter type must be non-null.
Reason: The swfVersion argument was missing from the additional compiler arguments of the project properties.

UPDATE:
Here are some details on deploying the playerglobal.swc to Maven for use by FlexMojos 4.

Run this command to install it in your local repository
mvn install:install-file -Dfile=playerglobal.swc -DgroupId=com.adobe.flex.framework -DartifactId=playerglobal -Dversion={FLEX_SDK_VERSION} -Dpackaging=swc -Dclassifier={FLASH_PLAYER_VERSION} 

Run this command to deploy it to your repository manager
mvn deploy:deploy-file -Durl={repositoryURL} -DrepositoryId={repositoryID} -Dfile=playerglobal.swc -DgroupId=com.adobe.flex.framework -DartifactId=playerglobal -Dversion={FLEX_SDK_VERSION} -Dpackaging=swc -Dclassifier={FLASH_PLAYER_VERSION}