I've run into an odd problem in a pong/brick-breaker game I'm making: one of the player's special abilities is to make a second ball split off from the main one and act exactly as the main one does for a short period before vanishing. The trouble is that when the second ball comes into contact with a stage boundary and is supposed to simply reverse its x or y velocity (depending on the boundary hit), it also apparently increases its width and height properties for some odd reason. The graphic doesn't change, but the values of width and height do (drastically) and this results in some stuckHandler methods I've defined for the odd situation where a ball ends up partially offstage getting called repeatedly. Nowhere in the code do I change width, height, or scaleX/scaleY properties, so I have no idea why this is happening. In reading the adobe documentation I found the following two points to be of potential interest regarding this matter--
Keyword THIS: A reference to a method's containing object. When a script executes, the 'this' keyword references the object that contains the script. Inside a method body, the 'this' keyword references the class instance that contains the called method. ---Isn't this two ways to say the same thing? I don't quite understand the particulars of the scope difference between 'this' at the start of a script and 'this' inside a method... Since the second ball object is created dynamically during play (the primary ball is a static object created pre-runtime and is controlled via a distinct driver class Ball) and is actually linked to a class Ball2 which controls and constructs it, the 'this' keyword is used a lot in different places throughout the class to reference thew graphic. I fear some confusion over the nuances surrounding 'this' in AS3 may be partly to blame for the odd circumstances I'm seeing.
Width/Height properties: Indicates the width/height of the display object, in pixels. The width/height is calculated based on the bounds of the content of the display object. When you set the width/height property, the scaleX/scaleY property is adjusted accordingly. ---What exactly do they mean by 'content of the display object'? Is that just the graphic or could it be something else under certain circumstances? Could the content change after a velocity reversal for some reason? Via debugging print statements, I found that at the point where the width and height expand the scaleX and scaleY properties remain at 1, indicating that Flash doesn't 'know' the object's size effectively changed...
I've attached the output log which shows a number of properties pertinent to the second ball's position, velocity, and size, and how they change over time. You can see that the width and height properties increase dramatically just after a velocity reversal, which indicates collision with a boundary. Also of note is that the second ball is created as a child of the main document class (which has no transformations applied to it, and is actually never added to the display list) and it seems to operate off of the proper stage-global coordinate system.