-
Client Software Programmer
Multi Touch
Hi, i have a grid array of buttons, but when i add multitouch zoom code to it which is found at the end of the script, only the last button in the array zooms in and out, any idea how to get it all into some sort of container in as3 and just be able to zoom the whole thing. Thanks
PHP Code:
import flash.events.MouseEvent;
var rows:int = 40;
var cols:int = 50;
for (var py:int = 0; py <rows; py++)
{
for (var px:int = 0; px <cols; px++)
{
var grid:Grid = new Grid();
grid.x = 200 + grid.width * px;
grid.y = 50 + grid.height * py;
grid.addEventListener(MouseEvent.ROLL_OVER,doFunction);
addChild(grid);
}
}
function doFunction(e:MouseEvent):void
{
trace(e.currentTarget);
trace(MovieClip(root).color_black.currentFrame);
if (MovieClip(root).color_black.currentFrame == 2)
{
e.currentTarget.gotoAndStop(1);
}
if (MovieClip(root).color_grey.currentFrame == 2)
{
e.currentTarget.gotoAndStop(2);
}
if (MovieClip(root).color_white.currentFrame == 2)
{
e.currentTarget.gotoAndStop(3);
}
if (MovieClip(root).color_yellow.currentFrame == 2)
{
e.currentTarget.gotoAndStop(4);
}
if (MovieClip(root).color_green.currentFrame == 2)
{
e.currentTarget.gotoAndStop(5);
}
if (MovieClip(root).color_blue.currentFrame == 2)
{
e.currentTarget.gotoAndStop(6);
}
if (MovieClip(root).color_brown.currentFrame == 2)
{
e.currentTarget.gotoAndStop(7);
}
if (MovieClip(root).color_red.currentFrame == 2)
{
e.currentTarget.gotoAndStop(8);
}
}
color_black.addEventListener(MouseEvent.CLICK, go);
function go(event:MouseEvent): void {
color_black.gotoAndStop(2);
color_grey.gotoAndStop(1);
color_white.gotoAndStop(1);
color_yellow.gotoAndStop(1);
color_green.gotoAndStop(1);
color_blue.gotoAndStop(1);
color_brown.gotoAndStop(1);
color_red.gotoAndStop(1);
}
color_grey.addEventListener(MouseEvent.CLICK, go2);
function go2(event:MouseEvent): void {
color_black.gotoAndStop(1);
color_grey.gotoAndStop(2);
color_white.gotoAndStop(1);
color_yellow.gotoAndStop(1);
color_green.gotoAndStop(1);
color_blue.gotoAndStop(1);
color_brown.gotoAndStop(1);
color_red.gotoAndStop(1);
}
color_white.addEventListener(MouseEvent.CLICK, go3);
function go3(event:MouseEvent): void {
color_black.gotoAndStop(1);
color_grey.gotoAndStop(1);
color_white.gotoAndStop(2);
color_yellow.gotoAndStop(1);
color_green.gotoAndStop(1);
color_blue.gotoAndStop(1);
color_brown.gotoAndStop(1);
color_red.gotoAndStop(1);
}
color_yellow.addEventListener(MouseEvent.CLICK, go4);
function go4(event:MouseEvent): void {
color_black.gotoAndStop(1);
color_grey.gotoAndStop(1);
color_white.gotoAndStop(1);
color_yellow.gotoAndStop(2);
color_green.gotoAndStop(1);
color_blue.gotoAndStop(1);
color_brown.gotoAndStop(1);
color_red.gotoAndStop(1);
}
color_green.addEventListener(MouseEvent.CLICK, go5);
function go5(event:MouseEvent): void {
color_black.gotoAndStop(1);
color_grey.gotoAndStop(1);
color_white.gotoAndStop(1);
color_yellow.gotoAndStop(1);
color_green.gotoAndStop(2);
color_blue.gotoAndStop(1);
color_brown.gotoAndStop(1);
color_red.gotoAndStop(1);
}
color_blue.addEventListener(MouseEvent.CLICK, go6);
function go6(event:MouseEvent): void {
color_black.gotoAndStop(1);
color_grey.gotoAndStop(1);
color_white.gotoAndStop(1);
color_yellow.gotoAndStop(1);
color_green.gotoAndStop(1);
color_blue.gotoAndStop(2);
color_brown.gotoAndStop(1);
color_red.gotoAndStop(1);;
}
color_brown.addEventListener(MouseEvent.CLICK, go7);
function go7(event:MouseEvent): void {
color_black.gotoAndStop(1);
color_grey.gotoAndStop(1);
color_white.gotoAndStop(1);
color_yellow.gotoAndStop(1);
color_green.gotoAndStop(1);
color_blue.gotoAndStop(1);
color_brown.gotoAndStop(2);
color_red.gotoAndStop(1);
}
color_red.addEventListener(MouseEvent.CLICK, go8);
function go8(event:MouseEvent): void {
color_black.gotoAndStop(1);
color_grey.gotoAndStop(1);
color_white.gotoAndStop(1);
color_yellow.gotoAndStop(1);
color_green.gotoAndStop(1);
color_blue.gotoAndStop(1);
color_brown.gotoAndStop(1);
color_red.gotoAndStop(2);
}
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
function onZoom (e:TransformGestureEvent):void{
grid.scaleX *= (e.scaleX+e.scaleY)/2;
grid.scaleY *= (e.scaleX+e.scaleY)/2;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|