Graphics Reference
In-Depth Information
thumbnail is both determined and stored. The first part is
the x value of the location, and it is realized by multiplying the
column number with the width of the thumbnail and then adding
that product to the product of the column multiplied with _padding .
It looks like this:
(column * _loadedImage.width) + (column * _padding)
re in column 3, the width of your thumbnail is
120 pixels and the padding between your images is 10 pixels. The
x position of that particular thumbnail would be 390: (3 * 120) +
(3 * 10) = 390.
That total is not only used to place the image in the correct
x position but also used to change the x property of the correspond-
ing Point in _pointVector and will be called on later when the user
is interacting with the image. The same thing is then done for the y
position of the thumbnail and y property of the Point but with the
row and thumbnail height. Once we have the position worked out,
it
So let
'
ssayyou
'
s time to place the image on the stage and set _loadedImage back
to null to clear up any memory that was associated with it. Finally,
we
'
re going to increment _numberLoaded and test to see if it matches
_numberOfImages . If it does, then all images are loaded, resized to
their thumbnail sizes, and placed on the stage. With all of them in
place, we can get the width and height of our gallery, and therefore,
we can assign values to _halfWidth and _halfHeight (which we
'
'
ll
use in the imageClicked method).
private function placeImage(e:Event):void {
e.target.removeEventListener(Event.COMPLETE,
placeImage);
e.target.removeEventListener(IOErrorEvent.IO_ERROR,
imageLoadError);
_loadedImage = e.target.loader;
var pIndex:int = pointIndex(_loadedImage);
var column:int = _pointVector[pIndex].x;
var row:int = _pointVector[pIndex].y;
_loadedImage.scaleX = _loadedImage.scaleY =
_thumbScale;
_loadedImage.x = _pointVector[pIndex].x = (column *
_loadedImage.width) + (column * _padding);
_loadedImage.y = _pointVector[pIndex].y = (row *
_loadedImage.height) + (row * _padding);
addChild(_loadedImage);
_loadedImage = null;
_numberLoaded++;
if(_numberLoaded == _numberOfImages){
Search WWH ::




Custom Search