Friday, March 26, 2010

Please help for Registration point to a...

I am new to AS3 and have a doubt on Registration point for
Movie clip / Sprite. Please help me the sample code for this



I simply draw a line using AS3 in flash environment. but i
used graphics.moveTo for center. but if i run this it is simply
taking x,y axis 0,0 and move around the stage. I want to move this
from center of the stage. please help.



below is my code



var line:Sprite = new Sprite()

addChild(line);



var cx:Number = stage.stageWidth/2;

var cy:Number = stage.stageHeight/2;



var radius:Number = 1;

var increase:Number = 0;



line.graphics.lineStyle(1, 0xff00ff);



line.addEventListener(Event.ENTER_FRAME, onEnter);



function onEnter(event:Event):void

{

increase += radius;



//trace(increase);

//line.graphics.moveTo(cx, cy);

line.graphics.lineTo(cx + increase, cy + increase);

line.rotation += 0.1;

}

Please help for Registration point to a...
to appear to control the registration point of line, make it
a child or an empty display object and offset it by -x,-y where x,y
is your choice for the apparent registration point. you can then
control the parent object and it will behave like your line with
changed registration point.Please help for Registration point to a...
Thank you very much :)
you're welcome.

No comments:

Post a Comment