View Building Your First Application
1: create a new Flash file (actionScript3)
2: click on the canvas, the properties for the file should not be available.
3:click on the size button.
4: change that to 1024 x 768 and 30+ FPS
5: click settings (below size button)
6: Where it says actionScrtip version, make sure ActionScript is selected and click settings
7: in classpath at the bottom, click on the + button and enter
../ext
do the same for
../int
8: save this flash file in (the touchlib folder) AS3/src (name it what you want) EG touch.fla
9: in the AS3/int/app/demo folder, create a new folder called MyTouchApp (must be exact)
10: create a new ActionScript file.
11: save it as MyTouchApp.as in AS3/int/app/demo/MyTouchApp (that folder you just made)
12: go back to (click on the tab for) you flash file EG. touch.fla
13: In the Document Class text field enter app.demo.MyTouchApp.MyTouchApp
14: select the rectangle button and make a rectangle that is over, and larger than your canvas. This will be the area your program will run on.
15: right click (control click on a mac) on the black rectangle you just made and select “Convert To Symbol”
16: make sure movieclip is selected and press ok.
17: Save file… go back to MyTouchApp.as
18: copy code from examples and paste it in this file. MAKE SURE THE PAGE IS CLEARED FIRST
19: save this file again, go back to (click on the tab for) you flash file EG. touch.fla
20: publish the file. It should work now
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
==Code Examples==
package app.demo.MyTouchApp{ //adds a circle where you touch (no resize)
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.geom.*;
public class MyTouchApp extends Sprite {
public function MyTouchApp() {
//--------connect to TUIO-----------------
TUIO.init(this,'localhost',3000,'',true);
trace("MyTouchApp Initialized");
//----------------------------------------
addEventListener(TouchEvent.MOUSE_DOWN, touchDown); //run touchdown, when touched
}
public function touchDown(e:TouchEvent):void{
var curPt:Point = parent.globalToLocal(new Point(e.stageX, e.stageY)); //convert touch points to x,y
var circle:Sprite = new Sprite(); //create a new sprite
circle.graphics.lineStyle(10, 0xff0000); //set line width to 10px and red
circle.graphics.drawCircle(0,0,40); // draw a 40px circle
circle.x = curPt.x; //put it where touch is (x cord)
circle.y = curPt.y; //put it where touch is (y cord)
addChild(circle); //add the circle where touch happened
}
}
}
package app.demo.MyTouchApp{
import flash.display.*;
import flash.events.*;
import app.core.action.RotatableScalable;
public class MyTouchApp extends RotatableScalable {
public function MyTouchApp() {
//--------connect to TUIO-----------------
TUIO.init(this,'localhost',3000,'',true);
trace("MyTouchApp Initialized");
//----------------------------------------
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); // adds an event listener looking for a mouse click - runs "onMouseDown"
}
private function onMouseDown(event:MouseEvent):void { //creats a circle when the mouse is clicked
var circle:Sprite = new Sprite();
circle.graphics.lineStyle(10, 0xff0000); //set line width to 10px and red
circle.graphics.drawCircle(0,0,40); // draw a 40px circle
circle.x = mouseX; //put it where the mouse clicked
circle.y = mouseY;
addChild(circle); //add the circle to the plane
}
}
}