• Keep in touch:
  • Linked In
  • Twitter
  • RSS

How do I make something bigger or smaller?

The size of an object is changed using a coordinate transform. The most common way is to specify the transform when you add an object to the display list. This means that the size can be changed without changing the definition of the object.

transform = CoordTransform.(x, y, scaleX, scaleY);

movie.add(new Place(rectangle.getIdentifier(), 2, transform));

You can animate size changes by repeatedly applying a transform over a number of frames. Note that the transforms applied to an object are not cumulative instead you have to track the changes in size and create separate transforms.

double scaleX = 1.0;
double scaleY = 1.0;
double shearX = 0.0;
double shearY = 0.0;

for (int i=0; i<10; i++)  {
    scaleX *= 1.1;
    scaleY *= 1.1;

    transform = new CoordTransform(scaleX, scaleY, 
        shearX, shearY, x, y);

    movie.add(new Place2().setType(PlaceType.MODIFY).setLayer(1)

There several other situations where coordinate transforms are applied to objects:

  • Setting the size and more importantly the orientation of text objects.
  • Setting the size and orientation of each shape used to create a button.
  • Setting the scale of images so they are displayed at the correct size.
  • Selecting the scale and position of the Gradient Square when creating gradient colours.

In each case the coordinate transform used to define an object is separate from the one used to position it on the screen.