Build 2 rows in a one row carussel
Hello Community,
i need a serious help in a script and have as a "Beginner" absolutly no clue how to do or where to do it.
To the Action:
There is a script in Flash Action Script what should show an container where are should be some Pictures inside.
This is the Bar at the Bottom:

Here i need now 2 rows of that Bar but the two arrows at the left and right should be in the high of both rows - so if you click the left arrow, the 6 pictures of the bar-line 1 (see above, there comes 6 pictures in) and the 6 pictures of the new bar line 2 (should be above) should scroll at the same time to the right, or left if clicked the right arrow.
What must i change or include to get this.
Must i start a new script ? If yes what i must write in that it works as i need it ?
It would be very very very great if you can give me the needed script add-on here ![]()
kind regard
The scrip so far:
[spoiler][code]
package lesta.controls
{
import scaleform.clik.controls.CoreList;
import scaleform.clik.controls.Button;
import flash.display.MovieClip;
import flash.geom.Point;
import scaleform.clik.core.UIComponent;
import scaleform.clik.events.ButtonEvent;
import flash.events.Event;
import scaleform.clik.events.InputEvent;
import flash.events.MouseEvent;
import scaleform.clik.interfaces.IDataProvider;
import scaleform.clik.interfaces.IListItemRenderer;
import scaleform.clik.events.ListEvent;
import scaleform.gfx.MouseEventEx;
import scaleform.clik.constants.InvalidationType;
import lesta.cpp.Tween;
import flash.display.DisplayObject;
import scaleform.clik.data.ListData;
import flash.utils.setInterval;
import flash.utils.clearInterval;
import scaleform.clik.ui.InputDetails;
import scaleform.clik.constants.InputValue;
import scaleform.clik.constants.NavigationCode;
public class Carousel extends CoreList
{
public static const INVALIDATE_SCROLL_POSITION:String = "invalidateScrollPosition";
public static const DIRECTION_LEFT:int = -1;
public static const DIRECTION_RIGHT:int = 1;
public static const DIRECTION_STOP:int = 0;
private var ARROW_DURATION:Number = 500;
private var DRAG_INTERVAL:Number = 40.0;
private var ARROW_INTERVAL:Number = 150.0;
public var mButtonLeftArrow:Button;
public var mButtonRightArrow:Button;
public var mRenderersMask:MovieClip;
private var mItemsHorPadding:Number = 0;
private var mItemsHorSpace:Number = 0;
private var mIsFillEmpty:Boolean = false;
private var mItemsCountAdjust:int = -1;
private var mSpeedCheck:Array;
private var mDisableScaleItems:Boolean = false;
private var mInitButtonsScale:Point;
private var mInitMaskRightMargin:Number = 0;
private var mInitMaskLeftMargin:Number = 0;
private var mCountItems:int = 0;
private var mScrollPosition:Number = 0;
private var mItemScrollPosition:uint = 0;
private var mColumnWidth:Number = 1;
private var currentTweenId:int = -1;
private var mIdDraggingInterval:int = -1;
private var mIdArrowInterval:int = -1;
private var mIdKeyArrowInterval:int = -1;
private var mMouseDownPosition:Point;
private var mListDragSpeeds:Array;
private var mArrowDirection:int = 0;
private var mContainerPositionBeforeDrag:Number = 0;
private var mLastPressItem:UIComponent = null;
private var mKeyArrowDirection:int = 0;
public function Carousel()
{
this.mSpeedCheck = [0.5,1.5,3];
this.mInitButtonsScale = new Point();
this.mMouseDownPosition = new Point();
this.mListDragSpeeds = [];
super();
this.mInitButtonsScale.x = this.mButtonLeftArrow.scaleX;
this.mInitButtonsScale.y = this.mButtonLeftArrow.scaleY;
this.mInitMaskLeftMargin = this.mRenderersMask.x;
this.mInitMaskRightMargin = width / scaleX - this.mRenderersMask.x - this.mRenderersMask.width;
scaleX = 1;
scaleY = 1;
}
override protected function configUI() : void
{
super.configUI();
this.mButtonLeftArrow.addEventListener(ButtonEvent.PRESS,this.onButtonLeftArrowPress,false,0,true);
this.mButtonLeftArrow.addEventListener(ButtonEvent.CLICK,this.onButtonLeftArrowClick,false,0,true);
this.mButtonLeftArrow.addEventListener(ButtonEvent.RELEASE_OUTSIDE,this.onButtonLeftArrowReleaseOutside,false,0,true);
this.mButtonRightArrow.addEventListener(ButtonEvent.PRESS,this.onButtonRightArrowPress,false,0,true);
this.mButtonRightArrow.addEventListener(ButtonEvent.CLICK,this.onButtonRightArrowClick,false,0,true);
this.mButtonRightArrow.addEventListener(ButtonEvent.RELEASE_OUTSIDE,this.onButtonRightArrowReleaseOutside,false,0,true);
container.mask = this.mRenderersMask;
}
override protected function addedToStage(param1:Event) : void
{
super.addedToStage(param1);
stage.addEventListener(InputEvent.INPUT,this.handleInput,false,0,true);
stage.addEventListener(MouseEvent.MOUSE_UP,this.handleMouseUpOnStage,false,0,true);
}
override public function set width(param1:Number) : void
{
this.mItemsCountAdjust = -1;
super.width = param1;
}
public function set fillEmpty(param1:Boolean) : void
{
this.mIsFillEmpty = param1;
invalidateData();
}
override public function set dataProvider(param1:IDataProvider) : void
{
super.dataProvider = param1;
this.mCountItems = super.dataProvider.length;
invalidateRenderers();
invalidateData();
}
override public function set itemRendererName(param1:String) : void
{
super.itemRendererName = param1;
this.recalcColumnWidth();
invalidateRenderers();
invalidateSize();
}
public function set itemsHorSpace(param1:Number) : void
{
this.mItemsHorSpace = param1;
}
public function set itemPaddingHorz(param1:Number) : void
{
this.mItemsHorPadding = param1;
this.recalcColumnWidth();
invalidateSize();
}
public function set disableScaleItems(param1:Boolean) : void
{
this.mDisableScaleItems = param1;
invalidateSize();
}
public function adjustToItemCount(param1:int) : void
{
if(param1 == -1)
{
this.mItemsCountAdjust = -1;
return;
}
this.mItemsCountAdjust = param1;
super.width = this.getAdjustedWidthToCount(param1);
invalidateSize();
this.mItemScrollPosition = 0;
this.scrollPosition = 0;
}
public function set scrollPosition(param1:Number) : void
{
if(param1 < 0)
{
var param1:Number = 0;
}
if(param1 > 1)
{
param1 = 1;
}
this.mScrollPosition = param1;
invalidate(INVALIDATE_SCROLL_POSITION);
}
override public function scrollToIndex(param1:uint) : void
{
if(this.mCountItems > this.countVisibleItems)
{
if(param1 > this.countRenderers - this.countVisibleItems)
{
var param1:uint = this.countRenderers - this.countVisibleItems;
}
}
else
{
param1 = 0;
}
this.mItemScrollPosition = param1;
this.scrollPosition = this.getPartByIndex(param1);
}
public function getAdjustedWidthToCount(param1:int) : Number
{
return param1 * (this.mColumnWidth - this.mItemsHorPadding * 2) + (param1 - 1) * this.mItemsHorSpace + this.mInitMaskLeftMargin + this.mInitMaskRightMargin;
}
public function get countVisibleItems() : int
{
if(this.mColumnWidth == 0)
{
return 0;
}
var _loc1_:int = Math.ceil((width - this.mInitMaskLeftMargin - this.mInitMaskRightMargin) / this.mColumnWidth);
return this.mItemsCountAdjust != -1?this.mItemsCountAdjust:_loc1_;
}
override public function get availableWidth() : Number
{
return this.mRenderersMask.width * scaleX;
}
override public function get availableHeight() : Number
{
return this.mRenderersMask.height * scaleY;
}
public function get scrollPosition() : Number
{
return this.mScrollPosition;
}
override public function getRendererAt(param1:uint, param2:int = 0) : IListItemRenderer
{
if(_renderers == null)
{
return null;
}
if(_renderers.length <= param1)
{
return null;
}
return _renderers[param1];
}
override protected function setupRenderer(param1:IListItemRenderer) : void
{
param1.owner = this;
param1.focusTarget = this;
param1.tabEnabled = false;
param1.doubleClickEnabled = true;
param1.addEventListener(ButtonEvent.PRESS,this.handleItemPress,false,0,true);
param1.addEventListener(ButtonEvent.CLICK,this.handleItemClick,false,0,true);
param1.addEventListener(MouseEvent.DOUBLE_CLICK,this.dispatchItemEvent,false,0,true);
param1.addEventListener(MouseEvent.ROLL_OVER,this.dispatchItemEvent,false,0,true);
param1.addEventListener(MouseEvent.ROLL_OUT,this.dispatchItemEvent,false,0,true);
if(_usingExternalRenderers)
{
param1.addEventListener(MouseEvent.MOUSE_WHEEL,handleMouseWheel,false,0,true);
}
}
override protected function cleanUpRenderer(param1:IListItemRenderer) : void
{
param1.owner = null;
param1.focusTarget = null;
param1.doubleClickEnabled = false;
param1.removeEventListener(ButtonEvent.PRESS,this.handleItemPress);
param1.removeEventListener(ButtonEvent.CLICK,this.handleItemClick);
param1.removeEventListener(MouseEvent.DOUBLE_CLICK,this.dispatchItemEvent);
param1.removeEventListener(MouseEvent.ROLL_OVER,this.dispatchItemEvent);
param1.removeEventListener(MouseEvent.ROLL_OUT,this.dispatchItemEvent);
param1.removeEventListener(MouseEvent.MOUSE_WHEEL,handleMouseWheel);
}
override protected function dispatchItemEvent(param1:Event) : Boolean
{
var _loc2_:String = null;
switch(param1.type)
{
case ButtonEvent.PRESS:
_loc2_ = ListEvent.ITEM_PRESS;
break;
case ButtonEvent.CLICK:
_loc2_ = ListEvent.ITEM_CLICK;
break;
case ButtonEvent.RELEASE_OUTSIDE:
_loc2_ = "itemReleaseOutside";
break;
case MouseEvent.ROLL_OVER:
_loc2_ = ListEvent.ITEM_ROLL_OVER;
break;
case MouseEvent.ROLL_OUT:
_loc2_ = ListEvent.ITEM_ROLL_OUT;
break;
case MouseEvent.DOUBLE_CLICK:
_loc2_ = ListEvent.ITEM_DOUBLE_CLICK;
break;
default:
return true;
}
var _loc3_:IListItemRenderer = param1.currentTarget as IListItemRenderer;
var _loc4_:uint = 0;
if(param1 is ButtonEvent)
{
_loc4_ = (param1 as ButtonEvent).controllerIdx;
}
else if(param1 is MouseEventEx)
{
_loc4_ = (param1 as MouseEventEx).mouseIdx;
}
var _loc5_:uint = 0;
if(param1 is ButtonEvent)
{
_loc5_ = (param1 as ButtonEvent).buttonIdx;
}
else if(param1 is MouseEventEx)
{
_loc5_ = (param1 as MouseEventEx).buttonIdx;
}
var _loc6_:* = false;
if(param1 is ButtonEvent)
{
_loc6_ = (param1 as ButtonEvent).isKeyboard;
}
var _loc7_:ListEvent = new ListEvent(_loc2_,false,true,_loc3_.index,0,_loc3_.index,_loc3_,dataProvider[_loc3_.index],_loc4_,_loc5_,_loc6_);
return dispatchEvent(_loc7_);
}
override protected function draw() : void
{
var _loc1_:* = NaN;
var _loc2_:* = false;
var _loc3_:* = false;
super.draw();
if(isInvalid(InvalidationType.SIZE))
{
this.mRenderersMask.x = this.mInitMaskLeftMargin / scaleX;
this.mRenderersMask.width = (width - this.mInitMaskLeftMargin - this.mInitMaskRightMargin) / scaleX;
this.mButtonRightArrow.scaleX = this.mInitButtonsScale.x / this.scaleX;
this.mButtonRightArrow.scaleY = this.mInitButtonsScale.y / this.scaleY;
this.mButtonLeftArrow.scaleX = this.mInitButtonsScale.x / this.scaleX;
this.mButtonLeftArrow.scaleY = this.mInitButtonsScale.y / this.scaleY;
this.mButtonRightArrow.x = width / scaleX - this.mButtonRightArrow.width;
container.x = Math.round(this.getXByPart(0));
}
if(isInvalid(INVALIDATE_SCROLL_POSITION))
{
_loc1_ = this.ARROW_DURATION;
this.currentTweenId = Tween.to(container,0.5,{"x":container.x},{"x":this.getXByPart(this.mScrollPosition)},null,Tween.EASE_OUT_QUAD);
_loc2_ = this.mCountItems > this.countVisibleItems && this.mScrollPosition > this.getPartByIndex(0.5);
_loc3_ = this.mCountItems > this.countVisibleItems && this.mScrollPosition < this.getPartByIndex(this.mCountItems - this.countVisibleItems - 0.5);
if(this.mButtonLeftArrow.enabled != _loc2_)
{
this.mButtonLeftArrow.enabled = _loc2_;
if(!_loc2_)
{
this.stopArrowInterval(-1);
}
}
if(this.mButtonRightArrow.enabled != _loc3_)
{
this.mButtonRightArrow.enabled = _loc3_;
if(!_loc3_)
{
this.stopArrowInterval(1);
}
}
}
if(isInvalid(InvalidationType.DATA))
{
this.drawLayout();
this.drawRenderers(_totalRenderers);
}
container.mask = this.mRenderersMask;
}
override protected function drawLayout() : void
{
var _loc1_:uint = 0;
var _loc2_:* = NaN;
var _loc3_:* = NaN;
var _loc4_:* = NaN;
var _loc5_:* = false;
var _loc6_:uint = 0;
var _loc7_:IListItemRenderer = null;
if(_renderers != null)
{
_loc1_ = _renderers.length;
_loc2_ = this.availableHeight;
_loc3_ = -this.mItemsHorPadding;
_loc4_ = 0;
_loc5_ = isInvalid(InvalidationType.DATA);
_loc6_ = 0;
while(_loc6_ < _loc1_)
{
_loc7_ = this.getRendererAt(_loc6_);
_loc7_.x = Math.round(_loc3_);
_loc7_.y = Math.round(_loc4_);
if(!this.mDisableScaleItems)
{
_loc7_.height = _loc2_;
(_loc7_ as DisplayObject).scaleX = (_loc7_ as DisplayObject).scaleY;
}
if(!_loc5_)
{
_loc7_.validateNow();
}
_loc3_ = _loc3_ + (_loc7_.width - 2 * this.mItemsHorPadding + this.mItemsHorSpace);
_loc6_++;
}
}
}
override protected function updateSelectedIndex() : void
{
super.updateSelectedIndex();
this.refreshData();
}
override protected function refreshData() : void
{
this.drawLayout();
this.drawRenderers(_totalRenderers);
_dataProvider.requestItemRange(0,_dataProvider.length,this.populateData);
}
override protected function calculateRendererTotal(param1:Number, param2:Number) : uint
{
return _dataProvider.length;
}
override protected function drawRenderers(param1:Number) : void
{
var _loc2_:* = 0;
var _loc3_:* = 0;
var _loc4_:* = 0;
var _loc5_:IListItemRenderer = null;
var _loc6_:DisplayObject = null;
if(_renderers != null)
{
if(_itemRenderer == null)
{
trace("Renderer class not defined.");
return;
}
_loc2_ = !this.mIsFillEmpty?this.mCountItems:Math.max(this.mCountItems,this.countVisibleItems);
_loc3_ = _renderers.length;
while(_loc3_ < _loc2_)
{
_loc5_ = createRenderer(_loc3_);
if(_loc5_ == null)
{
break;
}
_renderers.push(_loc5_);
container.addChild(_loc5_ as DisplayObject);
_loc3_++;
}
_loc4_ = _renderers.length;
_loc3_ = _loc4_ - 1;
while(_loc3_ >= _loc2_)
{
_loc5_ = this.getRendererAt(_loc3_);
if(_loc5_ != null)
{
this.cleanUpRenderer(_loc5_);
_loc6_ = _loc5_ as DisplayObject;
if(container.contains(_loc6_))
{
container.removeChild(_loc6_);
}
}
_renderers.splice(_loc3_,1);
_loc3_--;
}
}
}
override protected function scrollList(param1:int) : void
{
super.scrollList(param1);
if(this.mItemScrollPosition - param1 >= 0)
{
this.scrollToIndex(this.mItemScrollPosition - param1);
}
else
{
this.scrollToIndex(0);
}
}
override protected function handleDataChange(param1:Event) : void
{
super.handleDataChange(param1);
this.mCountItems = super.dataProvider.length;
invalidateRenderers();
invalidateData();
}
protected function populateData(param1:Array) : void
{
var _loc5_:IListItemRenderer = null;
var _loc6_:uint = 0;
var _loc7_:ListData = null;
if(_renderers == null)
{
return;
}
var _loc2_:uint = param1.length;
var _loc3_:uint = _renderers.length;
var _loc4_:uint = 0;
while(_loc4_ < _loc3_)
{
_loc5_ = this.getRendererAt(_loc4_);
_loc6_ = _loc4_;
_loc7_ = new ListData(_loc6_,itemToLabel(param1[_loc4_]),_selectedIndex == _loc6_);
_loc5_.enabled = _loc4_ >= _loc2_?false:true;
_loc5_.selected = _selectedIndex == _loc6_;
_loc5_.setListData(_loc7_);
_loc5_.setData(_loc4_ < this.mCountItems?param1[_loc4_]:null);
_loc5_.validateNow();
_loc4_++;
}
}
protected function get countRenderers() : int
{
if(_renderers == null)
{
return 0;
}
return _renderers.length;
}
protected function recalcColumnWidth() : void
{
if(itemRenderer == null)
{
return;
}
var _loc1_:IListItemRenderer = createRenderer(0);
if(!this.mDisableScaleItems)
{
_loc1_.height = this.availableHeight;
(_loc1_ as DisplayObject).scaleX = (_loc1_ as DisplayObject).scaleY;
}
this.mColumnWidth = _loc1_.width;
this.cleanUpRenderer(_loc1_);
}
protected function getXByPart(param1:Number) : Number
{
var _loc2_:Number = container.width - this.availableWidth / scaleX - this.mItemsHorPadding * 2 / scaleX;
if(_loc2_ < 0)
{
_loc2_ = 0;
}
return this.mRenderersMask.x - _loc2_ * this.scrollPosition;
}
protected function getPartByX(param1:Number) : Number
{
var _loc2_:Number = container.width - this.availableWidth / scaleX - this.mItemsHorPadding * 2 / scaleX;
if(_loc2_ <= 0)
{
return 0;
}
return param1 = (this.mRenderersMask.x - param1) / _loc2_;
}
protected function getPartByIndex(param1:Number) : Number
{
if(this.mCountItems <= this.countVisibleItems)
{
return 0;
}
return 1 / (this.mCountItems - this.countVisibleItems) * param1;
}
private function climbScrollItemPosition(param1:int) : Number
{
if(this.mCountItems > this.countVisibleItems)
{
if(param1 > this.countRenderers - this.countVisibleItems)
{
var param1:int = this.countRenderers - this.countVisibleItems;
}
}
else
{
param1 = 0;
}
return param1;
}
private function climbDragPosition(param1:Number) : Number
{
var _loc2_:Number = container.width - this.availableWidth / scaleX - this.mItemsHorPadding * 2 / scaleX;
if(_loc2_ < 0)
{
_loc2_ = 0;
}
var _loc3_:Number = this.mRenderersMask.x + this.mColumnWidth / 2 / scaleX;
var _loc4_:Number = this.mRenderersMask.x - _loc2_ - this.mColumnWidth / 2 / scaleX;
var _loc5_:Number = param1;
_loc5_ = _loc5_ > _loc3_?_loc3_:_loc5_ < _loc4_?_loc4_:_loc5_;
return _loc5_;
}
protected function getScrollPositionForItem(param1:int) : Number
{
return param1 * this.mColumnWidth + (param1 - 1) * this.mItemsHorSpace + this.mInitMaskLeftMargin + this.mInitMaskRightMargin;
}
protected function stopTween() : void
{
Tween.kill(this.currentTweenId);
}
protected function getAverageLastSpeedDrag() : Number
{
var _loc2_:* = 0;
var _loc1_:Number = 0;
if(this.mListDragSpeeds.length > 0)
{
_loc2_ = 0;
while(_loc2_ < this.mListDragSpeeds.length)
{
_loc1_ = _loc1_ + this.mListDragSpeeds[_loc2_];
_loc2_++;
}
_loc1_ = _loc1_ / this.mListDragSpeeds.length;
}
return _loc1_;
}
private function onButtonRightArrowPress(param1:ButtonEvent) : void
{
this.mArrowDirection = 1;
this.scrollToIndex(this.mItemScrollPosition + 1);
if(this.mIdArrowInterval == -1)
{
this.mIdArrowInterval = setInterval(this.onArrowInterval,this.ARROW_INTERVAL);
}
}
private function onButtonRightArrowClick(param1:ButtonEvent) : void
{
this.stopArrowInterval(1);
}
private function onButtonRightArrowReleaseOutside(param1:ButtonEvent) : void
{
this.stopArrowInterval(1);
}
private function onButtonLeftArrowPress(param1:ButtonEvent) : void
{
this.mArrowDirection = -1;
if(this.mItemScrollPosition > 0)
{
this.scrollToIndex(this.mItemScrollPosition - 1);
}
if(this.mIdArrowInterval == -1)
{
this.mIdArrowInterval = setInterval(this.onArrowInterval,this.ARROW_INTERVAL);
}
}
private function onButtonLeftArrowClick(param1:ButtonEvent) : void
{
this.stopArrowInterval(-1);
}
private function onButtonLeftArrowReleaseOutside(param1:ButtonEvent) : void
{
this.stopArrowInterval(-1);
}
private function stopArrowInterval(param1:int) : void
{
if(this.mIdArrowInterval == -1 || this.mArrowDirection != param1)
{
return;
}
clearInterval(this.mIdArrowInterval);
this.mIdArrowInterval = -1;
}
private function stopKeyArrowInterval(param1:int) : void
{
if(this.mIdKeyArrowInterval == -1 || this.mKeyArrowDirection != param1)
{
return;
}
clearInterval(this.mIdKeyArrowInterval);
this.mIdKeyArrowInterval = -1;
}
private function onArrowInterval() : void
{
if(this.mItemScrollPosition + this.mArrowDirection >= 0)
{
this.scrollToIndex(this.mItemScrollPosition + this.mArrowDirection);
}
else
{
this.scrollToIndex(0);
}
}
private function onKeyArrowInterval() : void
{
var _loc1_:uint = 0;
if(this.mItemScrollPosition + this.mKeyArrowDirection >= 0)
{
_loc1_ = this.mItemScrollPosition + this.mKeyArrowDirection;
}
this.scrollToIndex(_loc1_);
}
override public function handleInput(param1:InputEvent) : void
{
if(param1.currentTarget != stage)
{
return;
}
if(param1.isDefaultPrevented())
{
return;
}
var _loc2_:InputDetails = param1.details;
var _loc3_:uint = _loc2_.controllerIndex;
switch(_loc2_.navEquivalent)
{
case NavigationCode.RIGHT:
if(_loc2_.value == InputValue.KEY_DOWN)
{
this.mKeyArrowDirection = 1;
this.scrollToIndex(this.mItemScrollPosition + 1);
if(this.mIdKeyArrowInterval == -1)
{
this.mIdKeyArrowInterval = setInterval(this.onKeyArrowInterval,this.ARROW_INTERVAL);
}
}
else if(_loc2_.value == InputValue.KEY_UP)
{
this.stopKeyArrowInterval(1);
}
break;
case NavigationCode.LEFT:
if(_loc2_.value == InputValue.KEY_DOWN)
{
this.mKeyArrowDirection = -1;
if(this.mItemScrollPosition > 0)
{
this.scrollToIndex(this.mItemScrollPosition - 1);
}
if(this.mIdKeyArrowInterval == -1)
{
this.mIdKeyArrowInterval = setInterval(this.onKeyArrowInterval,this.ARROW_INTERVAL);
}
}
else if(_loc2_.value == InputValue.KEY_UP)
{
this.stopKeyArrowInterval(-1);
}
break;
}
}
private function handleMouseUpOnStage(param1:Event) : void
{
this.stopDragging();
}
protected function handleItemPress(param1:Event) : void
{
this.stopTween();
if(this.mIdDraggingInterval != -1)
{
return;
}
this.mLastPressItem = param1.target as UIComponent;
this.mContainerPositionBeforeDrag = container.x;
this.mMouseDownPosition.x = this.mouseX;
this.mMouseDownPosition.y = this.mouseY;
this.mListDragSpeeds.length = 0;
this.mIdDraggingInterval = setInterval(this.onDraggingInterval,this.DRAG_INTERVAL);
this.dispatchItemEvent(param1);
}
override protected function handleItemClick(param1:ButtonEvent) : void
{
if(Math.abs(container.x - this.mContainerPositionBeforeDrag) < 10)
{
super.handleItemClick(param1);
}
this.stopDragging();
}
private function onDraggingInterval() : void
{
var _loc1_:Number = this.mouseX;
var _loc2_:Number = this.mouseY;
var _loc3_:Number = _loc1_ - this.mMouseDownPosition.x;
var _loc4_:Number = container.x + _loc3_;
_loc4_ = this.climbDragPosition(_loc4_);
container.x = Math.round(_loc4_);
var _loc5_:Number = 0;
if(this.mListDragSpeeds.length > 0)
{
_loc5_ = -_loc3_ / this.DRAG_INTERVAL;
if(_loc5_ * this.getAverageLastSpeedDrag() < 0)
{
this.mListDragSpeeds.length = 0;
}
if(this.mListDragSpeeds.length > 10)
{
this.mListDragSpeeds.splice(1,1);
}
}
this.mListDragSpeeds.push(_loc5_);
this.mMouseDownPosition.x = _loc1_;
this.mMouseDownPosition.y = _loc2_;
}
private function stopDragging() : void
{
var _loc4_:* = 0;
var _loc5_:* = NaN;
var _loc6_:* = NaN;
var _loc7_:* = 0;
if(this.mIdDraggingInterval == -1)
{
return;
}
clearInterval(this.mIdDraggingInterval);
this.mIdDraggingInterval = -1;
var _loc1_:Number = this.getPartByX(container.x);
var _loc2_:Number = (this.countRenderers - this.countVisibleItems) * _loc1_;
var _loc3_:* = 0;
if(_loc1_ >= 0 && _loc1_ <= 1)
{
_loc4_ = Math.floor(_loc2_);
_loc5_ = _loc2_ - _loc4_;
_loc6_ = this.getAverageLastSpeedDrag();
if(_loc5_ > 0.8)
{
_loc3_ = int(Math.ceil(_loc2_));
}
else if(_loc5_ < 0.2)
{
_loc3_ = int(Math.floor(_loc2_));
}
else
{
_loc3_ = _loc6_ > 0?int(Math.ceil(_loc2_)):int(Math.floor(_loc2_));
}
_loc7_ = 0;
while(_loc7_ < this.mSpeedCheck.length)
{
if(_loc6_ >= this.mSpeedCheck[_loc7_])
{
_loc3_ = _loc3_ + (_loc6_ > 0?1:-1);
}
_loc7_++;
}
}
else
{
_loc3_ = _loc1_ < 0?0:this.countRenderers - this.countVisibleItems;
}
this.mItemScrollPosition = _loc3_;
this.scrollPosition = this.getPartByIndex(_loc3_);
}
}
}
[/code][/spoiler]
