[Event(name="scroll", type="mx.events.ScrollEvent")]
0)
{
var scrollingOn:Boolean;
var newScrollingOn:Boolean;
var flowComposer:IFlowComposer = _activeFlow.flowComposer;
var controller:ContainerController = flowComposer.getControllerAt(flowComposer.numControllers - 1);
var textConfiguration:Configuration = Configuration(_activeFlow.configuration);
if (_activeFlow.computedFormat.blockProgression == BlockProgression.TB)
{
scrollingOn = (controller.verticalScrollPolicy != ScrollPolicy.OFF);
newScrollingOn = scrollByAmount.selectedLabel != "Off";
if (scrollingOn != newScrollingOn)
controller.verticalScrollPolicy = newScrollingOn ? ScrollPolicy.ON : ScrollPolicy.OFF;
}
else
{
scrollingOn = (controller.horizontalScrollPolicy != ScrollPolicy.OFF);
newScrollingOn = scrollByAmount.selectedLabel != "Off";
if (scrollingOn != newScrollingOn)
controller.horizontalScrollPolicy = newScrollingOn ? ScrollPolicy.ON : ScrollPolicy.OFF;
}
}
}
private function updateScrollDragDelay():void
{
if (_activeFlow && _activeFlow.configuration && (DragDelay.text != ""))
{
var textConfiguration:Configuration = Configuration(_activeFlow.configuration);
textConfiguration.scrollDragDelay = Number(DragDelay.text);
}
}
private function updateScrollDragPixels():void
{
if (_activeFlow && _activeFlow.configuration && (DragPixels.text != ""))
{
var textConfiguration:Configuration = Configuration(_activeFlow.configuration);
textConfiguration.scrollDragPixels = Number(DragPixels.text);
}
}
private function updateScrollPagePercent():void
{
if (_activeFlow && _activeFlow.configuration && (PagePercent.text != ""))
{
var textConfiguration:Configuration = Configuration(_activeFlow.configuration);
textConfiguration.scrollPagePercentage = Number(PagePercent.text);
}
}
private function updateScrollMouseWheelMultiplier():void
{
if (_activeFlow && _activeFlow.configuration && (MouseWheelMultiplier.text != ""))
{
var textConfiguration:Configuration = Configuration(_activeFlow.configuration);
textConfiguration.scrollMouseWheelMultiplier = Number(MouseWheelMultiplier.text);
}
}
private var _activeFlow:TextFlow = null;
public function get activeFlow():TextFlow
{
return _activeFlow;
}
public function set activeFlow(t:TextFlow):void
{
_activeFlow = t;
}
public function scrollTo(x:Number, y:Number):void
{
var detail:String;
var delta:Number;
doScroll(detail, x, ScrollEventDirection.HORIZONTAL, delta);
doScroll(detail, y, ScrollEventDirection.VERTICAL, delta);
updateScrollSettings();
}
public function scroll(button:Button):void
{
var direction:String;
var detail:String;
var position:Number;
var delta:Number;
var scrollPercent:Number;
var dirVal:Number;
if (_activeFlow.flowComposer && _activeFlow.flowComposer.numControllers)
{
// TODO: multiple controllers?
var firstController:ContainerController = _activeFlow.flowComposer.getControllerAt(0);
var textConfiguration:Configuration = Configuration(_activeFlow.configuration);
scrollPercent = textConfiguration.scrollPagePercentage;
switch(button)
{
case leftScroll:
dirVal = -1;
direction = ScrollEventDirection.HORIZONTAL;
break;
case rightScroll:
dirVal = 1;
direction = ScrollEventDirection.HORIZONTAL;
break;
case upScroll:
dirVal = -1;
direction = ScrollEventDirection.VERTICAL;
break;
case downScroll:
dirVal = 1;
direction = ScrollEventDirection.VERTICAL;
break;
}
delta = dirVal * ((direction == ScrollEventDirection.VERTICAL) ? (firstController.compositionHeight * scrollPercent) : (firstController.compositionWidth * scrollPercent));
var blockProgression:String = _activeFlow.computedFormat.blockProgression;
if (scrollByAmount.selectedLabel == "Line")
{
if (blockProgression == BlockProgression.TB && (button == upScroll || button == downScroll)) {
delta = dirVal;
detail = ScrollEventDetail.LINE_UP;
}
if (blockProgression == BlockProgression.RL && (button == leftScroll || button == rightScroll)) {
delta = -dirVal;
detail = ScrollEventDetail.LINE_UP;
}
}
doScroll(detail, position, direction, delta);
updateScrollSettings();
}
}
]]>