----- Original Message ----- 
  From: Paul Andrews 
  To: [email protected] 
  Sent: Thursday, September 25, 2008 2:45 AM
  Subject: Re: [flexcoders] Manually scroll a list component


  <?xml version="1.0"?>

  <!-- dpcontrols/TileListDataProvider.mxml -->

  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 

  initialize="initData();" >

  <mx:Script>

  <![CDATA[

  import mx.controls.Button;

  import mx.collections.*;

  private var listArray:Array=[

  {label: "item0", data: 0},{label: "item1", data: 1},

  {label: "item2", data: 2},{label: "item3", data: 3},

  {label: "item4", data: 4},{label: "item5", data: 5},

  {label: "item6", data: 6},{label: "item7", data: 7},

  {label: "item8", data: 8}];

  [Bindable]

  public var TileListdp:ArrayCollection;


  private function initData():void {

  TileListdp = new ArrayCollection(listArray);

  }


  private function forward():void {

  tl.selectedIndex += 1;

  }

  ]]>

  </mx:Script>

  <mx:Button label=">" click="forward()" />


  <mx:HorizontalList id="tl" dataProvider="{TileListdp}" width="500"  
horizontalScrollPolicy="off"

  itemRenderer="mx.controls.Button" />

  </mx:Application>

    ----- Original Message ----- 
    From: Mike Pearce 
    To: [email protected] 
    Sent: Thursday, September 25, 2008 2:22 AM
    Subject: [flexcoders] Manually scroll a list component


    Hi list,

     

    Been bashing away trying to remove the scrollbar from a HorizontalList so I 
can instead use just a forward and back button.

     

    Not having a lot of luck.

     

    Has anyone done this before? 

     

    I've extended the HorizontalList class in the hope of using some of the 
protected methods like scrollHorizontally() but I seem to be wasting a lot of 
time.

     

    Any help much appreciated.

     

    Cheers,

    Mike



Forgot to scroll and make the width smaller than the number of buttons.



Just to clarify:  the HorizontalList selectedIndex attribute can be 
incremented/decremented by the forward back button to change the selection, the 
scrollToIndex method will make sure that the selected index is visible; 
horizontalScrollPolicy="off" removes the scroll bar.



Better example below..



<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 

initialize="initData();" >

<mx:Script>

<![CDATA[

import mx.controls.Button;

import mx.collections.*;

private var listArray:Array=[

{label: "item0", data: 0},{label: "item1", data: 1},

{label: "item2", data: 2},{label: "item3", data: 3},

{label: "item4", data: 4},{label: "item5", data: 5},

{label: "item6", data: 6},{label: "item7", data: 7},

{label: "item8", data: 8}];

[Bindable]

public var TileListdp:ArrayCollection;


private function initData():void {

TileListdp = new ArrayCollection(listArray);

}


private function forward():void {

hl.selectedIndex += 1;

hl.scrollToIndex(hl.selectedIndex);

}


private function back():void {

hl.selectedIndex -= 1;

hl.scrollToIndex(hl.selectedIndex);

}

]]>

</mx:Script>

<mx:Button label="forward" click="forward()" />

<mx:Button label="back" click="back()" />


<mx:HorizontalList id="hl" dataProvider="{TileListdp}" width="100" 
maxWidth="1000" horizontalScrollPolicy="off"

itemRenderer="mx.controls.Button" />

</mx:Application>






Reply via email to