Contents |
imgBox is a useful component that helps loading images or SWF movies in Flash Lite applications and gives a full easy control on the image scale, rotate, align, and user touch gestures. Also it has loading effects of sliding (RTL or LTR), expanding, and alpha. A 'while loading animation' is another feature of this component and can be customized easily.
We load images in our applications a lot, so why wasting time on routine code. Just use imgBox component and it will do them all for you.
imgBox component (MXP) and a simple usage example: http://www.benefit-ms.com/downloads/others/imgBox_component.zip
Installation of the imgBox component is easy. Execute the components MXP file and follow the simple instructions in Adobe Extension Manager to complete the installation process. Restart Adobe Flash CS4 after installation.
Note: Component FLA and AS files should appear in the directories [INSTALL PATH]\Flash CS4\en\Configuration\Components\Forum Nokia and [INSTALL PATH]\Flash CS4\en\Configuration\Classes\com\forumnokia. In some setup environments, the files may appear under the wrong language directories (for example, fi instead of en). In such cases, the files should be manually moved to the correct directories as specified above.
Indicates the current scaling of the loaded file within imgBox. The scaleMode property can use the values exactFit, showAll, and noScale.
Note: imgZoom property must be set to 0 to enable scaleMode effect.
This property can use any number value. When set to 0, the selected scaleMode will be used to scale the image, otherwise the image will be zoomed according to imgZoom value.
To specify image rotation inside the box. This property can use any number value.
To specify image align inside the box. This property can use the following values:
| Value | Vertical | Horizontal |
|---|---|---|
| C | Center | Center |
| T | Top | Center |
| B | Bottom | Center |
| L | Center | Left |
| R | Center | Right |
| TL | Top | Left |
| TR | Top | Right |
| BL | Bottom | Left |
| BR | Bottom | Right |
imgBox can give the image some effects after loading it. This property can use the following values: Alpha, Expand, SlideRTL, SlideLTR, None
Gets and sets the image position inside the box.
Gets the image size.
Loads image or SWF movie inside the box.
This should be called after changing any of the following properties scaleMode, imgZoom, imgRotation and imgAlign
Invoked when a file loaded with imgBox.loadImage() has loaded successfully.
Invoked when a file loaded with imgBox.loadImage() has failed to load.
Invoked when imgBox is clicked (only in touchscreen enabled devices).
Parameters: _xclick and _yclick tells the point inside the box that was clicked.
Invoked when imgBox is double clicked (only in touchscreen enabled devices).
Parameters: _xclick and _yclick tells the point inside the box that was double clicked.
Invoked when imgBox is touched with a slide gesture if the loaded image size is equal or smaller than the box, but if the image is larger than the box this event won't be triggered and the touch event will move the image inside the box.
Parameters:
The next illustration shows how to identify the touch slide gesture using these parameters:
iBox.loadImage("http://www.forum.nokia.com/images/logo_forumnokia.gif");
var LoaderListener:Object = new Object();
function onImgLoaded (evt:Object):Void {
trace("Image Loaded");
}
function onImgDblClick(evt:Object):Void {
// zoom the image when double clicked
iBox.imgZoom+=100;
iBox.reDraw();
}
function onImgClick(evt:Object):Void {
// fit the image in the box when clicked
iBox.imgZoom=0;
iBox.scaleMode="exactFit";
iBox.reDraw();
}
function onImgSlideTouch(evt:Object):Void {
// rotate
if(evt.Clockwise){
iBox.imgRotation+=90;
}else{
iBox.imgRotation-=90;
}
iBox.reDraw();
}
iBox.addEventListener("imgLoaded", onImgLoaded);
iBox.addEventListener("imgDblClick", onImgDblClick);
iBox.addEventListener("imgClick", onImgClick);
iBox.addEventListener("imgSlideTouch", onImgSlideTouch);
No related wiki articles found