
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
ImageViewer Implementation (Take 2)
|
145
Using ImageViewer (Take 2)
Now that our ImageViewer class can crop an image and add a border to it, let’s put
ourselves in the position of a developer who’s using the class (not creating and main-
taining it). When we used the first version of the ImageViewer class, we placed the
following code on frame 15 of imageViewer.fla:
var viewer:ImageViewer = new ImageViewer(this, 1);
viewer.loadImage("picture.jpg");
ImageViewer version 2 added two new features comprising quite a lot of code. How-
ever, none of the public API defined by ImageViewer version 1 changed in version 2;
version 2 made additions only to that API. The loadImage( ) method changed inter-
nally, but its external usage did not change at all. Likewise, the constructor function
changed internally, but externally it only added parameters. It retains the
target and
depth parameters from version 1 and adds six new parameters: x, y, w, h,
borderThickness, and borderColor. Hence, users of ImageViewer version 1 can easily
update imageViewer.fla to use ImageViewer version 2’s new features, as follows:
1. Replace the old ImageViewer.as file with the new one.
2. Change the code on frame 15 of imageViewer.fla to include the six new parame-
ters expected by the ImageViewer constructor. For example: ...