Height of Itemrendere

If given data, is there a way to find the height of its respective itemrenderer before adding it to the list ?

Nevermind,
  On the DataGroup of the list, there is an array property "indexToRenderer".  It is declared private but it is the basis of the numElements and getElementAt functions.
Unless of course this is a terrible terrible way to do it.

Similar Messages

  • List Height w/ itemRenderer

    I'm trying to figure out why my list won't adjust it's height
    when the height of the itemRenderer changes. The list looks like
    this:
    <mx:List id="Parts" width="349"
    verticalScrollPolicy="off"
    itemRenderer="PartRenderer"
    variableRowHeight="true"
    alternatingItemColors="[0xEEEEEE, 0xDFDFDF]"
    themeColor="#FFFFFF" />
    If I add another item to the list, then it grows to fit the
    new item, but if the any of the items themselves grow (they each
    contain expanding TextArea's etc.) then the list will not adjust
    it's height to fit. I know for sure that it is the list that is not
    growing because I am printing its height to the screen so I can
    monitor its size.
    Also, I don't explicitly set the height anywhere for the
    list. I also don't want scrollbars in the list. I just want the
    whole list to expand to whatever height it needs to show all of
    each item.
    When the list first loads the height is correct, but if I the
    height of an item changes after it has been loaded into the list,
    the list no longer adjusts its height to fit.
    Any ideas on how to do this or what I might be doing wrong?

    First re-install the original SpryMenuBarHorizontal.css.
    Then add the following styles to the bottom of the original CSS
    ul.MenuBarHorizontal {
        font: 80%/1.6em Arial, Helvetica, sans-serif;
    ul.MenuBarHorizontal li {
        width: auto;
    ul.MenuBarHorizontal a.MenuBarItemSubmenu {
        padding: 0.5em 2em 0.5em 0.75em;
    ul.MenuBarHorizontal a {
        background-color: #FC0;
        border: 1px solid #02014D;
    ul.MenuBarHorizontal a:hover, ul.MenuBarHorizontal a:focus {
        background:#ffff66 url(navbakyel.jpg) repeat-x center;
        color: #000;
    ul.MenuBarHorizontal a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarSubmenuVisible, ul.MenuBarHorizontal li a.MenuBarItemSubmenuHover {
        background:#ffff66 url(navbakyel.jpg) repeat-x center;
        color: #000;
    Gramps

  • Access properties of component within an itemRenderer

    I have a VBox (vbox1.mxml) component that contain a 2 childs
    component, which is Image and Label. Some snapshots of the code is
    <!—vbox1.mxml - ->
    <mx:VBox>
    <mx:Image id="videoImg" width="100%" height="100%"
    cachePolicy="off" source="{data.videoImage}" name="{data.secs}"
    completeEffect="{fadeIn}" />
    <mx:Label id="segmentLabel" width="50%" color="white"
    textAlign="center" text="At {data.secs} secs" />
    </mx:VBox>
    Then I have the main application mxml (main.mxml) that will
    use this component (vbox1.mxml).
    <mx:TileList id="segmentTileList" width="100%"
    height="95%" itemRenderer=" vbox1"
    dataProvider="{vsRO.findVideoDetails.lastResult}"
    rowHeight="120" columnWidth="120" backgroundColor="#646D7E"
    backgroundSize="100%"/>
    Question is how am I able to access the Label value that
    resides within the item renderer? How can I read/write its values
    from my main.mxml?

    The code you have shown here looks correct to me.
    What do you get when you print ${item.value} and ${item.value.subject}?
    Just to query the base assumptions
    - Is it a map of Message objects? Try the expression ${item.value.class} to see what the class of the returned object is.
    - Do you also have a setter for the subject in the Message class?
    I presume the Message and MessageCenter classes are in a package?
    Hope this helps,
    evnafets

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

  • Downloading Images - FileReference download error 2176

    Hi everyone.
    I'm trying to download some images but getting this error "Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press."
    The trouble is, it IS running off a button click - just indirectly.
    I'm trying to design a good architecture for my program, so have the Application, a dataStore and some value objects, for example, a pricebook containing and array of products, each called PricebookVO and ProductVO.
    What I'm doing when the application loads is doing a database query with another API that gives me a pricebook and all of its products, and i populate the value objects.  Relationship is obviously  PricebookVO -< ProductVO.  I wanted to download the images for the products at the same time but it won't let me due to the error above, so what I have now is a button bar and when the user clicks a button an event is bubbled up to the Application which changes the page, but what also happens is it checks to see if the user has clicked the Products button and if it has, it tells the PricebookVO to tell each of its ProductVO's to download their image (from a URL that was saved from the query.
    Presumably the error im getting now is because the download is not directly summoned by a user event but by an indirect event (ie user pushes button, code calls code which tries to download the file).  How can I download the images and still maintain my architecture?
    Also, am I getting confused?  I want to get a file from a server and save them in an mx.controls.Image on the ProductVO record, do I use the FileReference.Download method or something else?  Because on further inspection it looks as though the download method is for downloading something to the local machine with a download dialog box?
    Thanks
    Steven

    Thanks for all your help Peter, its much appreciated.  I hate that useless feeling when learning a new language!
    So anyway, I was initially using image.source but thought to myself that's probably referencing the image from its server source which might be quite a hog, so wanted to store it myself, but if you say image.source does indeed handle the image itself and not just reference it from the source, thats good.
    My only remaining query is regarding how it is displaying.  I have a tileList which is rendering the images and it does work, however the images are loading on screen as I watch them, and if I scroll I then have to wait again whilst the images load.  If I then scroll back to the previuos part of the screen, where the images had previously already loaded, they have disappeared again and I once again have to wait for them to load.
    I know normally you'd embed them, but dont see how thats possible with the way I'm having to load them from the server?
    I have a method in my datastore like this:
    public function getProds():ArrayCollection{
    var imgs : ArrayCollection = new ArrayCollection();
    for each (var pb : PricebookVO in pricebooks){
      pb.getProdCount();
      for each (var p2 : ProductVO in pb.products){
       imgs.addItem(p2);
    return imgs;
    and in my products page:
    <mx:TileList>
      <mx:width>100%</mx:width>
      <mx:height>100%</mx:height>
      <mx:itemRenderer>components.Thumbnail</mx:itemRenderer>
      <mx:dataProvider>{DataStore.getInstance().getProds()}</mx:dataProvider>
    </mx:TileList>
    components.Thumbmail is
    <mx:Image>
      <mx:width>100</mx:width>
      <mx:height>75</mx:height>
      <mx:source>{this.data.image.source}</mx:source>
      <mx:toolTip>{this.data.prodCode}</mx:toolTip>
    </mx:Image>
    So, how can I stop the tilelist from having to constantly reload the images?  I get the impression that the solution might end up using a lot of memory to store the images somehow, so advice on the best way to do this is appreciated.
    Thanks!

  • My VScrollBar applied on List ignores my custom Skin

    I'm trying to customize the skin of a List. The code looks like this:
    <s:List id="selector" x="670" height="327" itemRenderer="components.GalleryThumbnailRenderer" borderVisible="false" contentBackgroundAlpha="0" focusAlpha="0" horizontalScrollPolicy="off">
          <s:layout>
              <s:TileLayout requestedColumnCount="2" horizontalGap="1" verticalGap="1"  />
         </s:layout>
         <s:scroller>
              <s:Scroller>
                   <s:verticalScrollBar>
                        <s:VScrollBar skinClass="components.VScrollSkin" />
                   </s:verticalScrollBar>
              </s:Scroller>
         </s:scroller>
    </s:List>
    I've generated the components.VScrollSkin with Flash Builder using spark.components.VScrollBar as host component and created as a copy of spark.skins.spark.VScrollBarSkin
    Whatever I change and do in components.VScrollSkin isn't applied when I build the app. Always the default Skin is shown. I've but a trace in components.VScrollSkin to see if it's actually being loaded or not. But it is being used.
    What am I doing wrong????

    Thank you Frank for your response.....
    I have used the stand alone skineditor version:
    Skin Editor Version 11.1.2.0.0
    Build JDEVADF_11.1.2.0.0_GENERIC_110531.1615.6017
    I followed the following steps:
    - From the skin editor - I created a new application with target application release 11.1.1.4
    -- Created a new skin
    --- Changed af|selectonechoice background color to maroon....
    ---- Created deployment profile - adf library jar file with all standard option (i didn't make any changes)
    ----- created jar file using newly creately deployment profile
    Open Jdev Studio Edition Version 11.1.1.4.0
    - Opened Web application project properties
    -- Under libraries and classpath --> added new library --> added skin jar file and fusion-simple-skin.jar file
    --- Open trinidad-config.xml file and changed content to :
    <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
    <skin-family>skin1</skin-family>
    </trinidad-config>
    Now in Jdev design mode I see all dropdown fields background changed to Maroon.....
    But wHen I run the page from Jdev. I don't see those dropdown background changed to Maroon. But it looks like it is using some new skin.... because all fonts of label are little bigger than usual...... on the running page....

  • Disable roll-over-color in List

    Hi,
    I'd like to only use roll-over-text-color in my list, but have no roll-over-color at all. Is there a way to kill the roll over color, as well as the selection color?
    Thanks

    @upshotvideo,
    For mx:List, I think Harui is suggesting something like the following:
    package comps {
        import flash.display.Sprite;
        import mx.controls.List;
        import mx.controls.listClasses.IListItemRenderer;
        public class NoHighlightList extends List {
            public function NoHighlightList() {
                super();
            override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void {
                // super.drawHighlightIndicator(indicator, 0, y, unscaledWidth - viewMetrics.left - viewMetrics.right, height, color, itemRenderer);
    Peter

  • Changing values in custom item renderer

    I have an xml feed that I am using to populate a List control. The list control has it's itemRenderer property set to CustomListItem which a custom component built by me to display various pieces of data from the xml along with an icon. At certain points I would like to ba able to tell one of the fields in CustomListItem to change from displaying xml.firstData to xml.secondData depending on a radio button selection but I can't find a way to access the properties of CustomListItem from main.mxml (which is where the radio buttons are).
    At the moment the values in CustomListItem are set using functions within it to parse the 'data' property.
    Sorry if this is a bit of a sketchy explanation of my problem Any suggestions would be great.
    Cheers

    I hope this code represents your situation, but at least I hope it helps you!
    ----------------------- main app ----------------------------
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
      height="100%" creationComplete="dataRequest.send();"
      xmlns:comp="*" horizontalAlign="left">
      <mx:Script>
        <![CDATA[
          import mx.rpc.events.ResultEvent;
          import MyListItems;
          import mx.collections.XMLListCollection;
          [Bindable] private var xmllist:XMLList;
          [Bindable] private var xlc:XMLListCollection;
          private function resultHandler(evt:ResultEvent):void{
            xmllist = evt.result.item;
            xlc = new XMLListCollection(xmllist.firstData);
          private function changeData(evt:Event):void{
            if(evt.currentTarget.label == "First Data"){
              xlc = new XMLListCollection(xmllist..firstData);         
            }else{
              xlc = new XMLListCollection(xmllist.secondData);         
        ]]>
      </mx:Script>
      <mx:HTTPService id="dataRequest" useProxy="false" url="data.xml"
        resultFormat="e4x" result="resultHandler(event)"/>
      <mx:RadioButtonGroup id="items"/>
      <mx:RadioButton group="{items}" label="First Data" change="changeData(event)"
        selected="true"/>
      <mx:RadioButton group="{items}" label="Second Data" change="changeData(event)"/>
      <mx:List width="100" height="150" itemRenderer="MyListItems"
        dataProvider="{xlc}"/>
    </mx:Application>
    ----------------------- item renderer --------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Text text="{data}"/>
    </mx:HBox>
    ------------------------------- data.xml ---------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mydata>
      <item>
        <firstData>apples</firstData>
        <secondData>oranges</secondData>
      </item>
      <item>
        <firstData>beef</firstData>
        <secondData>chicken</secondData>
      </item>
      <item>
        <firstData>milk</firstData>
        <secondData>juice</secondData>
      </item>
      <item>
        <firstData>carrot</firstData>
        <secondData>tomato</secondData>
      </item>
    </mydata>

  • TileList - Items have a Border even if I set the Border borderStyle="solid" borderThickness="0""

    Hi,
    I have a TileList
    Here is a Snippet of code
           tileList = new TileList();
           tileList.percentWidth = 100;
           tileList.percentHeight = 100;
           tileList.id = "picsList";
            tileList.dataProvider = parentDocument.partListColl;
           tileList.itemRenderer = createItemRenderer();
           tileList.dragEnabled = true;
           tileList.dragMoveEnabled = false;
    The ItemRenderer is:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
            horizontalAlign="center"
            verticalAlign="middle" width="200" height="200" backgroundColor="0xFF0000"  borderColor="0x00FF00" borderStyle="solid" borderThickness="0">
        <mx:Image id="image"  width="100" height="100" source="assets/{data.Image}"   visible="false"/>
        <mx:Label text="{data.Name}"  width="100" textAlign="center"  visible="false" />
    </mx:Panel>
    I still see a black border on all the items in the Tilelist.
    I'm not sure where this is coming from. I would like to remove this border. Any help welcome.
    I notice that if i create a Object Array with the same Image and Label. Then i dont have this issue of the border.
    Regards

    I gave width and height as zero,for the item renderer(line no.29).In that case too I got the scroll perfectly and the item renderer content too got fit automatically to the screen size.So i guess is it that there needs to be a set height and width for the item renderer (to be precise,for any of the parents of scroller)initially?
    @Shongrunden
    I got the issue fixed by setting width and height for itemrenderer.But wanted to know the reason behind it working correctly.

  • Buttons in List

    Hi,
    I have spark buttons in List.  I would like to trigger different task when user clicks the button, but not to trigger the list item.  Is there an "isClick" attribute on spark button?
    Thanks!

    1) Use a button item renderer for list
    2) Add click event handler for button
    3) In click event handler,use something like label of the button to uniquely identify the button which is clicked and based on that write the logic you want to implement.
    Here is a simple example for you:
    <?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/mx" minWidth="955" minHeight="600">
        <s:layout>
            <s:VerticalLayout/>
        </s:layout>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:List width="150" height="250" itemRenderer="ButtonRenderer">
            <s:layout>
                <s:VerticalLayout/>
            </s:layout>
            <s:dataProvider>
                <s:ArrayList>
                    <fx:String>Btn1</fx:String>
                    <fx:String>Btn2</fx:String>
                    <fx:String>Btn3</fx:String>
                    <fx:String>Btn4</fx:String>
                    <fx:String>Btn5</fx:String>
                    <fx:String>Btn6</fx:String>
                </s:ArrayList>
            </s:dataProvider>
        </s:List>
    </s:Application>
    Here is the ButtonRenderer class:
    <?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"
                    autoDrawBackground="false">
        <fx:Script>
            <![CDATA[
                import mx.controls.Alert;
                protected function button1_clickHandler(event:MouseEvent):void
                    if(event.currentTarget.label == 'Btn4')
                        Alert.show('You have clicked Btn4');
                    else
                        Alert.show('You have clicked some other btn');
            ]]>
        </fx:Script>
        <s:Button label="{data}" click="button1_clickHandler(event)"/>
    </s:ItemRenderer>

  • Changing chart series colors with colorpicker

    I am trying to implement functionality to allow the user to
    select what color he wants a particular series item in a chart to
    be. Here's what I'm doing, but it doesn't work. I get the series
    object returned correctly, but "setStyle" doesn't do anything.

    Alright, I think I have something you're looking for. This
    updates the series' color in the legend, too.
    <?xml version="1.0"?>
    <!-- charts/BasicLine.mxml -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script><![CDATA[
    import mx.collections.ArrayCollection;
    import mx.charts.events.ChartItemEvent;
    import mx.controls.ColorPicker;
    import mx.events.ColorPickerEvent;
    import mx.charts.HitData;
    import mx.charts.chartClasses.ChartElement;
    import mx.graphics.Stroke;
    import mx.charts.series.items.LineSeriesItem;
    [Bindable]
    public var expenses:ArrayCollection = new ArrayCollection([
    {Month:"Jan", Profit:2000, Expenses:1500, Amount:450},
    {Month:"Feb", Profit:1000, Expenses:200, Amount:600},
    {Month:"Mar", Profit:1500, Expenses:500, Amount:300}
    private var cp:ColorPicker;
    private var csi:LineSeriesItem;
    private var el:ChartElement;
    private function doSomething(e:ChartItemEvent):void {
    var hitData:HitData = e.hitData;
    csi = LineSeriesItem(hitData.chartItem);
    el = ChartElement(csi.element);
    cp = new ColorPicker();
    myChart.addChild(cp);
    cp.addEventListener(ColorPickerEvent.CHANGE,
    changeItemColor);
    cp.x = e.localX;
    cp.y = e.localY;
    cp.open();
    private function changeItemColor(e:ColorPickerEvent):void {
    var s1:Stroke = new Stroke(cp.selectedColor, 4, 1); //First
    3 arguments are color, weight, and alpha.
    el.setStyle("lineStroke", s1);
    // Use this if it's a column or bar series:
    // var c:SolidColor = new SolidColor(cp.selectedColor);
    //el.setStyle("fill", c);
    //csi.itemRenderer.height = csi.itemRenderer.height;
    myChart.removeChild(cp);
    ]]></mx:Script>
    <mx:Panel title="Line Chart">
    <mx:LineChart id="myChart"
    dataProvider="{expenses}"
    showDataTips="true"
    itemClick="doSomething(event)"
    >
    <mx:horizontalAxis>
    <mx:CategoryAxis
    dataProvider="{expenses}"
    categoryField="Month"
    />
    </mx:horizontalAxis>
    <mx:series>
    <mx:LineSeries
    yField="Profit"
    displayName="Profit"
    selectable="true"
    />
    <mx:LineSeries
    yField="Expenses"
    displayName="Expenses"
    selectable="true"
    />
    </mx:series>
    </mx:LineChart>
    <mx:Legend dataProvider="{myChart}"/>
    </mx:Panel>
    </mx:Application>
    matt horn
    flex docs

  • Making a list a definite length with no repeated data

    I have a list tag that currently accepts repeats and as many objects as I will drop into it. Is there a simple way to make this where it will only accept four objects and no repeats?

    Here is the code in my item renderer:
    protected function hbox1_mouseDownHandler(event:MouseEvent):void{
                    var target:Canvas = Canvas(event.currentTarget);
                    var sourceObject:Lesson = new Lesson(data.lesson, data.lessonNumber);
                    var dragSource:DragSource = new DragSource();
                    dragSource.addData( sourceObject, "listCopy" );
                    mx.managers.DragManager.doDrag(target, dragSource, event, null , -0, -0, 0.40, true );
    Here are the two drag//drop handlers in my class:
                     * allows for 4 items on the list and no repeats
                    private function dragDropHandler(event:DragEvent):void{
                        if (event.dragSource.hasFormat('listCopy'))
                            var newObj:Lesson;
                            newObj = event.dragSource.dataForFormat("listCopy") as Lesson;
                            model.selectedLessonList.addItem(newObj as Lesson);
                     * allows for 4 items on the list and no repeats
                       private function dragEnterHandler(event:DragEvent):void
                        tmpObject = event.dragSource.dataForFormat("listCopy");
                        if(tmpObject == null){return;}//something messed up!
                        trace(tmpObject.lesson);
                        repeatFlag = false;
                        for (var i:int=0; i < model.selectedLessonList.length;i++){
                            if (model.selectedLessonList[i].lesson == tmpObject.lesson){
                                repeatFlag=true;
                                break;
                        if (model.selectedLessonList.length < maxLength && repeatFlag==false){
                            DragManager.acceptDragDrop(List(event.target));       
                            DragManager.showFeedback(mx.managers.DragManager.COPY);
    Here is the list containing the original item:
               <mx:List id="lstAllCategories" width="245" height="95%" itemRenderer="com.components.renderers.CategoryListItemRenderer"
                                    dataProvider="{ApplicationModel.instance.categoryList}" styleName="BoxBackground"
                                    rollOver="createToolTip('Mouse_Over_AllCategories')" rollOut="createToolTip('Mouse_Over_BottomOfScreen')">
    Here is the list that the item is being dropped into:
    <mx:List id="lstCurrentSelectedLessons" dataProvider="{model.selectedLessonList}" width="245" height="140"  dropEnabled="true" dragDrop="dragDropHandler(event);checkSelectedLessonList()" dragEnter="dragEnterHandler(event)"
                                    doubleClickEnabled="true" doubleClick="beginLesson()" itemRenderer="com.components.renderers.ChosenListItemRenderer" styleName="BoxBackground"
                                    rollOver="createToolTip('Mouse_Over_CurrentLessons')" rollOut="createToolTip('Mouse_Over_BottomOfScreen')">
                                </mx:List>

  • Dynamic height of mx:Text in List ItemRenderer

    Hello,
    I want to have a list with line breaks if the width of the
    items is higher then the width of the list.
    I wrote my custon ItemRender but if i set the no height to
    the mx:Text there would be only first line tdisplayed on the list
    My List looks like this
    <mx:List id="level1" dataProvider="{level1List}"
    width="100%" height="100%"
    change="selectLevel1ItemEvent(event)">
    <mx:itemRenderer>
    <mx:Component>
    <mx:VBox height="100%">
    <mx:Text width="100%" height="40" text="{data.desc}"/>
    </mx:VBox>
    </mx:Component>
    </mx:itemRenderer>
    </mx:List>
    The problem is that know all items have a height to fit an
    item with two lines. I want only have this if the width of an item
    is higher than the width of the list.
    Thanks,
    Stefan

    try setting minHeight of the RTE to 0

  • Inline item mx:Image ... in mx:itemRenderer could not see the defination of method

    I have following code and got a compilation error ("possiblely called an undefined function") because the <mx:Image ...> in the <mx:itemRenderer > could not see the defination of "aMethod" method:
    <mx:Form ....>
    <mx:Script><![CDATA[
    private function aMethod(evt:Event):void {
               // code...
    ]]></mx:Script>
    <mx:Canvas label="Tile View" width="100%" height="100%" >
              <mx:TileList id="photosTileList" dataProvider="{this.photoDP}" width="100%" height="100%"  >
                        <mx:itemRenderer >
                            <mx:Component>
                                <mx:Image horizontalAlign="center" source="{data.url.text()}"
                                    toolTip="{data.caption.text()}" width="55" height="38" complete="aMethod(event)"/>  <!-- It causes the error -->
                            </mx:Component>
                        </mx:itemRenderer>
             </mx:TileList>
             <mx:Image .... complete="aMethod(event)"/>  <!-- It is OK here -->
    </mx:Canvas>
    </mx:Form>
    I do not know why the inline <mx:Image> inside <mx:itemRenderer> can not see the "aMethod" function defination in the same mxml file.
    Any suggestions?

    You need outerDocument, and the method cannot be private, it should be public:
    complete="outerDocument.aMethod(event)"
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex / AIR Development, Training, and Support Services

  • Using a custom itemrenderer in datagrid to update value in the same row but different column/cell

    Here's what I have so far.  I have one datagrid (dg1) with enable drag and another datagrid (dg2) with dropenabled.  Column3 (col3) of dg2 also has a custom intemrenderer that's just a hslider.
    When an item from dg1 is dropped on dg2, a custom popup appears that asks you to use the slider in the popup to set a stress level.  Click ok and dg2 is populated with dg1's item as well as the value you selected from the popup window.  I was also setting a sliderTemp variable that was bound to the itemrender slider to set it but that's obviously causing issues as well where all the itemrenderer sliders will change to the latest value and I don't want that.
    What is needed from this setup is when you click ok from the popup window, the value you choose from the slider goes into dg2 (that's working) AND the intemrenderer slider needs to be set to that value as well.  Then, if you used the intemrenderer slider you can change the numeric value in the adjacent column (col2).   I just dont know how to hook up the itemrenderer slider to correspond with that numeric value (thatds be in col2 on that row);
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"
                        xmlns:viewStackEffects="org.efflex.mx.viewStackEffects.*" backgroundColor="#FFFFFF" creationComplete="init(event)"
                        xmlns:components="components.*" xmlns:local="*">
         <mx:Script>
              <![CDATA[
                   import mx.binding.utils.ChangeWatcher;
                   import mx.collections.ArrayCollection;
                   import mx.controls.Alert;
                   import mx.controls.TextInput;
                   import mx.core.DragSource;
                   import mx.core.IUIComponent;
                   import mx.events.CloseEvent;
                   import mx.events.DataGridEvent;
                   import mx.events.DragEvent;
                   import mx.events.FlexEvent;
                   import mx.events.ListEvent;
                   import mx.events.SliderEvent;
                   import mx.events.SliderEventClickTarget;
                   import mx.managers.DragManager;
                   import mx.managers.PopUpManager;
                   import mx.utils.ObjectUtil;
                   [Bindable]private var myDP1:ArrayCollection;
                   [Bindable]private var myDP2:ArrayCollection;
                   [Bindable]public var temp:String;
                   [Bindable]public var slideTemp:Number;
                   private var win:Dialog;     
                   protected function init(event:FlexEvent):void{
                        myDP1 = new ArrayCollection([{col1:'Separation from friends and family due to deployment'},{col1:'Combat'},{col1:'Divorce'},{col1:'Marriage'},
                             {col1:'Loss of job'},{col1:'Death of a comrade'},{col1:'Retirement'},{col1:'Pregnancey'},
                             {col1:'Becoming a parent'},{col1:'Injury from an attack'},{col1:'Death of a loved one'},{col1:'Marital separation'},
                             {col1:'Unwanted sexual experience'},{col1:'Other personal injury or illness'}])
                        myDP2 = new ArrayCollection()
                   protected function button1_clickHandler(event:MouseEvent):void
                        event.preventDefault();
                        if(txt.text != "")
                             Alert.yesLabel = "ok";                    
                             Alert.show("", "Enter Stress Level", 3, this,txtClickHandler);
                   private function image_dragEnter(evt:DragEvent):void {
                        var obj:IUIComponent = IUIComponent(evt.currentTarget);
                        DragManager.acceptDragDrop(obj);
                   private function image_dragDrop(evt:DragEvent):void {
                        var item:Object = dg2.selectedItem;                    
                        var idx:int = myDP2.getItemIndex(item);
                        myDP2.removeItemAt(idx);
                   protected function dg1_changeHandler(event:ListEvent):void
                        temp=event.itemRenderer.data.col1;     
                   protected function dg2_dragDropHandler(event:DragEvent):void
                        event.preventDefault();                         
                        dg2.hideDropFeedback(event as DragEvent)
                        var win:Dialog = PopUpManager.createPopUp(this, Dialog, true) as Dialog;
                        win.btn.addEventListener(MouseEvent.CLICK, addIt);
                        PopUpManager.centerPopUp(win);                              
                        win.mySlide.addEventListener(Event.CHANGE, slideIt);
                   private function txtClickHandler(event:CloseEvent):void {
                        trace("alert");
                        if (event.detail==Alert.YES){
                             myDP2.addItem({label:temp});
                   private function addIt(event:MouseEvent):void{                    
                        myDP2.addItem({col1:temp, col2:slideTemp})
                   private function slideIt(event:SliderEvent):void{                    
                        slideTemp = event.target.value;               
              ]]>
         </mx:Script>
                   <mx:Panel x="10" y="10" width="906" height="481" layout="absolute">
                        <mx:Image x="812" y="367" source="assets/woofie.png" width="64" height="64" dragDrop="image_dragDrop(event);" dragEnter="image_dragEnter(event);"/>
                        <mx:DataGrid x="14" y="81" width="307" height="251" dragEnabled="true" id="dg1" dataProvider="{myDP1}" wordWrap="true" variableRowHeight="true" change="dg1_changeHandler(event)">
                             <mx:columns>
                                  <mx:DataGridColumn headerText="Examples of Life Events" dataField="col1"/>
                             </mx:columns>
                        </mx:DataGrid>
                        <mx:DataGrid x="329" y="81" height="351" width="475" dragEnabled="true" dropEnabled="true" id="dg2"
                                        wordWrap="true" variableRowHeight="true" dataProvider="{myDP2}" editable="true"
                                        dragDrop="dg2_dragDropHandler(event)"  rowHeight="50" verticalGridLines="false" horizontalGridLines="true" >
                             <mx:columns>
                                  <mx:DataGridColumn headerText="Stressor" dataField="col1" width="300" wordWrap="true" editable="false">
                                  </mx:DataGridColumn>
                                  <mx:DataGridColumn headerText="Stress Level" dataField="col2" width="82" editable="false"/>
                                  <mx:DataGridColumn headerText="Indicator" dataField="col3" width="175" paddingLeft="0" paddingRight="0" wordWrap="true" editable="false">
                                       <mx:itemRenderer>
                                            <mx:Component>
                                                 <components:Compslide/>
                                            </mx:Component>
                                       </mx:itemRenderer>
                                  </mx:DataGridColumn>
                             </mx:columns>
                        </mx:DataGrid>                    
                        <mx:Text x="14" y="10" text="The first category of underlying stressors is called Life Events. The list includes both positive and negative changes that individuals experience. Both can be stressful. For example, becoming a parent is usually viewed as a positive thing, but it also involves many new responsibilities that can cause stress. " width="581" height="73" fontSize="12"/>
                        <mx:TextInput x="10" y="380" width="311" id="txt"/>
                        <mx:Text x="10" y="335" text="Add events to your list that are not represented in the example list.  Type and click &quot;Add to List&quot;&#xa;" width="311" height="51" fontSize="12"/>
                        <mx:Button x="234" y="410" label="Add to List" click="button1_clickHandler(event)"/>
                   </mx:Panel>     
    </mx:Application>

    how do i go about doing that?  do i put a change event function in the itemrenderer?  and how would i eventually reference data.col2?

Maybe you are looking for

  • How can I get JavaScript to detect if flash is installed and then load a different URL?

    Hi, I've made two versions of the same site, one in flash and one in HTML, but I want the browser to detect what version of flash is installed, if any and then load the appropriate version of my site. I used to have it so that it displays a HTML mess

  • How do I retrieve lost Notes?

    All my notes have disappeared from my Iphone (4S), iPad 2 and Macbook Pro. How do I get them back? I've tried going into Time Machine but no luck so far.

  • Unzip data received from web service?

    In my Apex 3.0.1 application I am trying to obtain data from a web service. The problem is that the returned data is first zipped and then encoded using base 64 coding. I can decode the data using the utl_encode package and if I download the result,

  • Error of u0093test configurationu0094

    Hi,gurus: when i do the tool->test configuration in the ID,an error occured,it displays :" Interface Mapping Runtime error java.lang.NullPointerException thrown during application mapping com/sap/xi/tf/_MM_ASC2XML_:" what's wrong whit the message map

  • HT3765 - Cascading Softwareupdate Server not working!?

    Following HT3765 (OS X Server: How to cascade Software Update Servers from a Central Software Update Server) I am not able to get this to work. The secondary Software Update Server are still contacting Apple's Infrastructure. Did anyone get this to w