Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
package net.pixvi.myr.panel.figure
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import net.pixvi.common.center.TipCenter;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.myr.element.bag.ItemVo;
|
||||
import net.pixvi.pfw.display.BitMovieClip;
|
||||
import net.pixvi.pfw.display.NetBitImg;
|
||||
import net.pixvi.pfw.ui.controls.PiListItem;
|
||||
|
||||
public class FigureListItem extends PiListItem
|
||||
{
|
||||
|
||||
public var container_img:Sprite;
|
||||
|
||||
private var img:NetBitImg;
|
||||
|
||||
private var shadow:BitMovieClip = null;
|
||||
|
||||
public function FigureListItem(skin:DisplayObject = null, auto:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
super(skin,auto,w,h);
|
||||
}
|
||||
|
||||
override public function onData(value:Object) : void
|
||||
{
|
||||
clearImg();
|
||||
if(shadow == null)
|
||||
{
|
||||
shadow = FF.getBMC("mc.figureShadow",1);
|
||||
}
|
||||
var itemType:int = int(value);
|
||||
img = new NetBitImg(ItemVo.getImgSrc(itemType));
|
||||
container_img.addChild(shadow);
|
||||
container_img.addChild(img);
|
||||
if(img.loaded)
|
||||
{
|
||||
layoutImg();
|
||||
}
|
||||
else
|
||||
{
|
||||
img.addEventListener("complete",onImgComplete);
|
||||
}
|
||||
TipCenter.registTextTip(this,ItemVo.getName(itemType));
|
||||
}
|
||||
|
||||
private function onImgComplete(e:Event) : void
|
||||
{
|
||||
img.removeEventListener("complete",onImgComplete);
|
||||
layoutImg();
|
||||
}
|
||||
|
||||
private function layoutImg() : void
|
||||
{
|
||||
if(img == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
img.x = -0.5 * img.width;
|
||||
img.y = -img.height + 18;
|
||||
}
|
||||
|
||||
private function clearImg() : void
|
||||
{
|
||||
TipCenter.remove(this);
|
||||
if(shadow != null && shadow.parent != null)
|
||||
{
|
||||
shadow.parent.removeChild(shadow);
|
||||
}
|
||||
if(img != null)
|
||||
{
|
||||
img.removeEventListener("complete",onImgComplete);
|
||||
if(img.parent != null)
|
||||
{
|
||||
img.parent.removeChild(img);
|
||||
}
|
||||
img.dispose();
|
||||
img = null;
|
||||
}
|
||||
}
|
||||
|
||||
override public function reset() : void
|
||||
{
|
||||
clearImg();
|
||||
super.reset();
|
||||
}
|
||||
|
||||
override public function dispose() : void
|
||||
{
|
||||
TipCenter.remove(this);
|
||||
clearImg();
|
||||
shadow.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
package net.pixvi.myr.panel.figure
|
||||
{
|
||||
import flash.events.Event;
|
||||
import net.pixvi.common.center.PopCenter;
|
||||
import net.pixvi.myr.GameSetting;
|
||||
import net.pixvi.myr.center.BagCenter;
|
||||
import net.pixvi.pfw.event.MobiEvent;
|
||||
import net.pixvi.pfw.ui.controls.PiDataList;
|
||||
import net.pixvi.pfw.utils.broadcast.GlobalBroadcast;
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
import net.pixvi.psg.ui.PSGPopPanel;
|
||||
|
||||
public class FigureListPanel extends PSGPopPanel
|
||||
{
|
||||
|
||||
private static const DRAG_ROW_PX:Number = 40;
|
||||
|
||||
private static const COL_NUM:int = 4;
|
||||
|
||||
public var ui:FigureListPanelUI = new FigureListPanelUI();
|
||||
|
||||
private var _dragging:Boolean = false;
|
||||
|
||||
private var _lastRowY:Number = 0;
|
||||
|
||||
private var _startIndex:int = 0;
|
||||
|
||||
public function FigureListPanel(showTime:Number = -1, hideTime:Number = -1)
|
||||
{
|
||||
addChild(ui);
|
||||
super(GameSetting.PanelTransTime,GameSetting.PanelTransTime);
|
||||
ui.btn_close.onClick(closeBtnHandler);
|
||||
}
|
||||
|
||||
public static function getIns() : FigureListPanel
|
||||
{
|
||||
return Singleton.getInstanceOrCreate(FigureListPanel) as FigureListPanel;
|
||||
}
|
||||
|
||||
override public function init() : void
|
||||
{
|
||||
GlobalBroadcast.addEventListener("androidBack",AndroidBackHandler);
|
||||
ui.list_figure.setDatas(BagCenter.getIns().getAllSkinItem());
|
||||
ui.text_num.text = "收藏数量:" + ui.list_figure.totalItems;
|
||||
setupSliderByRow();
|
||||
ui.list_figure.addEventListener(MobiEvent.MOUSE_DOWN,listDragDownHandler);
|
||||
ui.bar_list.addEventListener("pichange",sliderChangeHandler);
|
||||
}
|
||||
|
||||
private function setupSliderByRow() : void
|
||||
{
|
||||
var list:PiDataList = ui.list_figure;
|
||||
var visibleRows:int = Math.ceil(list.pageSize / 4);
|
||||
var totalRows:int = Math.ceil(list.totalItems / 4);
|
||||
var maxRow:int = totalRows - visibleRows;
|
||||
if(maxRow < 0)
|
||||
{
|
||||
maxRow = 0;
|
||||
}
|
||||
ui.bar_list.scaleBtn = false;
|
||||
ui.bar_list.bind(null,null,maxRow,0,true,0);
|
||||
_startIndex = 0;
|
||||
ui.bar_list.value = 0;
|
||||
showRow(0);
|
||||
}
|
||||
|
||||
private function showRow(row:int) : void
|
||||
{
|
||||
_startIndex = row * 4;
|
||||
ui.list_figure.showDataByIndex(_startIndex);
|
||||
}
|
||||
|
||||
private function sliderChangeHandler(e:Event) : void
|
||||
{
|
||||
showRow(int(ui.bar_list.value));
|
||||
}
|
||||
|
||||
private function listDragDownHandler(e:Event) : void
|
||||
{
|
||||
_dragging = true;
|
||||
_lastRowY = stage.mouseY;
|
||||
stage.addEventListener(MobiEvent.MOUSE_MOVE,listDragMoveHandler);
|
||||
stage.addEventListener(MobiEvent.MOUSE_UP,listDragUpHandler);
|
||||
}
|
||||
|
||||
private function listDragMoveHandler(e:Event) : void
|
||||
{
|
||||
if(!_dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row:int = int(ui.bar_list.value);
|
||||
var maxRow:int = ui.bar_list.max;
|
||||
while(_lastRowY - stage.mouseY >= 40)
|
||||
{
|
||||
if(row < maxRow)
|
||||
{
|
||||
row++;
|
||||
}
|
||||
_lastRowY -= 40;
|
||||
}
|
||||
while(stage.mouseY - _lastRowY >= 40)
|
||||
{
|
||||
if(row > 0)
|
||||
{
|
||||
row--;
|
||||
}
|
||||
_lastRowY += 40;
|
||||
}
|
||||
if(row != int(ui.bar_list.value))
|
||||
{
|
||||
ui.bar_list.value = row;
|
||||
showRow(row);
|
||||
}
|
||||
}
|
||||
|
||||
private function listDragUpHandler(e:Event) : void
|
||||
{
|
||||
stopDrag();
|
||||
}
|
||||
|
||||
private function stopDrag() : void
|
||||
{
|
||||
_dragging = false;
|
||||
if(stage != null)
|
||||
{
|
||||
stage.removeEventListener(MobiEvent.MOUSE_MOVE,listDragMoveHandler);
|
||||
stage.removeEventListener(MobiEvent.MOUSE_UP,listDragUpHandler);
|
||||
}
|
||||
}
|
||||
|
||||
private function closeBtnHandler(e:Event = null) : void
|
||||
{
|
||||
closeHandler();
|
||||
}
|
||||
|
||||
private function AndroidBackHandler(e:Event = null) : void
|
||||
{
|
||||
if(PopCenter.getIns().topPanel == this)
|
||||
{
|
||||
closeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public function closeHandler(e:Event = null) : void
|
||||
{
|
||||
GlobalBroadcast.removeEventListener("androidBack",AndroidBackHandler);
|
||||
ui.list_figure.removeEventListener(MobiEvent.MOUSE_DOWN,listDragDownHandler);
|
||||
ui.bar_list.removeEventListener("pichange",sliderChangeHandler);
|
||||
stopDrag();
|
||||
this.showOut();
|
||||
dispatchEvent(new Event("complete"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.pixvi.myr.panel.figure
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.text.TextField;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
import net.pixvi.pfw.ui.controls.PiDataList;
|
||||
import net.pixvi.pfw.ui.controls.PiSliderBar;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class FigureListPanelUI extends UIComponent
|
||||
{
|
||||
|
||||
public var btn_close:PiLightButton;
|
||||
|
||||
public var list_figure:PiDataList;
|
||||
|
||||
public var bar_list:PiSliderBar;
|
||||
|
||||
public var text_num:TextField;
|
||||
|
||||
public function FigureListPanelUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
skin = FF.getMC("ui.FigurePanelUI");
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
list_figure.itemClass = FigureListItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user