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();
 
                addChild(circle);

Open in new window

lexshineAsked:
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.

Aneesh ChopraCommented:
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();
 
addChild(circle);
// 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

Open in new window

0
lexshineAuthor 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?

0
lexshineAuthor Commented:
the point from which it grows appears to be at the bottom right of the circle.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Aneesh ChopraCommented:
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
0
lexshineAuthor 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;

Open in new window

0
Aneesh ChopraCommented:
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
0
lexshineAuthor Commented:
you will have to add .as and .fla as I couldnt attach the zip file with the proper filenames.


circle-test.zip
0
Aneesh ChopraCommented:
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);
                  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lexshineAuthor Commented:
yep, that did the trick.. thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.