近来在研究flash touchlib编程,和大家分享一下:
这是一个简单的多点触摸程序,实现对一个方块的缩放和旋转。
需要的软件:
1,Simulator,请到[url=http://mt2a.googlecode.com]这里[/url]下载
2,touchlib,请到[url=http://touchlib.googlecode.com]这里[/url]下载
好,准备完毕,开工:
1,打开Flash CS3,建立一个AS3文件,保存到 ..\touchlib\as3\int文件夹下,起名叫做 MTTest.fla。
2, 新建一个as3文件,起名为MTTest.as,同样保存到 ..\touchlib\as3\int文件夹下。
3,在as3文件里,输入下面的代码,建议你最好自己敲进去,不要直接复制。
4,在MTTest.fla文档类里输入MTTest, 注意大小写。
5,打开Flosc.rar, 并点击“Start”按钮,再打开Simulator.jar。
6,回答Flash CS3界面,Ctrl+Enter,发布Flash。这时,应该会看到一个绿色的方块。
7,回到Simulator界面,就可以缩放和移动那个绿色方块了。注意位置要对应好,要不点不到方块上。
package
{
import flash.display.Sprite;
import flash.events.TUIO;
import flash.events.Event;
import flash.events.TouchEvent;
import flash.display.Graphics;
import app.core.action.RotatableScalable;
public class MTTest extends Sprite
{
private var mc:RotatableScalable=new RotatableScalable();
public function MTTest():void
{
TUIO.init(this,"localhost",3000,'',true);
init();
}
private function init():void
{
mc.graphics.beginFill(0x99cc00);
mc.graphics.drawRect(-50,-50,100,100);
mc.graphics.endFill();
addChild(mc);
mc.x=200;
mc.y=200;
}
}
}
[img]http://www.mt2a.com/attachment.php?aid=103&k=7ede1d1ec367347cf8877e16e59006f3&t=1239180473&noupdate=yes&sid=c17auwk91C90%2FbirCKxNvGgRGkeX07rBmc9%2FWXIFjoAOCcI[/img]
更多信息,请访问[url=http://www.mt2a.com]mt2a多点触摸论坛[/url]