Graphics Reference
In-Depth Information
columnLoop: for (var r:int = 0; r < _numberOfImages; r
+= columns) {
for (var c:int = 0; c < columns; c++) {
if(r+c < _numberOfImages){
createImage(c, r);
}else{
break columnLoop;
}
}
}
}
public function setPosition(xPosition:Number = 0,
yPosition:Number = 0) {
x = xPosition;
y = yPosition;
}
s take a look into that createImage method that was
being called from the for loop in the constructor. Since this is an
image gallery, there are images in it, and they need to be created
(or loaded, actually). The two parameters required by this method
are the column and row where the image will end up. If you
remember from the for loop, we passed those in with the two
variables c and r . On the very first line of createImage ,we
Now let
'
re going
to create a new Point with an x value equal to the column parameter
and a y value equal to the row parameter. That new Point is immedi-
ately added to the _pointVector for later use. Yes, you are correct.
That means you now have a Vector filled with Points with x,y values
like (0,1), (0,2), and (1,2). It may not make sense right away, but it
will make more when we look at the placeImage method. The next
way we
'
re going to use the column and row parameters together is to
grab an image name from _imageArray and append it to _gallery
Path . With those two values added together, we should have a valid
URL to an image for the gallery. What a coincidence! We need a
value like that for the url property of _imageURLRequest .Let
'
'
suse
this one, shall we?
Okay, now we
re going to use the _imageLoader variable to create a
new Loader for loading the image. Once we
'
'
ve instantiated that new
'
Loader, we
regoingtogiveitanameusingthe _imageNamePrefix
combined (once again) with row and column .Thistimewe
re adding
the values of row and column to come up with a number, so we
end up with names for our images like image_1 , image_2 ,and
image_3 . Let
'
Loaders next. First is
a MouseEvent.CLICK listener that will call the imageClicked method.
The second is an Event.COMPLETE listener that will call placeImage
once the image has finished loading from its external location.
'
s add a few listeners to our images
'
Search WWH ::




Custom Search