Posted on 2012-01-11 16:58
TWaver 阅读(3083)
评论(5) 编辑 收藏
需要注意几点:
1. 从
这里下载Flash Player 11.2以及
playerglobal.swc文件
2. 将下载的flashplayer11-2_p3_playerglobal_122011.swc文件改名为playerglobal.swc,并放入SDK的相应目录中(Adobe Flash Builder 4.5/sdks/4.5.1/frameworks/libs/player/11.2):
3. 最好使用SDK 4.5或以上版本的SDK(SDK4.0之前不支持Flash Player 11)
4. 工程选项里Flash Player版本,需要设置为11.2
5. 工程选项里添加 -swf-version=15 编译选项
代码如下:
1 <?xml version="1.0" encoding="utf-8"?>
2 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
3 xmlns:s="library://ns.adobe.com/flex/spark"
4 xmlns:mx="library://ns.adobe.com/flex/mx"
5 xmlns:twaver="http://www.servasoftware.com/2009/twaver/flex"
6 applicationComplete="init()">
7 <fx:Script>
8 <![CDATA[
9 import mx.collections.ArrayCollection;
10 import mx.controls.Menu;
11
12 import twaver.*;
13
14 private function init():void {
15 var box:ElementBox = new ElementBox();
16
17 var from:Node = new Node();
18 from.name = "From";
19 from.location = new Point(100, 100);
20 box.add(from);
21
22 var to:Node = new Node();
23 to.name = "To";
24 to.location = new Point(300, 300);
25 box.add(to);
26
27 var link:Link = new Link(from, to);
28 link.name = "From - To";
29 box.add(link);
30
31 network.elementBox = box;
32 network.addEventListener('rightClick', handleRighClick);
33 }
34
35 private var menu:Menu = null;
36
37 private function handleRighClick(e:MouseEvent):void {
38 var element:IElement = network.getElementByMouseEvent(e);
39 var myMenuData:ArrayCollection = new ArrayCollection([
40 {label: element == null ? "none" : element.name}
41 ]);
42 if(menu != null){
43 menu.hide();
44 }
45 menu = Menu.createMenu(network, myMenuData, false);
46 var point:Point = network.globalToLocal(new Point(e.stageX, e.stageY));
47 menu.show(point.x, point.y);
48 }
49 ]]>
50 </fx:Script>
51
52 <twaver:Network id="network" width="100%" height="100%" backgroundAlpha="0" backgroundColor="#FF0000"/>
53 </s:Application>