2012/09/28

Popup Menu Realized by the New Functions in Flash Player 11.2

In Flash Player 11.2, a significant function has been added: the Popup Menu. Please refer to Flash Player 11.2 Beta Features for details.  The following image is the effect in the Network in TWaver Flex which means that it is unnecessary to screen out the Popup Menu through the js script of html, which method no longer takes effect after the content in flash is full-screening. Because after that, flash is out of the browser and it is of little help to listen to the right button in the browser.
Attentions need to be paid to:
  1. Click here to download Flash Player 11.2 and playerglobal.swc file
  2. Change the name of the downloaded file flashplayer11-2_p3_playerglobal_122011.swc to playerglobal.swc and put it into the corresponding catalogue of SDK(Adobe Flash Builder 4.5/sdks/4.5.1/frameworks/libs/player/11.2)
  3. SDK 4.5 or the edition above is suggested. (The edition below SDK4.0 is not compatible with Flash Player 11.)
  4. Set the edition of Flash Player in the project options as 11.2.
  5. Add the option -swf-version=15 in the project options.
The code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:twaver="http://www.servasoftware.com/2009/twaver/flex"
               applicationComplete="init()">
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.Menu;

            import twaver.*;

            private function init():void {
                var box:ElementBox = new ElementBox();

                var from:Node = new Node();
                from.name = "From";
                from.location = new Point(100, 100);
                box.add(from);

                var to:Node = new Node();
                to.name = "To";
                to.location = new Point(300, 300);
                box.add(to);

                var link:Link = new Link(from, to);
                link.name = "From - To";
                box.add(link);

                network.elementBox = box;
                network.addEventListener('rightClick', handleRighClick);
            }

            private var menu:Menu = null;

            private function handleRighClick(e:MouseEvent):void {
                var element:IElement = network.getElementByMouseEvent(e);
                var myMenuData:ArrayCollection = new ArrayCollection([
                    {label: element == null ? "none" : element.name}
                ]);
                if(menu != null){
                    menu.hide();
                }
                menu = Menu.createMenu(network, myMenuData, false);
                var point:Point = network.globalToLocal(new Point(e.stageX, e.stageY));
                menu.show(point.x, point.y);
            }
        ]]>
    </fx:Script>

    <twaver:Network id="network" width="100%" height="100%" backgroundAlpha="0" backgroundColor="#FF0000"/>
</s:Application>
 

No comments:

Post a Comment