Attentions need to be paid to:
- Click here to download Flash Player 11.2 and playerglobal.swc file
- 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)
- SDK 4.5 or the edition above is suggested. (The edition below SDK4.0 is not compatible with Flash Player 11.)
- Set the edition of Flash Player in the project options as 11.2.
- Add the option -swf-version=15 in the project options.
<?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