I have a sample code from another person which shows how to use a movie clip and duplicate it for a multi touch computer. The problem is that I want to be able to use my own images from an XML file or even put them into a flash library and change the fla as I need to. I tried every option I can think of but I am not sure what I am doing wrong. I tried adding a loader which would load the image but when I touched the screen it gave me an error that it couldn’t translate a loader to a sprite.
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.Sprite;
import flash.events.MouseEvent;
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var con:Sprite = new Sprite();
con.x = stage.stageWidth * 0.5;
con.y = stage.stageHeight * 0.5;
addChild(con);
for(var i:uint=0; i<20; ++i)
{
var b:Sprite = Sprite(new box());
b.x = Math.random() * stage.stageWidth - (stage.stageWidth * 0.5);
b.y = Math.random() * stage.stageHeight - (stage.stageHeight * 0.5);
b.rotation = Math.random() * 360;
b.addEventListener(MouseEvent.MOUSE_UP, onUP);
b.addEventListener(MouseEvent.MOUSE_DOWN, onDOWN);
b.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);
b.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onRotate);
con.addChild(b)
}
function onDOWN(e:MouseEvent): void
{
var b:Sprite = Sprite(e.currentTarget);
con.addChild(b);
b.startDrag();
}
function onUP(e:MouseEvent): void
{
var b:Sprite = Sprite(e.currentTarget);
con.addChild(b);
b.stopDrag();
}
function onZoom(e:TransformGestureEvent): void
{
e.stopImmediatePropagation();
var b:Sprite = Sprite(e.currentTarget);
b.scaleX *= e.scaleX;
b.scaleY = e.scaleY;
}
function onRotate(e:TransformGestureEvent): void
{
e.stopImmediatePropagation();
var b:Sprite = Sprite(e.currentTarget);
b.rotation += e.rotation;
}
function StageZoom(e:TransformGestureEvent): void
{
con.scaleX *= e.scaleX;
con.scaleY *= e.scaleY;
}
function StageRotate(e:TransformGestureEvent): void
{
con.rotation +=e.rotation
}