Graphics Reference
In-Depth Information
The last one I
m adding is an IOErrorEvent.IO_ERROR listener. This is
in place in case there
'
s a problem loading the image. It calls out to
imageLoadError ,whichyou
'
ll need to modify to fit your particular
error-handling needs. And finally, we
'
'
ll use the load method of our
Loader to attempt to load an image.
_imageURLRequest .
private function createImage(column:int, row:int):void {
_pointVector.push(new Point(column, row/_columns));
_imageURLRequest.url = _galleryPath + _imageArray[row +
column];
_imageLoader = new Loader();
_imageLoader.name = _imageNamePrefix + (row + column);
_imageLoader.addEventListener(MouseEvent.CLICK,
imageClicked, false, 0, true);
_imageLoader.contentLoaderInfo.addEventListener(Event.
COMPLETE, placeImage, false, 0, true);
_imageLoader.contentLoaderInfo.addEventListener(IOError
Event.IO_ERROR, imageLoadError, false, 0, true);
_imageLoader.load(_imageURLRequest);
}
ve created the images, the next thing that
happens for each one after it
So now that we
'
s finished loading is that it notifies
the placeImage method of its load completion. The first thing the
placeImage method then does is to release a little memory
by removing the two load-related listeners ( Event.COMPLETE and
IOErrorEvent.IO_ERROR ). Now we
'
re going to use _loadedImage to
reference and manipulate our currently targeted Loader (image).
So here
'
s where we get back to the Vector full of Points with x,y
values that didn
'
t make any sense earlier. Remember when we
named our images and added the row and column together to
append a number to the end of the name? Well that number just
so happens to match the image
'
sindexin _imageArray and the
index of the Point it will use from _pointVector .SeewhereI
'
'
m
going with this?
So let
'
s take _loadedImage and pass it to the pointIndex method.
We
ll quickly look at that method later, but it basically just strips the
number off the end of the name for us to use in the next steps. Now
that we
'
'
ve got that number, we can use it to pull the correct Point
from _pointVector .We
'
ll grab the x and y values from that Point
and assign them back to column and row variables for use within this
method.Nextistosettheimage
s scaleX and scaleY according to
the _thumbScale variable and then get into a tiny bit of math.
Now that we
'
re dealing with a thumbnail
(assuming that the _thumbScale variable was set lower than 1).
The math in the next couple of lines is where the location of the
'
ve scaled the image, we
'
Search WWH ::




Custom Search