bkp image rail
TRANSCRIPT
<?xml version="1.0" encoding="utf-8"?><mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:imageLoading="com.flyaway.imageLoading.*"verticalAlign="middle"horizontalAlign="center"creationComplete="onCreationComplete(event)">
<mx:Script><![CDATA[
import com.flyaway.imageLoading.ImageLoading;
import mx.collections.ArrayCollection;import mx.effects.Move;import mx.events.EffectEvent;import mx.events.FlexEvent;import mx.managers.PopUpManager;import mx.utils.ObjectUtil;
// tamanho da image[Bindable]private var _width_image:Number=100;
[Bindable]private var _heigth_image:Number=100;
// property do name do arquivoprivate var _image_property:String;
private var _spacing:Number=0;
// image pathprivate var _image_path:String;
private var _move:Move=new Move();
[Bindable]private var _image_array:ArrayCollection=new ArrayCollec
tion();
// image atualprivate var atual:int=0;
// image atualprivate var atualObj:Object;
// imageprivate var img:ImageLoading;
protected function onCreationComplete(event:FlexEvent):void
{stage.addEventListener(KeyboardEvent.KEY_DOWN, f
unction(event:KeyboardEvent):void{
switch (event.keyCode){
case Keyboard.ESCAPE:close();break;
}});
}
//inicia o componenteprivate function init():void{
//imageCanvas.removeAllChildren();
_move.target=imageCanvas; _move.addEventListener(EffectEvent.EFFECT_END, c
heck_atual);
atual=0;
var posX:Number=0;
for (var i:int=0; i < _image_array.length; i++){
var image:ImageLoading=new ImageLoading();
image.source=_image_path + _image_array.source[i][_image_property];
image.width=_width_image;//image.height=_heigth_image;image.scaleContent=false;image.setStyle("verticalAlign", "center"
);image.setStyle("horizontalAlign", "cente
r");image.x=posX;posX=_width_image + posX + _spacing;
imageCanvas.addChild(image);
if (atualObj != null){
if (atualObj[_image_property] ==_image_array.source[i][_image_property])
{ _move.xTo=(imageCanvas.x
- _width_image - _spacing) * i; _move.play();atual=i;
}}
}check_atual(null);
}
// metodos privadosprivate function check_atual(event:Event):void{
if (atual >= _image_array.length - 1){
next.enabled=false;next.visible=false;
}else{
next.enabled=true;next.visible=true;
}if (atual == 0){
back.enabled=false;back.visible=false;
}else{
back.enabled=true;back.visible=true;
}}
private function back_click(event:MouseEvent):void{
_move.xTo=imageCanvas.x + _width_image + _spacing;
_move.play();
next.enabled=false;back.enabled=false;
atual--;}
private function next_click(event:MouseEvent):void{
_move.xTo=imageCanvas.x - _width_image - _spacing;
_move.play();
next.enabled=false;back.enabled=false;
atual++;}
private function close():void{
PopUpManager.removePopUp(this);}
//========================================// SET//========================================public function set setArrayImages(value:ArrayCollection
):void{
_image_array=value;this.init();
}
public function set setImageAtual(value:Object):void{
atualObj=value;}
public function set setImagePath(value:String):void{
_image_path=value;
this.init();}
public function set setImagePropertyToUse(value:String):void
{ _image_property=value;
}
public function set setWidthImage(value:Number):void{
_width_image=value;}
public function set setHeigthImage(value:Number):void{
_heigth_image=value;}
]]></mx:Script><!--========================================================================
===== FRONT END========================================================================
===--><mx:Canvas width="{_width_image}"
verticalScrollPolicy="off"horizontalScrollPolicy="off">
<mx:Canvas id="imageCanvas"styleName="imageRailImage"verticalScrollPolicy="off"horizontalScrollPolicy="off"/>
<mx:HBox width="100%"horizontalAlign="right">
<mx:LinkButton label="X"color="#FFFFFF"click="close()"/>
</mx:HBox><mx:HBox width="100%"
height="100%"verticalAlign="middle"horizontalAlign="center">
<mx:Image toolTip="Foto anterior"source="assets/ico_arrow_left.png"id="back"click="{back_click(event)}"buttonMode="true"/>
<mx:Spacer width="100%"height="100%"/>
<mx:Image toolTip="Próxima foto"id="next"source="assets/ico_arrow_right.png"click="{next_click(event)}"buttonMode="true"/>
</mx:HBox></mx:Canvas>
</mx:VBox>