Spark list, scroller horizontal ne s'adapte pas à la largeur du texte

Bonjour,
dans un composant spark list, le barre de défilement horizonta s'affiche si le texte est plus large que la taille de la liste, si je modifie ma liste et que le texte est inférieur à la taille de la liste la barre de défilement horizontal devrait disparaître or ce n'est pas le cas, il garde la taille précédente, existe-il un moyen de forcer sa réactualisation.
merci

Bonjour,
dans un composant spark list, le barre de défilement horizonta s'affiche si le texte est plus large que la taille de la liste, si je modifie ma liste et que le texte est inférieur à la taille de la liste la barre de défilement horizontal devrait disparaître or ce n'est pas le cas, il garde la taille précédente, existe-il un moyen de forcer sa réactualisation.
merci

Similar Messages

  • Spark list horizontal scroller doesn't actualize when rows is set lesser than list container

    Hello,
    The size of the Image control is set larger than that of its parent Group  container. By default, the child extends past the boundaries of the parent  container. Rather than allow the child to extend past the boundaries of the  parent container, the Scroller specifies to clip the child to the boundaries and  display scroll bars.
    In the spark list, when I change the list dataProvider and the size of the Image control is set lesser than that of its parent Group  container, the horizontal scroller doesn't actualize.
    thanks.

    <!-- Simple example to demonstrate the Spark List component -->
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="comp()" width="260" height="400">
        <fx:Script>
            <![CDATA[
        import mx.collections.*;
        public var dpArray:Array;
        [Bindable]
        public var dpCol:ArrayCollection;
        public function handleClick():void {
            dpCol.removeAll();
            dpCol.addItem({ label:"spark test" });
            dpCol.addItem({ label:"spark text" });
        public function comp():void {
            dpCol = new ArrayCollection(dpArray);
            dpCol.addItem({ label:"spark list horizontal scroller doesn't actualize when rows is set lesser than list container" });
            dpCol.addItem({ label:"spark test" });
            dpCol.addItem({ label:"spark text" });
             ]]>
        </fx:Script>
        <s:Panel title="List">
            <s:VGroup left="20" right="20" top="20" bottom="20">
                <s:List width="200" id="lis" dataProvider="{dpCol}" height="120"/>
                <s:Button id="button1" label="Click here!" width="100" fontSize="12" click="handleClick();"/>
            </s:VGroup>
        </s:Panel>
    </s:Application>

  • Replace horizontal scroll in a spark list?

    I've gotten myself confused...
    1. I create a new component based on Spark List, "MyList.mxml"
    2. I open it, and in design view I say "create copy of skin"
    3. I open ListSkin1.mxml.
    I want to replace the scroll bar with a custom skinned one. I am not sure where to do this...
    1. I create a new component based on HScrollBar "MyScrollbar.mxml"
    Now what?  Where so I specify in the List component -- or its skin -- do I specify the new scroll bar?

    OK, this is a little crude, but seems to work (and was a lot less complex than I initially thought). My main app looks like this:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/halo">
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            s|List s|Scroller {
                horizontalScrollPolicy: on;
                verticalScrollPolicy: on;
            s|List s|HScrollBar {
                skinClass: ClassReference("TrackThumbOnlyHSBSkin");
        </fx:Style>
        <s:List id="list" width="100" height="100" horizontalCenter="0" verticalCenter="0">
            <s:dataProvider>
                <s:ArrayList>
                    <fx:Object label="The quick brown fox jumps over the lazy dog" />
                    <fx:Object label="One" />
                    <fx:Object label="Two" />
                    <fx:Object label="Three" />
                    <fx:Object label="Four" />
                    <fx:Object label="Five" />
                    <fx:Object label="Six" />
                    <fx:Object label="Seven" />
                    <fx:Object label="Eight" />
                    <fx:Object label="Nine" />
                </s:ArrayList>
            </s:dataProvider>
        </s:List>
    </s:Application>
    And my custom HScrollBar skin, TrackThumbOnlyHSBSkin.mxml, is as follows:
    <?xml version="1.0" encoding="utf-8"?>
    <s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
                 xmlns:s="library://ns.adobe.com/flex/spark"
                 xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
                 minWidth="35" minHeight="15"
                 alpha.disabled="0.5" alpha.inactive="0.5">
        <s:states>
            <s:State name="normal" />
            <s:State name="disabled" />
            <s:State name="inactive" />
        </s:states>
        <fx:Metadata>
            <![CDATA[
            [HostComponent("spark.components.HScrollBar")]
            ]]>
        </fx:Metadata>
        <fx:Script fb:purpose="styling">
            <![CDATA[
                /* Define the skin elements that should not be colorized.
                For scroll bar, the skin itself is colorized but the individual parts are not. */
                static private const exclusions:Array = ["track", "thumb"];
                override public function get colorizeExclusions():Array {
                    return exclusions;
                override protected function initializationComplete():void {
                    useBaseColor = true;
                    super.initializationComplete();
            ]]>
        </fx:Script>
        <!--- Defines the skin class for the HScrollBarSkin's track. The default skin class is HScrollBarTrackSkin. -->
        <s:Button id="track" left="0" right="0" width="54"
                  focusEnabled="false"
                  skinClass="spark.skins.spark.HScrollBarTrackSkin"
                  baseColor="haloGreen"/>
        <!--- Defines the skin class for the HScrollBarSkin's thumb. The default skin class is HScrollBarThumbSkin. -->
        <s:Button id="thumb"
                  focusEnabled="false" visible.inactive="false"
                  skinClass="spark.skins.spark.HScrollBarThumbSkin"
                  baseColor="haloBlue"/>
    </s:SparkSkin>
    So I was wrong. I didnt need a custom List skin, or Scroller skin... just the one custom HScrollBar skin (and presumably a custom VScrollBar skin -- and possibly more skins depending on how custom you want the scrollbar left/right top/bottom buttons and/or thumb/track skins).
    Peter

  • Adding only a horizontal scrollbar to a Spark List

    I have a Spark list which may be wider than the application container.  I want to have a horizontal scrollbar if and only if the content is wider than the screen.
    <s:List id="timeline" itemRenderer="com.thismoment.TimeLineRenderer"
                contentBackgroundAlpha="0" borderVisible="false">
            <s:layout>
                <s:HorizontalLayout clipAndEnableScrolling="true" />
            </s:layout>
        </s:List>
    With this code, I get a vertical scrollbar as well.  I only want horizontal.

    hi,
    In your list create a custom skin, then find the scroller line in your new skin and add verticalScrollPolicy="Off"
        <s:Scroller left="0" top="0" right="0" bottom="0" id="scroller" minViewportInset="1" hasFocusableChildren="false" verticalScrollPolicy="off">
    David

  • Animated Horizontal Spark List

    Hello,
    how could I animate a Horizontal Spark List and enable the Mouse-Wheel for it ?
    I like to scroll with the intervall size of the page, to get started with it I enabled snapping and set the stepsize to thewidth of the itemRenderer/List.
    How to animate this now ?
    http://wensauer.info/flex/AnimatedHorizontalSparkList/ (view source enabled)
    As you can see when you reach the last item and keep scrolling there is some pixels overhead so that you can scroll the content freely.
    How to fix this ?
    Colclusion:
    * how to enable mousewheell for the horizontal scroller (swap function with the vertical?)
    * how to animate a  spark list
    * how to remove pixel overhead
    Any Help is welcome!
    Marc

    Ok,
    I solved some questions myself.
    It is working so far to a certain extend.
    When I scroll to fast with the mouse wheel the auxilary slider gets out of sync with the List.
    Is there a way to only start a new animation once the current is finished ? can I lock it somehow or put them into a queue?
    http://www.wensauer.info/flex/AnimatedHorizontalSparkListII/
    The best way woulkd be that I can use the scrollbar of the scroller, but when I enable snapping, the animation isnt working anymore.
    Idea ? Noone ?

  • How do I select a cell in a multicolum​n list box and use scroll horizontal on th

    From an event structure, how do I select a cell in a multicolumn list box and use scroll horizontal on the front panel at the same time.  I can select a cell from the multicolumn in an event structure, but I cannot move the scroll bar on the front panel when the program is running.
    Solved!
    Go to Solution.

    I'm assuming you're referring to the scrollbar in the multicolumn listbox. What is your code doing when you select a cell? Can you please post your code so we can see the behavior you're describing? It's possible that you're blocking the event structure, as in performing some long operation in the event that's handling the cell selection. In this case the event structure has to wait until the event completes before being able to respond to the next event. You can configure the event to not lock the front panel while waiting for the event to complete.

  • Horizontal grid lines color in a spark List

    Hello,
    How to change horizontal grid lines color in a spark List using css
    Thanks

    Hello,
    How to change horizontal grid lines color in a spark List using css
    Thanks

  • How to smooth scroll a Spark List using the mouse wheel

    I've got my Spark List smooth scrolling nicely if I grab the scrollbar thumb and drag it. But when using the mouse wheel, it's jumping itemrenderer by itemrenderer.
    Is there any way to get this to smooth scroll?  I'm using a List with variableRowHeight = true.
    Thanks.

    This thread demonstrates how to customize mouse wheel scrolling:
    http://forums.adobe.com/message/2783736
    An enhancement was recently added that will allow for customizing the behavior without needing to subclass.  See this bug for the details:
    http://bugs.adobe.com/jira/browse/SDK-26432

  • Need help with navigation within a spark list...

    hey guys, so in my application when you click on a list item, it opens up an image, and along with the image a few buttons are created dynamically...
    the image and the url/labels for the dynamic buttons is provided through an xml/xmlListCollection.
    what i need help with is the url or more specifically when you click on one of these dynamic buttons it needs to navigate me to another part of an list or display a certain set of images that is not in my spark list...
    please let me know if this makes no sence
    the code i have is
    <code>
        [Bindable] private var menuXml:XML;
        [Bindable] private var imgList:XMLListCollection = new XMLListCollection();
        [Bindable] private var navControl:XMLListCollection = new XMLListCollection();
        [Bindable] private var fullList:XMLListCollection = new XMLListCollection();
        private var returnedXml:XMLListCollection = new XMLListCollection();
        private var myXmlSource:XML = new XML();
        //[Bindable] private var xmlReturn:Object;
        private var currImage:int = 0;
        //public var userOpProv:XMLListCollection = new XMLListCollection();
        //private var troubleShootProvider:XMLListCollection = new XMLListCollection();
        private function myXml_resultHandeler(event:ResultEvent):void{
            userOptionProvider.source = event.result.apx32.userOptions.children();
            troubleShootProvider.source = event.result.apx32.troubleShooting.children();
            fullList.source = event.result.apx32.children();
            returnedXml.source = event.result[0].children();
            myXmlSource = event.result[0];
        private function myXml_faultHandler(event:FaultEvent):void{
            Alert.show("Error loading XML");
            Alert.show(event.fault.message);
        private function app_creationComplete(event:FlexEvent):void{
            userOptions.scroller.setStyle("horizontalScrollPolicy", ScrollPolicy.OFF);
            myXml.send();
            //trouble.scroller.setStyle("horizontalScrollPolicy", ScrollPolicy.OFF);
            myXml = new HTTPService();
            myXml.url = "modules/apx32/apx32TroubleshootingXml.xml";
            myXml.resultFormat = "e4x";
            myXml.addEventListener(ResultEvent.RESULT, myXml_resultHandeler);
            myXml.addEventListener(FaultEvent.FAULT, myXml_faultHandler);
            myXml.send();
        private function troubleShootChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = troubleShootProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = troubleShootProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            //var isMultiPage:String = navControl[2]["multiPages"];
            //trace(isMultiPage);
            //        if(isMultiPage){
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
        private function customButtonPressed(event:Event):void{
            if(imgList[currImage].button.@changeTo != ""){
        private function userOptionsChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = userOptionProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = userOptionProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        newButton.addEventListener(MouseEvent.MOUSE_DOWN, customButtonPressed);
                        dynamicButtons.addElement(newButton);
            var isMultiPage:String = navControl[2]["multiPages"];
            if(isMultiPage == "true"){
                if(navControl[2]["next"] == "NEXT STEP"){
                    navContainer.x = 630;
                else{
                    navContainer.x = 640;
                next.label = navControl[2]["next"];
                back.label = navControl[2]["back"];
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
        private function nextClickHandler(event:MouseEvent):void{
            currImage += 1;
            dynamicButtons.removeAllElements();
            if(currImage >= imgList.length-1){
                currImage = imgList.length - 1;
                //next.visible = false;
                next.label = "YOU'RE DONE";
            else
                next.label = navControl[2]["next"];
            back.visible = true;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            definition.source = imgList[currImage].@url;
        private function backClickHandler(event:MouseEvent):void{
            currImage -= 1;
            dynamicButtons.removeAllElements();
            if(currImage == 0){
                back.visible = false;
            next.visible = true;
            next.label = navControl[2]["next"];
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            definition.source = imgList[currImage].@url;
    </code>
    i have attached a copy of the xml that i have right now to this post for reference...
    any help will be greatly appretiated!!! i've been stuck on this problem for the last week and my project is due soon
    again thank you in advance...

    hey david... just nevermind my previous post... I was able to subclass a link button, so i now have two variables that get assigned to a link button,
    one is "tabId" <-- contains the information on which tab to swtich to, and the second is, "changeTo"... this contans the label name which it needs to switch to
    I'm just stuck on how to change my selected item in my tabNavigator/list
    the code i have right now is
        private function customButtonPressed(event:Event):void{
            if(event.currentTarget.tabId == "troubleShooting"){
                for each(var item:Object in troubleShootProvider){
                    if(item.@label == event.currentTarget.changeTo){
        private function userOptionsChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = userOptionProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = userOptionProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:customLinkButton = new customLinkButton();
                        newButton.label = item.@name;
                        newButton.tabId = item.@tab;
                        newButton.changeTo = item.@changeTo;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        newButton.addEventListener(MouseEvent.MOUSE_DOWN, customButtonPressed);
                        dynamicButtons.addElement(newButton);
            var isMultiPage:String = navControl[2]["multiPages"];
            var videoPresent:String = navControl[1]["videoPresent"];
            if(videoPresent == "true"){
                if(isMultiPage != "true"){
                    navContainer.x = 825;
            if(isMultiPage == "true"){
                if(navControl[2]["next"] == "NEXT STEP"){
                    navContainer.x = 630;
                else{
                    navContainer.x = 640;
                next.label = navControl[2]["next"];
                back.label = navControl[2]["back"];
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
    as you know, my xml gets divided into two saperate xmllistcollections one is the userOptionProvider, and the troubleshootingProvider
    as is in the following xml
    <mx:TabNavigator id="tabNav" width="275" tabStyleName="tabStyle" fontWeight="bold" height="400" paddingTop="0"
                             tabWidth="137.5" creationPolicy="all" borderVisible="false">
                <mx:VBox label="USER OPTIONS" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                    <s:List id="userOptions" width="100%" height="100%" itemRenderer="modules.apx32.myComponents.listRenderer"
                            borderVisible="false" contentBackgroundColor="#e9e9e9"
                            change="userOptionsChange(event)">
                        <s:dataProvider>
                            <s:XMLListCollection id="userOptionProvider" />
                        </s:dataProvider>
                    </s:List>
                </mx:VBox>
                <mx:VBox label="TROUBLESHOOTING">
                    <s:List id="trouble" width="100%" height="100%" itemRenderer="modules.apx32.myComponents.listRenderer"
                            borderAlpha="0" borderVisible="false" contentBackgroundColor="#e9e9e9"
                            change="troubleShootChange(event)">
                        <s:dataProvider>
                            <s:XMLListCollection id="troubleShootProvider" />
                        </s:dataProvider>
                    </s:List>
                </mx:VBox>
            </mx:TabNavigator>
    Im having some trouble updating my list... basically change to the troubleshooting tab, and then select the one that i need...
    hopefully that makes sence...

  • [svn:fx-trunk] 10876: Add support for drag-and-drop from Spark List to Spark List.

    Revision: 10876
    Author:   [email protected]
    Date:     2009-10-05 15:20:07 -0700 (Mon, 05 Oct 2009)
    Log Message:
    Add support for drag-and-drop from Spark List to Spark List.
    - List drop related handlers
    - LayoutBase APIs
    - VerticalLayout DND support
    Notes:
    - ListSkin is not final.
    - Drag-scrolling not yet implemented.
    QE notes: Only VerticalLayout works, HorizontalLayout still not implemented.
    Doc notes: None
    Bugs: None
    Reviewer: Deepa
    Tests run: checkintests
    Is noteworthy for integration: No
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/List.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/layouts/VerticalLayout.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutBase.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/ListSkin.mxml
        flex/sdk/trunk/frameworks/spark-manifest.xml
    Added Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/layouts/supportClasses/DropLocation.as

    Whoops, disregard my question - I just read the spec that indicates drag and drop is scheduled for later work.
    David

  • How To Add scrollbar in Spark list which will work on mouse movement ?

    Hi,
    I want to add scrollbar in Spark list which will work on mouse movement, i.e instead scrolling down it will sense mouse position and scroll automatically. I could not find a way to handle this with horizontalLayout.
    I tried hovering on list and setting ensureIndexIsVisible(index) but hovering element index is not present in the Spark List.
    Any idea on this will be highly appreciated.
    Thanks in advance
    Avishek

    Hi,
    I want to add scrollbar in Spark list which will work on mouse movement, i.e instead scrolling down it will sense mouse position and scroll automatically. I could not find a way to handle this with horizontalLayout.
    I tried hovering on list and setting ensureIndexIsVisible(index) but hovering element index is not present in the Spark List.
    Any idea on this will be highly appreciated.
    Thanks in advance
    Avishek

  • My JScrollpane wont scroll horizontally?

    hmmmm...
    As the title says, my JSCrollPane wont scroll horizontally. I've passed a customer "Drawer" object to it.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.ArrayList;
    public class gui extends JFrame{
         Container c;
         JPanel p;
         Drawer d;
         JComboBox box;
         JLabel lab;
         JScrollPane sp=new JScrollPane(p);
         String options[]={"Terminal","Non-Terminal","Repeat","Or"};
         ArrayList list=new ArrayList();
         String lastTerminal="";
         String lastNonTerminal="";
         int x=0;
         int y=350;
         boolean stupid=true;
         int pixelsize=0;
         String orString;
         ArrayList orStringList=new ArrayList();
         ArrayList orList=new ArrayList();
         boolean done=false;
         int count=0;
         int lastx=0;
         int lasty=0;
         public gui(){
              super("Something");
              setSize(900,700);
              c=getContentPane();
              c.setLayout(new BorderLayout(5,5));
              c.setBackground(Color.white);          
              p=new JPanel();
             d=new Drawer();
             box=new JComboBox(options);
             lab=new JLabel("Add:");
            box.addActionListener(new BoxListener());
            box.setOpaque(false);
             p.add(lab);
              p.add(box);
              sp=new JScrollPane(d);
              c.add(sp,BorderLayout.CENTER);
              c.add(p,BorderLayout.SOUTH);
              show();
         public class BoxListener implements ActionListener{
          public void actionPerformed(ActionEvent evt) {
               //if(!stupid){
                if (box.getSelectedIndex()==0)
                     lastTerminal=JOptionPane.showInputDialog("Enter your Terminal name");
                     list.add(new Terminal(lastTerminal,x,y,true));
                     Terminal tt=(Terminal)list.get(list.size()-1);
                     x=x+tt.getStringWidth()+45;
                     repaint();
                if (box.getSelectedIndex()==1)
                       lastNonTerminal=JOptionPane.showInputDialog("Enter your Non-Terminal name");
                     list.add(new Terminal(lastNonTerminal,x,y,false));
                     Terminal tt=(Terminal)list.get(list.size()-1);
                     x=x+tt.getStringWidth()+45;
                     repaint();
             if (box.getSelectedIndex()==3)
                       orStringList.clear();
                       orString=JOptionPane.showInputDialog("Enter your Or, seperate each Or with a |")+"|";
                       StringBuffer sb=new StringBuffer(orString);
                       while(sb.indexOf("|")!=-1)
                            orStringList.add(sb.substring(0,sb.indexOf("|")));
                            sb.delete(0,sb.indexOf("|")+1);
                       int eveny=y;
                        int oddy=y;
                        for(int i=1;i<orStringList.size()+1;i++)
                                 if((i%2)==0)
                                           eveny=eveny+25;
                                           orList.add(new OrTerm((String)orStringList.get(i-1),x+35,eveny,false,x,y,x+130,y));
                                  else
                                            oddy=oddy-25;
                                           orList.add(new OrTerm((String)orStringList.get(i-1),x+35,oddy,false,x,y,x+130,y));
                       OrTerm tt=(OrTerm)orList.get(orList.size()-1);
                     x=x+tt.getStringWidth()+100;
                       repaint();
         public static void main (String args[]) {
              gui app = new gui();
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public class Drawer extends JPanel
              public Drawer()
                   this.setBackground(Color.ORANGE);
         public void paint(Graphics g2)
             super.paint(g2);
             Graphics2D g=(Graphics2D)g2;
              g.setFont(new Font(null,Font.BOLD,15));
              Terminal temp=null;
              OrTerm temp2=null;
              for(int i=0;i<orList.size();i++)
                        temp2=(OrTerm)orList.get(i);
                        pixelsize=SwingUtilities.computeStringWidth(g.getFontMetrics(),temp2.getName());
                        g.drawString(temp2.getName(),temp2.getx(),temp2.gety());
                        g.drawRect(temp2.getx()-4,temp2.gety()-16,pixelsize+7,25);
                        g.drawLine(temp2.getx()-2,temp2.gety()-2,temp2.getx2()-5,temp2.gety2()-2);
                        g.drawLine(temp2.getx()+pixelsize+7,temp2.gety()-2,temp2.getx3(),temp2.gety3());
              for(int i=0;i<list.size();i++)
                   temp=(Terminal)list.get(i);
                   g.drawString(temp.getName(),temp.getx(),temp.gety());
                   pixelsize=SwingUtilities.computeStringWidth(g.getFontMetrics(),temp.getName());
                   if(temp.isTerminal()==true)
                     g.drawOval(temp.getx()-4,temp.gety()-16,pixelsize+7,25);
                   else
                     g.drawRect(temp.getx()-4,temp.gety()-16,pixelsize+7,25);
                   lastx=temp.getx()+pixelsize+7+30;
                   lasty=y-2;
                   //drawing line
                   g.drawLine(temp.getx()+pixelsize+7,y-2,temp.getx()+pixelsize+7+30,y-2); 
                 //drawing little array >
                 g.drawLine(temp.getx()+pixelsize+7+30,y-2,temp.getx()+pixelsize+7+25,y-7);
                  g.drawLine(temp.getx()+pixelsize+7+30,y-2,temp.getx()+pixelsize+7+25,y+5);
    class Terminal {
         private String name;
         private int x2;
         private int y2;
         private boolean terminal;
         public Terminal(String name, int x, int y,boolean boo)
              this.name=name;
              this.x2=x;
              this.y2=y;
              this.terminal=boo;
         public String getName(){return this.name;}
         public int getx(){return this.x2;}
         public int gety(){return this.y2;}
         public int getStringWidth()
              return SwingUtilities.computeStringWidth(Toolkit.getDefaultToolkit().getFontMetrics(new Font(null,Font.BOLD,15)),this.name);
         public boolean isTerminal(){return this.terminal;}
    class OrTerm {
         private String name;
         private int x;
         private int y;
         private int x2;
         private int y2;
         private int x3;
         private int y3;
         private boolean terminal;
         public OrTerm(String name, int x, int y,boolean boo,int x2,int y2,int x3,int y3)
              this.name=name;
              this.x=x;
              this.y=y;
              this.terminal=boo;
              this.x2=x2;
              this.y2=y2;
              this.x3=x3;
              this.y3=y3;          
         public String getName(){return this.name;}
         public int getx(){return this.x;}
         public int gety(){return this.y;}
         public int getx2(){return this.x2;}
         public int gety2(){return this.y2;}
         public int getx3(){return this.x3;}
         public int gety3(){return this.y3;}
         public int getStringWidth()
              return SwingUtilities.computeStringWidth(Toolkit.getDefaultToolkit().getFontMetrics(new Font(null,Font.BOLD,15)),this.name);
         public boolean isTerminal(){return this.terminal;}
         import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.ArrayList;
    public class gui extends JFrame{
         Container c;
         JPanel p;
         Drawer d;
         JComboBox box;
         JLabel lab;
         JScrollPane sp=new JScrollPane(p);
         String options[]={"Terminal","Non-Terminal","Repeat","Or"};
         ArrayList list=new ArrayList();
         String lastTerminal="";
         String lastNonTerminal="";
         int x=0;
         int y=350;
         boolean stupid=true;
         int pixelsize=0;
         String orString;
         ArrayList orStringList=new ArrayList();
         ArrayList orList=new ArrayList();
         boolean done=false;
         int count=0;
         int lastx=0;
         int lasty=0;
         public gui(){
              super("Something");
              setSize(900,700);
              c=getContentPane();
              c.setLayout(new BorderLayout(5,5));
              c.setBackground(Color.white);          
              p=new JPanel();
         d=new Drawer();
         box=new JComboBox(options);
         lab=new JLabel("Add:");
    box.addActionListener(new BoxListener());
    box.setOpaque(false);
         p.add(lab);
              p.add(box);
              sp=new JScrollPane(d);
              c.add(sp,BorderLayout.CENTER);
              c.add(p,BorderLayout.SOUTH);
              show();
         public class BoxListener implements ActionListener{
         public void actionPerformed(ActionEvent evt) {
              //if(!stupid){
              if (box.getSelectedIndex()==0)
         lastTerminal=JOptionPane.showInputDialog("Enter your Terminal name");
         list.add(new Terminal(lastTerminal,x,y,true));
         Terminal tt=(Terminal)list.get(list.size()-1);
         x=x+tt.getStringWidth()+45;
         repaint();
              if (box.getSelectedIndex()==1)
         lastNonTerminal=JOptionPane.showInputDialog("Enter your Non-Terminal name");
         list.add(new Terminal(lastNonTerminal,x,y,false));
         Terminal tt=(Terminal)list.get(list.size()-1);
         x=x+tt.getStringWidth()+45;
         repaint();
    if (box.getSelectedIndex()==3)
              orStringList.clear();
              orString=JOptionPane.showInputDialog("Enter your Or, seperate each Or with a |")+"|";
              StringBuffer sb=new StringBuffer(orString);
              while(sb.indexOf("|")!=-1)
                   orStringList.add(sb.substring(0,sb.indexOf("|")));
                   sb.delete(0,sb.indexOf("|")+1);
              int eveny=y;
                        int oddy=y;
                        for(int i=1;i<orStringList.size()+1;i++)
                        if((i%2)==0)
                                  eveny=eveny+25;
                                  orList.add(new OrTerm((String)orStringList.get(i-1),x+35,eveny,false,x,y,x+130,y));
                                  else
                                            oddy=oddy-25;
                                  orList.add(new OrTerm((String)orStringList.get(i-1),x+35,oddy,false,x,y,x+130,y));
              OrTerm tt=(OrTerm)orList.get(orList.size()-1);
         x=x+tt.getStringWidth()+100;
              repaint();
         public static void main (String args[]) {
              gui app = new gui();
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public class Drawer extends JPanel
              public Drawer()
                   this.setBackground(Color.ORANGE);
    public void paint(Graphics g2)
         super.paint(g2);
         Graphics2D g=(Graphics2D)g2;
              g.setFont(new Font(null,Font.BOLD,15));
         Terminal temp=null;
         OrTerm temp2=null;
              for(int i=0;i<orList.size();i++)
                   temp2=(OrTerm)orList.get(i);
                   pixelsize=SwingUtilities.computeStringWidth(g.getFontMetrics(),temp2.getName());
                   g.drawString(temp2.getName(),temp2.getx(),temp2.gety());
                   g.drawRect(temp2.getx()-4,temp2.gety()-16,pixelsize+7,25);
                   g.drawLine(temp2.getx()-2,temp2.gety()-2,temp2.getx2()-5,temp2.gety2()-2);
                   g.drawLine(temp2.getx()+pixelsize+7,temp2.gety()-2,temp2.getx3(),temp2.gety3());
         for(int i=0;i<list.size();i++)
              temp=(Terminal)list.get(i);
              g.drawString(temp.getName(),temp.getx(),temp.gety());
              pixelsize=SwingUtilities.computeStringWidth(g.getFontMetrics(),temp.getName());
              if(temp.isTerminal()==true)
              g.drawOval(temp.getx()-4,temp.gety()-16,pixelsize+7,25);
              else
              g.drawRect(temp.getx()-4,temp.gety()-16,pixelsize+7,25);
              lastx=temp.getx()+pixelsize+7+30;
              lasty=y-2;
              //drawing line
              g.drawLine(temp.getx()+pixelsize+7,y-2,temp.getx()+pixelsize+7+30,y-2);
         //drawing little array >
         g.drawLine(temp.getx()+pixelsize+7+30,y-2,temp.getx()+pixelsize+7+25,y-7);
         g.drawLine(temp.getx()+pixelsize+7+30,y-2,temp.getx()+pixelsize+7+25,y+5);
    class Terminal {
         private String name;
         private int x2;
         private int y2;
         private boolean terminal;
         public Terminal(String name, int x, int y,boolean boo)
              this.name=name;
              this.x2=x;
              this.y2=y;
              this.terminal=boo;
         public String getName(){return this.name;}
         public int getx(){return this.x2;}
         public int gety(){return this.y2;}
         public int getStringWidth()
              return SwingUtilities.computeStringWidth(Toolkit.getDefaultToolkit().getFontMetrics(new Font(null,Font.BOLD,15)),this.name);
         public boolean isTerminal(){return this.terminal;}
    class OrTerm {
         private String name;
         private int x;
         private int y;
         private int x2;
         private int y2;
         private int x3;
         private int y3;
         private boolean terminal;
         public OrTerm(String name, int x, int y,boolean boo,int x2,int y2,int x3,int y3)
              this.name=name;
              this.x=x;
              this.y=y;
              this.terminal=boo;
              this.x2=x2;
              this.y2=y2;
              this.x3=x3;
              this.y3=y3;          
         public String getName(){return this.name;}
         public int getx(){return this.x;}
         public int gety(){return this.y;}
         public int getx2(){return this.x2;}
         public int gety2(){return this.y2;}
         public int getx3(){return this.x3;}
         public int gety3(){return this.y3;}
         public int getStringWidth()
              return SwingUtilities.computeStringWidth(Toolkit.getDefaultToolkit().getFontMetrics(new Font(null,Font.BOLD,15)),this.name);
         public boolean isTerminal(){return this.terminal;}
         

    Scrollbars will appear when the preferred size of the component is greater than the size of the scroll pane. If you are adding a custom drawn component to the scrollpane then you must set the preferredSize.

  • Spark list filter not working

    I have a spark list with custom itemRenderers and I have a filter on the list.  I run the filter, but at random times the filter doesn't work. I threw in some trace statements and its passing the filter but the screen doesn't show the filters results. It only shows the results of the last filter. I think it has to do with the spark lists itemRenderer resuse.
    Is this a known bug?

    The bug is in TileLayout. 
    If I remove the the TileLayout the list functions as aspected.  Here is a simple example.  Make sure when running the app to follow these instructions.
    1. Run the app (notice the list shows all the items in it)
    2. Click "K"
    3. Click "All"
    4. Look at the Bottom list to see if only two items show even when "ALL" is selected.
    5.Repeat steps 2-4 until you see the bug.
    <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2010/05/12/scrolling-to-a-specific-index-in-a-spark-list-cont rol-in-flex-4/ -->
    <s:Application name="Spark_List_ensureIndexIsVisible_test"
       xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    private var array:Array = ['one', 'otwo', 'othree', 'ofour', 'ofive', 'osix', 'oseven', 'oeight', 'nine', 'nten'];
    private var myAC:ArrayCollection = new ArrayCollection( array );
    private function setAlphaFilter() : void {
    if( myAC ) {
    myAC.filterFunction = alphaFilter;
    myAC.refresh();
    private function alphaFilter( item:Object ) : Boolean {
    var tempStr:String;
    if( String(alphaList.selectedItem.firstName).toLowerCase() == 'all' ) {
    return true;
    if(  item.toLowerCase().charAt(0) == String(alphaList.selectedItem.firstName).toLowerCase() ) { // if something a letter is selected.
    return true;
    return false;
    ]]>
    </fx:Script>
    <s:List id="alphaList" changing="setAlphaFilter()"
    width="100%" top="2" bottom="2" left="2" right="2" borderColor="#7F7F7F" >
    <s:layout>
    <s:HorizontalLayout columnWidth="20" paddingLeft="1" />
    </s:layout>
    <!-- itemRenderer is inline in this sample -->
    <s:itemRenderer>
    <fx:Component>
    <s:ItemRenderer>
    <s:Group top="1">
    <s:Label id="blah" text="{data.firstName}" fontSize="13" bottom="1" top="1" right="1" left="1" />
    </s:Group>
    </s:ItemRenderer>
    </fx:Component>
    </s:itemRenderer>
    <s:dataProvider>
    <s:ArrayList>
    <fx:Object firstName="All" />
    <fx:Object firstName="A"  />
    <fx:Object firstName="B"  />
    <fx:Object firstName="C" />
    <fx:Object firstName="D" />
    <fx:Object firstName="E" />
    <fx:Object firstName="F"  />
    <fx:Object firstName="G"  />
    <fx:Object firstName="H" />
    <fx:Object firstName="I" />
    <fx:Object firstName="J" />
    <fx:Object firstName="K"  />
    <fx:Object firstName="L"  />
    <fx:Object firstName="M" />
    <fx:Object firstName="N" />
    <fx:Object firstName="O" />
    <fx:Object firstName="P"  />
    <fx:Object firstName="Q"  />
    <fx:Object firstName="R" />
    <fx:Object firstName="S" />
    <fx:Object firstName="T" />
    <fx:Object firstName="U"  />
    <fx:Object firstName="V"  />
    <fx:Object firstName="W" />
    <fx:Object firstName="X" />
    <fx:Object firstName="Y" />
    <fx:Object firstName="Z" />
    <fx:Object firstName="1" />
    <fx:Object firstName="2" />
    <fx:Object firstName="3" />
    <fx:Object firstName="4" />
    <fx:Object firstName="5" />
    <fx:Object firstName="6" />
    <fx:Object firstName="7" />
    <fx:Object firstName="8" />
    <fx:Object firstName="9" />
    </s:ArrayList>
    </s:dataProvider>
    </s:List>
    <s:List id="list" width="630" height="100"
    horizontalCenter="0" verticalCenter="0" dataProvider="{myAC}" useVirtualLayout="true" allowMultipleSelection="true">
    <s:layout>
    <s:TileLayout columnWidth="300" rowHeight="50" verticalGap="1" horizontalGap="1" 
      requestedColumnCount="2"  />
    </s:layout>
    </s:List>
    </s:Application>

  • How Do You Populate A Spark List Control With An Array?

    Hello, all,
    Sorry to come accross so frustrated, but how in the name of God do you populate a Spark list control with the data in an array?  You used to be able to do this with the mx:List control, but the guys developing Flex just had to make things more difficult than they need to be!  I am more of a code purist and prefer doing things the way they have been done for decades, but apparently nothing can ever stay simple!
    I simply want to populate a list control with an array and this shouldn't be rocket science!  I found out that I must use a "collection" element, so I decided that an arrayCollection would be best.  However, after searching Adobe's documentation about arrayCollections, I am lost in a black hole of data binding, extra lines of code just to add a new element, the need to sort it, etc...!
    Here is my code:
    var pendingArray:ArrayCollection = new ArrayCollection();
    for ( var i:int = 0 ; i < queue.length ; i++ )
         var item:UserQueueItem = queue[i] as UserQueueItem ;
         if ( item.status == UserQueueItem.STATUS_PENDING )
         pendingArray.addItem({label:item.descriptor.displayName,descriptor:item.descriptor});
    Here is the relevant MXML:
    <s:VGroup>
         <s:List id="knockingList" width="110" height="100"/>              
    </s:VGroup>
    I'm not getting any errors, but the list is not populating.
    I have seen several examples where the arrayCollection is declared and populated in MXML:
            <mx:ArrayCollection id="myAC">
                <!-- Use an fx:Array tag to associate an id with the array. -->
                <fx:Array id="myArray">
                    <fx:Object label="MI" data="Lansing"/>
                    <fx:Object label="MO" data="Jefferson City"/>
                    <fx:Object label="MA" data="Boston"/>
                    etc...
               </fx:Array>
            </mx:ArrayCollection>
    That may be fine for an example, but I think this is a rare situation.  Most of the time I would image that the arrayCollection would be created and populated on the fly in ActionScript!  How can I do this?
    Thanks in advance for any help or advice anyone can give!
    Matt

    In your post it seemed like you were trying to take care of many considerations at once: optimization, design, architecture.  I would suggest you get something up and running and then worry about everything else.
    If I use data binding, then I will probably have to declare the  arrayCollection as a global variable and then I'll have to write 100 or  so extra lines of code to addItem(), removeItem(), sort(), etc...  It  just seems like too much overhead.
    I believe you may have some misconceptions about databinding in general.  You won't have to make it a global variable and you certainly won't need an extra 100 lines of code.  If you did this forum would be a very , very quiet place.
    I don't want to use data binding because the original array is refreshed  often and there is one function called by an event that re-declares the  arrayCollection each time, populates it with the array, and then sets  it as the list's dataprovider.
    That is the beauty of the ArrayCollection, it can handle the updates to its source Array. I don't know if you need to redeclare the ArrayCollection, resetting the source to the new Array allows everyone involved to keep their references so you don't have to worry about any "spooky" stuff going on.

  • How to search XML data from a HTTPMultiService and display the result on the Spark List

    Hello all,
    I am totally new to Flash Builder and Actionscript and hope someone might be able to help me out. I basically create a mobile app with a single view. The view has a TextInput as a search box and a search button. I conntected a Data/Service using a local XML file and bind the Data to a Spark List. Innitally the List will show nothing until the user enter the search term and hit the button. The List suppose to show the XML data that match the search term.
    Now is my problem. I cannot make the List to show the data that match the search text. The List just shows ALL the data.
    Here are my MXML code:
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:shopping="services.shopping.*"
            title="Search">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
                protected function button1_clickHandler(event:MouseEvent):void
                    navigator.popView();
                protected function list_creationCompleteHandler(event:FlexEvent):void
                    getDataResult.token = shopping.getData();
                protected function seach_clickHandler(event:MouseEvent):void
                    getDataResult.token = shopping.getSearchData(searchTxt.text);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <s:CallResponder id="getDataResult"/>
            <shopping:Shopping id="shopping"/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:actionContent>
            <s:Button height="79" label="Back" click="button1_clickHandler(event)"/>
        </s:actionContent>
        <s:List id="list" left="0" right="0" top="111" bottom="0"
                creationComplete="list_creationCompleteHandler(event)" labelField="english">
            <s:AsyncListView list="{getDataResult.lastResult}"/>
        </s:List>
        <s:TextInput id="searchTxt" x="80" y="34" width="250" height="49" enabled="true"
                     prompt="search..."/>
        <s:Button id="search" x="338" y="35" width="72" height="49" label="s"
                  click="seach_clickHandler(event)"/>
    </s:View>
    Here is the _Super_Shopping.as file:
    * This is a generated class and is not intended for modification.  To customize behavior
    * of this service wrapper you may modify the generated sub-class of this class - Shopping.as.
    package services.shopping
    import com.adobe.fiber.core.model_internal;
    import com.adobe.fiber.services.wrapper.HTTPServiceWrapper;
    import com.adobe.serializers.xml.XMLSerializationFilter;
    import mx.rpc.AbstractOperation;
    import mx.rpc.AsyncToken;
    import mx.rpc.http.HTTPMultiService;
    import mx.rpc.http.Operation;
    import valueObjects.Shop;
    [ExcludeClass]
    internal class _Super_Shopping extends com.adobe.fiber.services.wrapper.HTTPServiceWrapper
        private static var serializer0:XMLSerializationFilter = new XMLSerializationFilter();
        // Constructor
        public function _Super_Shopping()
            // initialize service control
            _serviceControl = new mx.rpc.http.HTTPMultiService();
             var operations:Array = new Array();
             var operation:mx.rpc.http.Operation;
             var argsArray:Array;
             operation = new mx.rpc.http.Operation(null, "getData");
             operation.url = "assets/data/shopping.xml";
             operation.method = "GET";
             operation.serializationFilter = serializer0;
             operation.properties = new Object();
             operation.properties["xPath"] = "/::shop";
             operation.resultElementType = valueObjects.Shop;
             operations.push(operation);
             operation = new mx.rpc.http.Operation(null, "getSearchData");
             operation.url = "assets/data/shopping.xml";
             operation.method = "GET";
             operation.resultFormat = "text";
             argsArray = new Array("item");
             operation.argumentNames = argsArray;
             operation.properties = new Object();
             operation.properties["xPath"] = "/::shop";
             operation.resultElementType = valueObjects.Shop;
             operations.push(operation);
             _serviceControl.operationList = operations;
             preInitializeService();
             model_internal::initialize();
        //init initialization routine here, child class to override
        protected function preInitializeService():void
          * This method is a generated wrapper used to call the 'getData' operation. It returns an mx.rpc.AsyncToken whose
          * result property will be populated with the result of the operation when the server response is received.
          * To use this result from MXML code, define a CallResponder component and assign its token property to this method's return value.
          * You can then bind to CallResponder.lastResult or listen for the CallResponder.result or fault events.
          * @see mx.rpc.AsyncToken
          * @see mx.rpc.CallResponder
          * @return an mx.rpc.AsyncToken whose result property will be populated with the result of the operation when the server response is received.
        public function getData() : mx.rpc.AsyncToken
            var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("getData");
            var _internal_token:mx.rpc.AsyncToken = _internal_operation.send() ;
            return _internal_token;
        public function getSearchData(item:String) : mx.rpc.AsyncToken
            var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("getSearchData");
            var _internal_token:mx.rpc.AsyncToken = _internal_operation.send(item);
            return _internal_token;
    The getSearchData() supposed to return XML data that match the search text, but it doesn't. Can anyoen help?
    Thank you!

    Hi,
    are you able to change dynamically the  operation.url = "assets/data/shopping.xml";?
    i need to do that based on the users input.
    Thanks in advance,

Maybe you are looking for