Custom dragIndicator on Spark List Control

I have a Spark List Control that is displaying a tilelayout of dynamically imported Images.  Basically, a bunch of thumbnail Images that are displayed in a tile layout.  I have drag drop enabled so that I can reorder these thumbnails and everything is working great except for one thing, the dragIndicator.  In my itemrenderer, I have the Image included in the "dragging" state, but the image is not showing in the dragIndicator.  I am basically just getting a semi-transparent square as my dragIndicator, but I want to be able to actually drag my thumbnail.  Any ideas how to do this?
Here is my List:
<s:List id="ImageList1" x="77" y="95" width="858" height="412" dataProvider="{imageAC}"
     itemRenderer="renderers.ImageACSmallItemRenderer" contentBackgroundColor="0x000000"
     borderVisible="false" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"
     allowMultipleSelection="true" skinClass="skins.General.ListSkin" focusAlpha="0" mouseMove="getImageProxy(event)">
     <s:layout>
          <s:TileLayout columnWidth="76" rowHeight="76" horizontalAlign="center" verticalAlign="middle"
                 horizontalGap="8" verticalGap="8"/>
     </s:layout>
</s:List>
Here is my Itemrenderer:
<fx:Script>
     <![CDATA[
          import mx.utils.ObjectProxy;
          [Bindable]
          public var dataProxy:ObjectProxy;
          private function init():void {
               dataProxy = new ObjectProxy(data);
     ]]>
</fx:Script>
     <s:states>
          <s:State name="normal" />
          <s:State name="hovered" />
          <s:State name="selected" />
          <s:State name="dragging" />
     </s:states>
     <mx:Image source="{dataProxy.pathSmall}" horizontalCenter="0" verticalCenter="0" includeIn="normal, hovered, selected, dragging"/>
</s:ItemRenderer>
Thanks for any insight!

Hi Evtim,
Earlier this summer, you helped me to create an itemRenderer that would allow me to drag photos in a list with a grid layout so that I could re-order them, and the dragIndicator would remain the photo instead of a empty box.  We accomplished this by using the contentCache feature with the Spark BitmapImage.  Now when I drag my photos, they remain photos even while being dragged.  Your very elegant solution ended up looking like this:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                                        xmlns:s="library://ns.adobe.com/flex/spark"
                                        xmlns:mx="library://ns.adobe.com/flex/mx"
                                        width="76" height="76" focusEnabled="false">
          <fx:Script>
                    <![CDATA[
                              import spark.core.ContentCache;
                              static private const contentCache:ContentCache = new ContentCache();
                    ]]>
          </fx:Script>
          <s:states>
                    <s:State name="normal" />
                    <s:State name="hovered" />
                    <s:State name="selected" />
                    <s:State name="dragging" />
          </s:states>
          <s:BitmapImage source="{data.pathSmall}" width="70" height="70" contentLoader="{contentCache}"
                                            horizontalCenter="0" verticalCenter="0" alpha.dragging="2" includeIn="normal, hovered, selected, dragging"/>
</s:ItemRenderer>
Now I have another little interesting challenge with this itemRenderer.  I don't want to bore you with details, but the situation is that I will no longer be loading thumbnails that are 70x70 pixels in size, but I will be loading photos with various dimensions that have to be displayed as a 70x70 pixel thumbnail.  So I am going to create a Group that is 70x70 pixels, turn on the clipAndEnableScrolling for the Group, and then place the photos within the Group so that they essentially get cropped.  The images that I import will have to be resized to either 70 pixels wide or 70 pixels high depending on what is the larger dimension of the of the image, and then placed inside the Group so that I get a perfect center-crop of the images.
So to summarize, I need to load the photos using a loader.  Then I can figure out with the height and width of the photos is.  Then I can scale the photo so that the smaller dimension is 70 pixels, and then I can place it in the Group.  But to do all of this, I can no longer do it in MXML but have to do it in ActionScript... and thus my dilema.  I can't figure out how to use the contentCache properly in ActionScript so that the images stay images when dragged.  Here is what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                                        xmlns:s="library://ns.adobe.com/flex/spark"
                                        xmlns:mx="library://ns.adobe.com/flex/mx"
                                        width="76" height="76" focusEnabled="false" dataChange="init(event)">
          <fx:Script>
                    <![CDATA[
                              import mx.core.FlexGlobals;
                              import mx.events.FlexEvent;
                              import spark.core.ContentCache; 
                              private var contentCache:ContentCache = new ContentCache();
                              private var imageLoader:Loader = new Loader();
                              private var bitmapImg:BitmapImage = new BitmapImage();
                              private var widthHolder:int;
                              private var heightHolder:int;
                              protected function init(event:FlexEvent):void {
                                        var request:URLRequest = new URLRequest(FlexGlobals.topLevelApplication.imageAC[this.itemIndex].pathSmall);
                                        imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, createVisuals);
                                        imageLoader.load(request);
                              private function createVisuals(event:Event):void{
                                        bitmapImg.source = Bitmap(imageLoader.content);
                                        bitmapImg.horizontalCenter = 0;
                                        bitmapImg.verticalCenter = 0;
                                        bitmapImg.smooth = true;
                                        bitmapImg.smoothingQuality = "high";
                                        widthHolder = imageLoader.width;
                                        heightHolder = imageLoader.height;
                                        if (widthHolder > heightHolder) {
                                                  bitmapImg.width = int(Math.round(70*widthHolder/heightHolder));
                                                  bitmapImg.height = 70;
                                        else {
                                                  bitmapImg.width = 70;
                                                  bitmapImg.height = int(Math.round(70*heightHolder/widthHolder));
                                        imageGroup.addElement(bitmapImg);
                    ]]>
          </fx:Script>
          <s:states>
                    <s:State name="normal" />
                    <s:State name="hovered" />
                    <s:State name="selected" />
                    <s:State name="dragging"/>
          </s:states>
          <s:Group id="imageGroup" width="70" height="70" horizontalCenter="0" verticalCenter="0" clipAndEnableScrolling="true"/>
</s:ItemRenderer>
So when there is a dataChange in my List, the init() function gets called to load the image.  When the load is complete, the createVisuals() method resizes the image and places it in the Group. Everything is working as expected.  The images get resized, centered and cropped within the group, and smoothed out so that they look nice.  But now when I drag them, I get an empty box while dragging.  I am unsure of how to tie in the contentCache with my bitmapImage object so that it will stay an image while being dragged using actionScript.  I don't know if it is as simple as setting the contentLoader property for the bitmapImage object, or if it is more complicated and I need to set the image source for the "dragging" state.  Could you possibly give me some insight as to how to make this happen in ActionScript?
Thanks for any insight!
Bill

Similar Messages

  • 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 handle multiple selection in the Spark List control with checkbox as itemrenderer?

    Hi All,
    I am using checkbox as an ItemRenderer in spark list.
    I have a query.
    how to handle multiple selection in the Spark List control with checkbox as itemrenderer?
    how to retrieve the selected item label?
    Thank you in advance.

    Hi there, I'll tweak your code a little bit to something like this:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical">
        <mx:Script>
            <![CDATA[
                 import mx.events.ListEvent;
                 import mx.controls.CheckBox;
               [Bindable]
               private var mySelectedIndexes:ArrayCollection=new ArrayCollection();
                private function onChange(e:ListEvent):void
                   if(CheckBox(e.itemRenderer).selected){
                             mySelectedIndexes.addItem(e.rowIndex);
                   }else{
                                  mySelectedIndexes.removeItemAt(mySelectedIndexes.getItemIndex(e.rowIndex));     
                   chkList.selectedIndices=mySelectedIndexes.toArray();
            ]]>
        </mx:Script>
    <mx:ArrayCollection id="collection">
            <mx:Object label="Test A"/>
            <mx:Object label="Test B"/>
            <mx:Object label="Test C"/>
            <mx:Object label="Test D"/>
            <mx:Object label="Test E"/>
            <mx:Object label="Test F"/>
            <mx:Object label="Test G"/>
        </mx:ArrayCollection>
    <mx:List id="chkList" dataProvider="{collection}" itemRenderer="mx.controls.CheckBox"  itemClick="onChange(event);" allowMultipleSelection="true"/>
    </mx:Application>

  • Spark.List Control: right order in selectedItems

    Hi there,
    How can I get the right order from the selectedItemsArray?
    The docs say:
    "These Vectors contain a list of the selected indices and selected data items in the reverse order in which they were selected. That means the first element in each Vector corresponds to the last item selected."
    But this is not correct. If you have a look in the example "Handling multiple selection in the Spark List control" at the end of
    http://help.adobe.com/en_US/flex/using/WSc2368ca491e3ff923c946c5112135c8ee9e-7fff.html
    you will see, that the order is switching around at every click you make to select an Item in the list.
    Indeed the last selected item is the first item in the array, but the order of the other items is not forseeable...
    My Problem:
    I'm using a list control as an itemeditor in a datagrid. (BTW: Is there a way to use dropshadow on the control?)
    The selectedItems are written to Database as a string in form of "firstselection : secondSelection : thirdSelection".
    I also already tried to push the last selectedItem in an array on every change event and join this to a string at focusOut.
    But that seems to be to late, because the datagridColums editorDataFiled doesn't take the the new values.
    Maybe there are other events , which would be better to use?
    Besides how to handle the prevoiuos selectedItems, which comes already from the db. The best would be, if they are already in the right order at the beginning of that array respectivelythe string. "prevSelectedItem1 : prevSelectedItem2 : newSelectedItem1 ..."
    Another solution would be to have at least the first selectedItem to be the first Item in the string to be written to the db whether is already selected at the editbeginnig or complete new selections are made.
    I hope its understandable, because I'm from Germany
    Every help is welcome!
    Thanks, Kalle!
                <mx:DataGridColumn headerText="Fliesenart" dataField="prd_art" resizable="false" width="300" editorDataField="artLiSelected"  >
                    <mx:itemEditor >
                        <fx:Component>
                            <s:MXDataGridItemRenderer height="22" >
                                <fx:Script><![CDATA[
                                    import mx.collections.ArrayCollection;
                                    import mx.events.FlexEvent;
                                    import spark.events.IndexChangeEvent;
                                    [Bindable]
                                    public var artLiSelected:String;
                                    [Bindable]
                                    public var artTempArr:Array = new Array();
                                    public var artNewTempArr:Array = new Array();
                                    protected function artLi_creationCompleteHandler(artStr:String):void
                                        artLiSelected = artStr;
                                        artTempArr = artStr.split(" : ");
                                        var artTempVec:Vector.<Object> = new Vector.<Object>();
                                        for each (var art:Object in artTempArr) {
                                            artTempVec.push(art);
                                        artLi.selectedItems = artTempVec;
                                    protected function dataCollector():void {
                                        artNewTempArr.push(artLi.selectedItems[0]);
                                        //artLiSelected = artLi.selectedItems.join(" : ");
                                        trace ("change");
                                    protected function dataSubmitter ():void {
                                        artLiSelected = artNewTempArr.join(" : ");
                                        trace ("focusOut");
                                ]]></fx:Script>
                                <s:List id="artLi" height="300" top="5" left="5" right="5"
                                        dataProvider="{outerDocument.artNamesArr}"
                                        change="dataCollector()"
                                        focusOut="dataSubmitter()"
                                        requireSelection="true"
                                         creationComplete="artLi_creationCompleteHandler(data.prd_art)"
                                        allowMultipleSelection="true"
                                        />
                            </s:MXDataGridItemRenderer>
                        </fx:Component>
                    </mx:itemEditor>
                </mx:DataGridColumn>

    Create your own list which must extend from spark.List and then override the function calculateSelectedIndices.
    Then you can do 2 things depending on how you want the order in the selectedItems:
    1. Change all the interval.splice to interval.push (now you have the normal order)
    2. Change the "for (i = 0; i < selectedIndices.length; i++)" to "for (i = selectedIndices.length -1; i > -1; i--)" (then you have a reversed order)

  • Create custom scrollbar for Spark Datagrid

    I had a custom scroll bar for a MX datagrid.  But recently I got the new Flash Builder 4.5 and it said to use the Spark Datagrid component instead.  So I changed everything to Spark, but now I can't find any info on customizing the scroll bar.  Is this possible?  Should I go back to mx?
    According to the documentation in Flash Builder:
    "The Spark DataGrid control provides the following features:
    - Custom skins to control all aspects of the appearance of the DataGrid control"
    So I'm hoping it's possible but I can't find any info either way.

    Thanks.  I'm not sure exactly how I did it, but I started with this document in Flash Builder Help:
    "Setting a custom horizontal scroll bar skin on a Spark List control in Flex 4"
    I copied the code and changed "s|List" to "s|Datagrid", modified it accordingly for a vertical scroll bar, and I deleted references to "base color" so that it would compile.   Then, I copied in VScrollBarTrackSkin.mxml and VScrollBarThumbSkin.mxml from the Flash Builder directory: Adobe Flash Builder 4.5\sdks\4.5.1\samples\themes\zen\src\zen\skins.  And I removed the references to the swf files so that it would compile.  Then I embedded my own png images, e.g.: source.up="@Embed(source='/images/thumb.png')". And I got a scrollbar!
    Only problem is the example does not have up and down controls.  But I figured this out from looking at the zen skins (VScrollBarSkin / HScrollBarSkin) and copying in the code for the up and down buttons as well.  Now it's working pretty good.
    [I did not use any of the Flash Builder wizards/GUI to create the skins or files.  I just created the files individually (as in File - New - File).  Perhaps there's a better way to do it, but this worked for me.]
    I'm not sure why you suggested looking at "ScrollerSkin".  This didn't lead me anywhere, though perhaps I was not clear in my question.  But I greatly appreciate your answer, for saying that this is possible, otherwise I would have given up!

  • DataTipFields in Spark Lists?

    It doesn't seem like Spark's List controls are fully implemented;  at the very least dataTips and dataTipFields aren't.  This Halo code works:
    <mx:List id="courseCatalog" dataProvider="{getAllCoursesResult.lastResult}" labelField="title"  showDataTips="true" dataTipField="slug" ></mx:List>
    but the Spark version:
    <s:List id="courseCatalog" dataProvider="{getAllCoursesResult.lastResult}" labelField="title"  showDataTips="true" dataTipField="slug" ></s:List>
    yields these errors.
    Cannot resolve attribute 'dataTipField' for component type spark.components.List.   
    Cannot resolve attribute 'showDataTips' for component type spark.components.List.
    Is this a known issue?
    --Mike Jennings

    Correct, the mx:List and s:List components are two separate components and don't always have the exact same APIs. Most of the time the same functionality exists in both controls, but they may have slightly different names. I believe the latest Flex 4/ActionScript 3.0 Language Reference is posted at http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/ and should list which properties/methods/styles are supported by each component.
    As for your dataTip question, this may work for you: http://blog.flexexamples.com/2009/08/15/creating-data-tips-on-a-spark-list-control-in-flex -4/
    Not 100% certain about the variable row height, but I can take a look.
    Peter

  • 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,

  • Embed Font in a List Control

    I have no problem embeding fonts to be used in dynamic text
    but I cannot get my style to apply to a list control using AS3.
    My style code is:
    import fl.managers.StyleManager;
    var menuStyle:TextFormat = new TextFormat();
    menuStyle.color = 0xFFFFFF;
    menuStyle.size = 20;
    menuStyle.font = new CKTerzini().fontName;
    menuStyle.letterSpacing = 1;
    menuStyle.align = "center";
    StyleManager.setComponentStyle(List, "textFormat",
    menuStyle);
    My list control code is:
    my_list.setStyle("embedFonts", true);
    //my_list.setStyle("textFormat", menuStyle); DOES NOT WORK
    my_list.setRendererStyle("textFormat", menuStyle);
    I also have the font added to the library and properly
    linked. (Class name set to CKTerzini).
    This code works fine with the font on the system but not on a
    computer without the font.
    I have tested that the font is embed in the SWF by using the
    style on dynamic text and it works fine.
    Any suggestions would be greatly welcomed...
    Robert Pritchard
    Nerds Software

    Can you post the code for your list, renderer and custom control?

  • Spark List Itemrenderer items outside of List

    I have a spark list and i want some of the items in it to appear out side of the list depending on the users interaction.
    Is there a way to make items of an item renderer appear outsid of the LIst container?
    When i use basic layout on the lsit and explicitly set the x and y, they appear behind the list.
    Thanks.

    Hi jmandawg,
    My ListRenderer.mxml may be what you want as follows,
    <?xml version="1.0" encoding="utf-8"?>
    <s:ItemRenderer 
    xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="
    library://ns.adobe.com/flex/spark" xmlns:mx="
    library://ns.adobe.com/flex/mx" hide="mOut(
    null)" mouseMove="mOut(event)" mouseOut="mOutValueItem(event)"mouseDownOutside="mOut(event)" creationComplete="inited()"
    autoDrawBackground="
    true">
    <fx:Script>
    <![CDATA[
    import mx.controls.TextInput; 
    import mx.managers.PopUpManager; 
    import mx.utils.StringUtil; 
    import flash.text.TextLineMetrics; 
    public var mouseOnPopup:Boolean = false;  
    public var vi:mx.controls.TextInput; 
    private function inited():void {vi =
    new mx.controls.TextInput();vi.editable=
    false;vi.addEventListener(MouseEvent.MOUSE_OUT, mOut);
    vi.addEventListener(MouseEvent.ROLL_OUT, mOut);
    vi.addEventListener(MouseEvent.MOUSE_OVER, mOverPopup);
    private function mOut(event:MouseEvent):void { 
    if ( vi.isPopUp ) {PopUpManager.removePopUp(vi)
    mouseOnPopup =
    false;}
    private function mOverPopup(event:MouseEvent):void {mouseOnPopup =
    true;}
    private function mOutValueItem(event:MouseEvent):void { 
    if ( vi.isPopUp && !mouseOnPopup) {PopUpManager.removePopUp(vi)
    private function mOver(event:MouseEvent):void { 
    var txt:String = itemValue.texttxt = StringUtil.trim(txt);
    if(txt.length<5) return; 
    if(!vi.isPopUp) {PopUpManager.addPopUp(vi,
    this.parent)vi.text=txt;
    vi.setStyle(
    'fontSize',18); 
    var txtMetrics:TextLineMetrics = vi.measureText(vi.text);vi.width=txtMetrics.width*1.2
    vi.height=itemValue.height*1.4
    var p:Point = itemValue.localToGlobal(new Point(itemValue.x, itemValue.y));vi.x=p.x;
    vi.y=p.y-10;
    ]]>
    </fx:Script>
    <s:TextInput id="itemValue" text="{data.value}" width="200" mouseOver="mOver(event)" mouseOut="mOutValueItem(event)" mouseMove="mOut(event)" editable="false"/> 
    </s:ItemRenderer>
    You may test it with the following in your main.mxml
    Bindable] 
    private var detailAC:ArrayCollection = new ArrayCollection([{value:"nteDevice.device"},{value:
    "nteDevice.deviceTypenteDevice.loopbackIpAddr"},{value:
    "nteDevice.ipAddressnteDevice.loopbackIpAddr"},{value:
    "nteDevice.loopbackIpAddrnteDevice.loopbackIpAddr"}, {value:
    "nteDevice.release"},{value:
    "nteDevice.releasenteDevice.loopbackIpAddr"},{value:
    "nteDevice.clli"},{value:
    "nteDevice.provisionStatus"}]);
     <s:List id="lst" itemRenderer="com.att.ntscp.view.component.ListRenderer" dataProvider="{detailAC}" width="200" height="200"/>
    Is it a little bit trick?
    Jeffrey

  • Wrap long lines in a Spark List component?

    I have a Spark List. 
    The text for each entry is on one line, and is too long to fit.
    Can I get it to break to as many lines as needed without a custom item renderer?

    If you define an explicit width on the SimpleText in the DefaultItemRenderer you can get this behavior.
    Here is an example of this using an inline ItemRenderer:
    <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">
        <s:List width="50" height="200">
            <s:ArrayList>
                <fx:String>a</fx:String>
                <fx:String>b</fx:String>
                <fx:String>c c c c c c c c c c c c</fx:String>
                <fx:String>d</fx:String>
                <fx:String>e</fx:String>
            </s:ArrayList>
            <!-- here we define a custom item renderer inline (copied and modified from DefaultItemRenderer.mxml) -->
            <s:itemRenderer>
                <fx:Component>
                    <s:ItemRenderer focusEnabled="false">
                        <fx:Script>
                            <![CDATA[
                                override public function set label(value:String):void
                                    super.label = value;
                                    labelDisplay.text = label;
                            ]]>
                        </fx:Script>
                        <s:states>
                            <s:State name="normal" />           
                            <s:State name="hovered" />
                            <s:State name="selected" />
                            <s:State name="normalAndShowsCaret"/>
                            <s:State name="hoveredAndShowsCaret"/>
                            <s:State name="selectedAndShowsCaret"/>
                        </s:states>
                        <s:Rect left="0" right="0" top="0" bottom="0">
                            <s:stroke.normalAndShowsCaret>
                                <s:SolidColorStroke
                                    color="{selectionColor}"
                                    weight="1"/>
                            </s:stroke.normalAndShowsCaret>
                            <s:stroke.hoveredAndShowsCaret>
                                <s:SolidColorStroke
                                    color="{selectionColor}"
                                    weight="1"/>
                            </s:stroke.hoveredAndShowsCaret>
                            <s:stroke.selectedAndShowsCaret>
                                <s:SolidColorStroke
                                    color="{selectionColor}"
                                    weight="1"/>
                            </s:stroke.selectedAndShowsCaret>
                            <s:fill>
                                <s:SolidColor
                                    color.normal="{contentBackgroundColor}"
                                    color.normalAndShowsCaret="{contentBackgroundColor}"
                                    color.hovered="{rollOverColor}"   
                                    color.hoveredAndShowsCaret="{rollOverColor}"
                                    color.selected="{selectionColor}"
                                    color.selectedAndShowsCaret="{selectionColor}"
                                    />
                            </s:fill>
                        </s:Rect>
                        <!-- the only real change is to set a specific size on the SimpleText slightly smaller
                             than the width of the List to account for the border -->
                        <s:SimpleText id="labelDisplay" verticalCenter="0" width="48" top="6" bottom="4"/>
                    </s:ItemRenderer>
                </fx:Component>
            </s:itemRenderer>
        </s:List>
    </s:Application>

  • 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

  • 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>

  • Spark List alternating ItemRenderer

    Hello,
    lets say that I what a Spark List display its content like the following:
    [Picture]  text
    text  [Picture]
    Is there a way to define two (or even more,e.g: as  template) custom ItemRenderer and toggle between them?
    How is that solved in the DataGrid for example, where the background color is alternating.
    Best regards
    Marc

    You can try to build a custom ItemRenderer and determine the color,
    state, etc. based on the itemIndex property. For example you
    can use something like:
    if (itemIndex % 2 == 0)
         setStyle("backgroundColor", 0xFF0000);
    In your case I would try adding custom states to the ItemRenderer. You can read more about this in this post:
    http://forums.adobe.com/message/2082895

  • Relating 2 tables with one List Control

    I am testing the new data services in FB4 with PHP.   I have created a simple List control that displays a mySQL list  -- which works fine.
    When I double click on an item in the list, I want to use it as the search index for a second table. I use the doubleclick event to make the call to search the second table.
    I set the dataprovider of the same List control to the new search result array returned from the second table.   This does not work.
    The Individual search code to each table work fine, but calling the second search in the doublclick event function does not.
    any examples would be appreciated.

    Thanks for your help.   My code is below:
    <?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" minWidth="1024" minHeight="768" height="314" width="574" xmlns:categories="services.categories.*" xmlns:subcategories="services.subcategories.*">
    <fx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.events.FlexEvent;
    import mx.events.IndexChangedEvent;
    import com.adobe.serializers.utility.TypeUtility;
    import mx.controls.Alert;
    protected function connectToData(event:FlexEvent):void
    getAllItemsResult.token = categories.getAllItems();
    protected function list1_doubleClickHandler(event:MouseEvent):void
    var item:* = category.dataProvider.getItemAt(category.selectedIndex);
    getAllItemsResult2.token = subcategories.getAllItems(item.id);
    category.dataProvider = TypeUtility.convertToCollection(getAllItemsResult2.lastResult);
    category.labelField = "name";
    ]]>
    </fx:Script>
    <fx:Declarations>
    <s:CallResponder id="getAllItemsResult"/>
    <categories:Categories id="categories" destination="categories" endpoint="http://springblue/justin/flex/groupbrowser/bin-debug/gateway.php" fault="Alert.show(event.fault.faultString)" showBusyCursor="true" source="categories"/>
    <s:CallResponder id="getAllItemsResult2"/>
    <subcategories:Subcategories id="subcategories" destination="subcategories" endpoint="http://springblue/justin/flex/groupbrowser/bin-debug/gateway.php" fault="Alert.show(event.fault.faultString)" showBusyCursor="true" source="subcategories"/>
    </fx:Declarations>
    <s:List x="25" y="28" height="265" width="525" id="category" doubleClickEnabled="true" doubleClick="list1_doubleClickHandler(event)" creationComplete="connectToData(event)" dataProvider="{TypeUtility.convertToCollection(getAllItemsResult.lastResult)}" labelField="category_name" contentBackgroundColor="#E5E5E5"/>
    </s:Application>

Maybe you are looking for

  • Enemy territory and doom3 mouse annoyance

    I have three options:- 1. Do not disable dga in xorg.conf- :- If my move my mouse too much, some of the movement data is stored in some buffer or something. Press any key or move the mouse some more, this movement data stored in the buffer gets relea

  • It says video is too large on iPhone to be send to iCloud

    When I tried to send a video clip taken on iPhone (duration - 13 min) to iCloud a notification appeared  that the video was too large and I need to crop it. I clicked OK and then an upper line got out showing all the length frame by frame with a yell

  • Formula in BIBW

    I would like to have a report with customer & material in the rows and sales (value) in the columns.  The condition for arriving the sales value is that out of total sales, customer who has reached 70% of the sale value to be appeared first, next 20%

  • Numbered Forms Acrobat 9

    I want to create auto number forms where I would assign a range of numbers and once a number in the list was used it would expire and unable to be used twice.

  • Re: Exception in thread "main" java.lang.NullPointerException

    Hi I am getting the following error. I cannot see any uninitialised objects. I have spent enough time on it .Could someone help me with this. Thanks in advance Exception in thread "main" java.lang.NullPointerException         at pointlist.pointList.a