# Flash CS3 Actionscript 3 Scaling a circle

Once I draw the circle, I want to scale it larger or smaller.

the problem is, if I do the following

circle.height = grow;
circle.width = grow;

grow++;

the circle not only grows, it moves at an angle. I would like to scale it from the center, without it moving, just growing.

``````circle = new Sprite();
circle.graphics.beginFill(0xFFFFFF);
circle.graphics.drawCircle(450, 350, 50);
circle.graphics.endFill();

``````
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
keep registration point 0, in simple words center point of the circle in its movieClip should be 0, then it will scale at its position.
below is the updated code which should work fine..
``````var circle = new Sprite();
circle.graphics.beginFill(0xFFFFFF);
var circleWidth = 50;
circle.graphics.drawCircle(-circleWidth/2, -circleWidth/2, circleWidth);
circle.graphics.endFill();

// set x,y position of the circle once by updating following code
circle.x = 200;
circle.y = 200;
//now grow will increase it at its position
``````
Author Commented:
this is close to what I am looking for, except that the circle appears to grow upward and to the left as opposed to growing outward from the center.

is there a way to have it appear to grow from the center?

Author Commented:
the point from which it grows appears to be at the bottom right of the circle.
Commented:
I am sure on that using my code properly, circle will grow from center on all directions..

if it is not the case with you, then I suggest you to upload your SAMPLE FLA for review
Author Commented:
here is my full code for that section.

I have no idea why it grows from the bottom of the circle. when I make -circleWidth just circleWidth it grows from the top of the circle.

odd.

``````circle = new Sprite();
circle.graphics.beginFill(0xFFFFFF);
var circleWidth = 50;
circle.graphics.drawCircle(-circleWidth/2, -circleWidth/2, circleWidth);
circle.graphics.endFill();

if (cirState ==1){
cirSize=cirSize+2;
}else{
cirSize=cirSize-2;
}
if (cirSize > 80){
cirState = 2
}

if (cirSize < 10){
cirState = 1
}

circle.width = cirSize;
circle.height = cirSize;
``````
Commented:
provide code is not complete,

it does not tell where circle sprite has been added using  "addChild(circle)"
and it does not tell if x,y position of the circle or its parent has been changed or not.

I suggest to prepare a sample FLA with problem and attach here for quick solution
Author Commented:
you will have to add .as and .fla as I couldnt attach the zip file with the proper filenames.

circle-test.zip
Commented:
ok, got the fix

You just need to change the following line of code:
circle.graphics.drawCircle(-circleWidth/2, -circleWidth/2, circleWidth);

replace it with following:
circle.graphics.drawCircle(0, 0, circleWidth);

Experts Exchange Solution brought to you by