Hi,
I have created a horizontal scrollbar and would like it to target my already existing sprite of dynamic images (Class Coverflow). For some strange strange reason when I use the code below, my stage displays my dynamic set of images inside a white container with a scrollbar attached. Interaction with the set of images has been limited and my scrollbar scrolls up and down without anything happen to the images inside the container.
package {
import fl.containers.ScrollPane;
import fl.events.ScrollEvent;
import fl.controls.ScrollBarDirection;
import flash.display.Sprite;
import fl.controls.ScrollBarDirection;
public class ScrollPaneExample extends Sprite
{
private var sb: ScrollPane = new ScrollPane();
private var myCovers: CoverFlow;
public function ScrollPaneExample(covers: CoverFlow): void
{
myCovers = covers;
createScrollPane();
}
private function createScrollPane() : void
{
sb = new ScrollPane();
// _______________________________________________________________________________ ________Scrollbar properties
sb.source = myCovers;
sb.verticalScrollPolicy = "false";
// sb.horizontalScrollBar = "true"; // RETURNS AN ERROR! But already covered below
sb.horizontalLineScrollSize = 120;
sb.scrollDrag = true;
sb.move(14, 35);
// sb.direction = ScrollBarDirection.HORIZONTAL; // RETURNS AN ERROR!But already covered below
sb.width = 378; // Length of scrollbar // 978
sb.height = 286; // Height of scrollbar //26
// sb.scaleY = 300; // Doesnt work //300
addChild(sb);
sb.refreshPane()
}
public function scrollHandler(event:ScrollEvent): void
{
switch (event.direction)
{
case ScrollBarDirection.HORIZONTAL:
// Turn on to make sure that the scrollbar is on even when there is no content.
trace("horizontal scroll", event.position, "on", event.currentTarget.maxHorizontalScrollPosition);
break;
case ScrollBarDirection.VERTICAL:
trace("vertical scroll", event.position, "off", event.currentTarget.maxVerticalScrollPosition);
break;
}
}
}
}
My CoverFlow class looks like this:
public class CoverFlow extends Sprite {
public var covers : Vector.<DisplayObject>;
private var coverRotationY : Number = 60;
// Original distance between covers was 200
private var coverDistance : Number = 150;
// Original zoom on images in background
private var coverZ : Number = 250; //Not much difference compared to original 300
// Original zoom on selected image in foreground (value 0 = original pix)
private var selectedCoverZ : Number = .0;
private var tweenDuration : Number = .6;
private var easing : Function = Strong.easeOut;
public function CoverFlow(covers : Vector.<DisplayObject>)
{
this.covers = covers;
create();
show(2);
addEventListener(MouseEvent.CLICK, onClick);
}
//____________________________________________________________________________Create CoverFlow
private function create(): void
{
for(var i : Number = 0; i < covers.length; i++)
{
var cover : DisplayObject = covers*;
cover.rotationY = coverRotationY;
cover.x = i * coverDistance;
// cover.height = 100; //TRY
addChildAt(cover, 0);
}
}
//____________________________________________________________________________CoverFlow Tweening
private function show(id : uint) : void // e : Event
{
for (var i : Number = 0;i < covers.length; i++)
{
var cover : DisplayObject = covers*;
// Tried putting if i == id as last statment to stop website coming up automatically but it still does since it then loops through again.
if (i < id)
{
setChildIndex(cover, i);
TweenLite.to(cover, tweenDuration, {x: (id - i + 1) * -coverDistance, z: coverZ, rotationY: -coverRotationY, ease:easing });
} else if (i > id)
{
setChildIndex(cover, covers.length - 1 - i);
TweenLite.to(cover, tweenDuration, {x: ((i - id + 1) * coverDistance), z: coverZ, rotationY: coverRotationY, ease:easing });
} else if(i == id)
{
setChildIndex(cover, covers.length - 1);
TweenLite.to(cover, tweenDuration, {x: 0, z: selectedCoverZ, rotationY: 0, ease:easing });
}
}
}
(...)