Hi,
I want to write (not use other peoples classes) some AS so that when a user clicks on an MC, they can rotate and resize the MC... any ideas where I can get started? Or how I can do this?
Thanks
Printable View
Hi,
I want to write (not use other peoples classes) some AS so that when a user clicks on an MC, they can rotate and resize the MC... any ideas where I can get started? Or how I can do this?
Thanks
if you did not know "you can make an object rotate and resize without classes".
I'm pretty sure this is close to what you are looking for.
first you will have to create an event listener for your_mc
then you have to create a functionCode:your_mc.addEventListener(MouseEvent.MOUSE_DOWN,yourFunctionName);
Code:function yourFunctionName (evt:MouseEvent):void {
your_mc.width = -50;
your_mc.rotation = +15;
}
here's a very basic demo on resizing with mouse events. you can use the same approach for rotation.
PHP Code:function startresize(event:Event){
var wide:Number = box.width;
var tall:Number = box.height;
var xmouse:Number = stage.mouseX;
var ymouse:Number = stage.mouseY;
var executeresize:Function = function(event:Event){
var diffx:Number = stage.mouseX - xmouse;
var diffy:Number = stage.mouseY - ymouse;
box.width = wide + diffx;
box.height = tall + diffy;
};
var endresize:Function = function(event:Event){
stage.removeEventListener("mouseMove",executeresize);
stage.removeEventListener("mouseUp",endresize);
}
stage.addEventListener("mouseMove",executeresize);
stage.addEventListener("mouseUp",endresize);
};
var box:Sprite = new Sprite();
box.x = stage.stageWidth/2 - 50;
box.y = stage.stageHeight/2 - 50;
box.graphics.beginFill(0xff9900);
box.graphics.drawRect(0,0,100,100);
this.addChild(box);
box.addEventListener("mouseDown",startresize);