Resizing a circle that's part of a class (and actually a circle within a circle)

I have a ‘ball’ class that defines a set of on-screen circles, one within the other (a ‘ball’ with a black outline below it).

I’d like to be able to resize both of these circles within my main code (using an event listener that updates every frame). Unfortunately I can’t see how to do this in the function that handles the update event.

Here’s the code for my ball class:

import openfl.display.Sprite;

class Ball extends Sprite
	public var z : Float;
	public var Xvel : Float;
	public var Yvel : Float;
	public var Zvel : Float;
	public function new() 
		graphics.drawCircle(4, 4, 5);
		graphics.endFill();;, 4, 4);;
		this.z = 0.0;
		this.Xvel = 0.0;
		this.Yvel = 0.0;
		this.Zvel = 0.0;

The ball is added to the display in the init function. I’d like to then update it’s appearance in a function that runs every frame:

private function everyFrame(event:Event):Void {

if (ball.z > 100){
	//determine apparent size of ball
	var apparent = 8 * (ball.z / 100);

My hope is to use the variable ‘apparent’ to set the size of the ball to be displayed.

My question is therefore in two parts;

  1. Is it possible to set both circles that comprise the ball to be updated with a single call, or do I need to update both parts separately?
  2. Can I update the size of the ball here, or do I need to remove (removeChild) it, resize it, then redraw (addChild) it each frame?

Hi Bobby, not sure if I really got what you want to achieve, but why don´t you just scale the ball, then the graphics inside the ball also scale with it:

if (ball.z > 100){
	//determine apparent size of ball
	var apparent = 8 * (ball.z / 100);
        ball.scaleX = ball.scaleY = apparent;

One more thing,

On native targets, the graphics will not redraw if you zoom in on one of your circles. It tries to draw once and use the cached software graphic to prevent repeated software renders.

In order to avoid blurry edges, you may want to (sometimes) graphics.clear and graphics.drawCircle at a larger size, or perhaps draw at a larger size to begin with, and scale down when it is farther away