Custom ComboBox problem

Hello

I'm doing a custom combobox. I don't want pictures in that text. Inspired by DDImagesButton I coded my Combobox. But am experiencing a few problems with it.

For the button, I created TextButtonField. Problem that I face this is it shows text only when you click on it once. Otherwise, it shows just background color. Here's the code for TextbuttonField:

public class TextButtonField extends ButtonField implements FocusChangeListener {
    protected DropdownItem mItem;
    boolean mTextItem;
    int mWidth;
    int mHeight;
    private static final int FOCUS_COLOR_BORDER = Color.RED; //0xFC0000;
    private static final int UNFOCUS_COLOR_BORDER = Color.WHITE;
    private int borderColor = FOCUS_COLOR_BORDER;
    private int color;
    private boolean selected;

    public TextButtonField(String text) {
        this(new DropdownItem(null, text), true);
    }

    private TextButtonField(DropdownItem item, boolean textItem) {
        super(item.mName, CONSUME_CLICK);
        mItem = item;
        mTextItem = textItem; 

        mWidth = (mTextItem ? getFont().getAdvance(mItem.mName) + 6 : 0);
        mHeight = getFont().getAscent() + 6; 

        // Save the Width & Height for layout
        mItem.itemWidth = mWidth;
        mItem.itemHeight = mHeight;

        setPadding(3, 6, 3, 6);
        setMargin(0, 0, 0, 0);
        this.setBackground(BackgroundFactory.createSolidBackground(Color.RED));
        setBorder(BorderFactory.createSimpleBorder(new XYEdges(0, 0, 0, 0), Border.STYLE_TRANSPARENT));
        setBorder(VISUAL_STATE_ACTIVE, BorderFactory.createSimpleBorder(new XYEdges(0, 0, 0, 0), Border.STYLE_FILLED));
        setFocusListener(this);
    } 

    public TextButtonField(String text, int bgColor) {
        this(new DropdownItem(null,text), true);
        this.setBackground(BackgroundFactory.createSolidBackground(bgColor));
    }

    protected void paint(Graphics graphics) {
        super.paint(graphics);
    } 

    public int getPreferredWidth() {
        return mWidth;
    } 

    public int getPreferredHeight() {
        return mHeight;
    } 

    protected void layout(int width, int height) {
        setExtent(mWidth, mHeight);
    } 

   public void focusChanged(Field field, int eventType) {
        if (eventType == FocusChangeListener.FOCUS_GAINED) {
            borderColor = FOCUS_COLOR_BORDER;
            invalidate();
        }
        if (eventType == FocusChangeListener.FOCUS_LOST) {
            borderColor = UNFOCUS_COLOR_BORDER;
            invalidate();
        }
    }

    protected void drawFocus(Graphics g, boolean on) {
        paint(g);
    }
}

By using this class, I created the ComboBox class such as:

public class ComboBox extends TextButtonField implements FieldChangeListener {
    DropdownItem[] mItems;
    int mIndex;
    boolean showSelectedText;
    private int maxTextInd =0;

    public ComboBox(DropdownItem items[]) {
        super(items[0].mName);
        mItems = items;
        updateIndex(0);
        setChangeListener(this);
    }

    public ComboBox(DropdownItem items[], int bgColor) {
        super(items[0].mName, bgColor);
        mItems = items;
        updateIndex(0);
        setChangeListener(this);
    }

    protected void paint(Graphics graphics) {
        super.paint(graphics); 

        int x = 0;
        int ht =  0;
        x = this.getFont().getAdvance(mItems[maxTextInd].mName) + 5;

        int y = 5; 

        int y1 = y;
        int y2 = y + 10;
        int x1 = x;
        int x2 = x + 18;
        int[] xPts = new int[] { x1, x2, x1 + 9 };
        int[] yPts = new int[] { y1, y1, y2 };
        graphics.drawFilledPath(xPts, yPts, null, null);
    } 

    public void fieldChanged(Field f, int context) {
        getScreen().getUiEngine().pushScreen(new ComboPopUp());
    }

    public void updateIndex(int index) {
        mIndex = index;
        mItem = mItems[mIndex];
        invalidate();
    }

    public int getSelectedIndex() {
        return mIndex;
    }
    public String getSelectedItem() {
        return mItems[mIndex].mName;
    }

    class ComboPopUp extends PopupScreen implements FieldChangeListener {
        public ComboPopUp() {
            super(new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR));
            for (int i = 0; i < mItems.length; i++) {
                TextButtonField button = new TextButtonField(mItems[i].mName);
                add(button);
                button.setChangeListener(this);
            }
            getField(mIndex).setFocus();
        } 

        protected boolean keyChar(char key, int status, int time) {
            if (Keypad.KEY_ESCAPE == key) {
                this.close();
                return true;
            } else
                return super.keyChar(key, status, time);
        } 

        public void fieldChanged(Field field, int context) {
            updateIndex(getFieldWithFocusIndex());
            this.close();
        }
    }
}

* Here if the index is changed, I want to see the ot the button of the selected index. I want to say that if I have 2 items in the drop-down list 'Save' & 'Edit', Save is 1 then it will be displayed, if I select "Edit" then change must be considered over the top and not save. This time is seen as st element.

* In DDImagesButton, next to the button, the triangle is hsown, which indicates a drop down, here how can I show that. In DDImagesButton, I have not found where and what show this triangle.

* The popup is displayed correctly, but the text is not displayed until the component is selected. This issue will be resolved when TextButtonField problem is solved.

Although these 2 problems are a little different but as relate to them, I added in the same message.

Can you help me to solve my problems and help me create the custom drop-down list box. Help is highly appreciated.

Thank you

Hi Piotr,

Consideirng your instructions, I tried to implement and make changes accordingly, but nothing has worked... I knew that both the setBorder is necessary. For ascent, creaed a label with alphabet 'W' and I am for his ascension.

By developing, I realized the problem and resolved completely. In fact, I've been putting the text of the TextButtonField in super(), I removed that and displays text in object. It also helped me view the drop-down arrow that was not coming. I changed the following code and little bit here & there, and things were as expected.

private TextButtonField(DropdownItem item, boolean textItem) {
        super(CONSUME_CLICK);
        ..........
 }

    protected void paint(Graphics graphics) {
        super.paint(graphics);
        graphics.setColor(Color.WHITE);
        graphics.setFont(textFont);
        graphics.drawText(mItem.mName, XPad, 1);
    }

The drop down menu is not visible completely because of the size of the layout. Changed the width of TextButtonField in ComboBox object after showing the arrow that is:

totWidth = x 2;

and layout() TextButtonField:

Protected Sub layout (int width, int height) {}
setExtent (Math.max (mWidth, totWidth), mHeight);
}

That's all, and my work is done. Above code is added with explanation so can serve to someone else like me.

Thank you

Tags: BlackBerry Developers

Similar Questions

  • Custom Scrolller - problem with several objects...

    Hello

    I'm developing a very simple custom scroller as a proof of concept. The idea is to have a background image (content_mc), throw multiple objects(myContent[i]) on top of the image and scroll them all as a cohesive unit. However, I can't scroll myContent [i] as appropriate; each object has a unique position and when I try to scroll, they all assume a position (in which everything rides), move to this position and then made scroll (see # comment below). Does anyone know how to do this? (or this doesn't make any sense?)

    Thx for any help,

    Chipleh

    var rect:Rectangle;var scrollerMinY:Number = scrollbar_mc.scroller_mc.y;
    var contentMaxY:Number = content_mc.y;
    var padding:Number = 40;
    
    scrollbar_mc.scroller_mc.buttonMode = true;
    scrollbar_mc.scroller_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
    
    function dragIt(e:MouseEvent):void {
        rect = new Rectangle(4, 3, 0, 180);
        scrollbar_mc.scroller_mc.startDrag(false, rect);
        stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
        scrollbar_mc.scroller_mc.addEventListener(Event.ENTER_FRAME, scrollIt);
    }
    
    function dropIt(e:MouseEvent):void {
        scrollbar_mc.scroller_mc.stopDrag();
        scrollbar_mc.scroller_mc.removeEventListener(Event.ENTER_FRAME, scrollIt);
    }
    
    function scrollIt(e:Event):void 
    {
        var scrollerRange:Number = rect.height;
        var contentRange:Number = content_mc.height - mask_mc.height + padding;
        var percentage:Number = (scrollbar_mc.scroller_mc.y - scrollerMinY) / scrollerRange;
        var targetY:Number = contentMaxY - percentage * contentRange;
        content_mc.y = targetY;
    
        //###Herein lies the problem; I can not get multiple clips to align consistently like content_mc
        for(var i:int = 0;i<myContentArray.length;i++)
        {        
            var myContent:Object = MovieClip(root).getChildByName(myContentArray[i]);
            myContent.y = targetY - myContent.y;    
        }
    }
    

    Hey mocca,.

    So, I somewhat solved my problem,

    function scrollIt(e:Event):void

    {

    var scrollerRange:Number = rect.height;

    var contentRange:Number = Container1.height - mask_mc.height + padding;

    var percent: Number = (scrollbar_mc.scroller_mc.y - scrollerMinY) / scrollerRange;

    var targetY: number = contentMaxY - percentage * contentRange;

    Container1.y = targetY;

    for (var i: int = 0; i<>

    {

    var myContent:Object is MovieClip (root) .getChildByName ("ACB" + i);.

    If (myContent! = null)

    {

    myContent.y = Container1.y + int (interFace_XML.comboBox [i] .@yPosition);

    }

    }

    }

    I got the intial positions stored in an xml doc. those in the position of container application did the trick. Still not completely satisfied, but it works for now and allows me to progress. Thanks for your help, I'm this marking as correct.

    ~ Chipleh

  • Custom step problem

    I have a number of custom steps (not inherited, no source code) that we use with TestStand 3.0 and 3.5 versions.  I'm trying to import them into TestStand 4.1, but I have problems.  I know that the location of the files has changed under TestStand 4.x.  They used to live in the TestStand folder, now they live in C:\Documents and Settings\All Users\Documents\National Instruments\TestStand 4.1\Components.  I copied all the DLLs, INI, ICO, files in the correct folders, but some of the measures do not appear in the context menu when you add a step.  I have added custom, four steps two I have visible, two are not.

    The management mode that Custom steps has changed in the TS 4.1?

    Thank you.

    Have you added your pallets of type under C:\Documents and Settings\All Users\Documents\National Instruments\TestStand 4.1\Components\TypePalettes?

    Your pallets of type and the types of step appear in the Palette of Document Type?

    You may also right-click on the palette to insert a step and choose Customize... to update where your step types appear in the Insert palette.

    Hope this helps,

    -Doug

  • Custom EQ problem

    Hey all,.

    I just got my 8 GB player v2 of detonators and discovered a problem with the custom EQUALIZER setting. The song cut off permanently when being read. It plays fine in all other preset EQ settings (even if it sounds ugly).

    Thanks for any help.

    Make sure that the plug of your headphones is inserted completely into the outlet. They are extremely tight plant. This could be the cause of your problem. Try to twist as you push on it to ensure that it is firmly in place.

  • Changing custom field problem Listener

    I created a custom field that works as a button. He painted a bitmap to the screen. And when it focuses it changes the color of the image. However, I try to add a field change listener to it. I looked on the forum and found this code.

    protected boolean navigationClick(int status, int time)
    {
         fieldChangeNotify(1);
         return super.navigationClick(status, time);
    }
    

    It works but I have a problem. You see, my button now push a small screen, thin in the stack that has another button of the same type on it (custom button). At the moment it is the only button on this screen, which means that it has the focus. But it seems that once my button has the focus, I can click anywhere and it is always enabled. I only want to be activated when I touch it. Any suggestions? Here is my code

    public class MenuButtonField extends Field
    {
        Bitmap imagePic;
        Bitmap highlightedPic;
        public MenuButtonField(String imageName, String focusedImg)
        {
            super();
            imagePic=Bitmap.getBitmapResource(imageName);
            highlightedPic=Bitmap.getBitmapResource(focusedImg);
        }
    
        public void layout(int width,int height)
        {
            setExtent(20,80);
        }
    
        public boolean isFocusable()
        {
            return true;
        }
    
        public void drawFocus(Graphics graphics, boolean on)
        {
            paint(graphics);
        }
    
        public boolean touchEvent(TouchEvent message)
        {
            int type=0;
            type=message.getEvent();
            if(type==TouchEvent.CLICK)
            {
                fieldChangeNotify(1);
                return true;
            }
            else{
                return false;
            }
        }
    
        protected boolean navigationClick(int status, int time) {
            fieldChangeNotify(1);
            return super.navigationClick(status, time);
        }
    
        protected void paint(Graphics g)
        {
    
            g.drawBitmap(0, 20, 20, 80, imagePic, 0, 0);
    
            if(this.isFocus())
            {
                g.drawBitmap(0, 20, 20, 80, highlightedPic, 0, 0);
            }
    
        }
    }
    

    PLEASE HELP ME

    I found help here
    http://supportforums.BlackBerry.com/T5/Java-development/navigationClick-invoked-when-clicking-outsid...

    The position of Scribe the Lion was the solution.

  • Development/unfocus field custom button problem

    Hi all

    I have something weird happens.  I have a custom button field that swaps the images based on a focused state or blur.  I have been using this field custom for awhile now, and I have never had any problems.  Imagine the following provision:

    ______________    ________________________

    | Custom button |    | BasicEditField |

    ------------------------    ------------------------------------------

    When my screen is launched, the focus is on the custom button.  If I move the trackball in a downward movement, the focus is taken the custom button, and its background image changes adequately to what has been defined in the untargeted State.  The BasicEditField then has the focus.  This is the correct behavior.

    If, however, I move the trackball in a movement to the right to the BasicEditField, then the BasicEditField will indeed get the focus, however the custom button field always displays its "highlight" picture  Using print statements, I was able to determine that when I move in a movement to the right with the trackball, the custom field button loses the focus and then gets the focus back to back, that's why it shows the highlighted image.

    Additional info:  This isn't an issue on touch devices, and custom button Manager is a TableLayoutManager.

    Any ideas why this might be happening?  Here's the code to my custom button field:

    public class BitmapButtonField extends Field {
        private String text = "";
        private Bitmap bitmap;
        private Bitmap bitmapHighlight;
        private Bitmap b;
        private boolean highlighted;
    
        public BitmapButtonField(String image, String imageHighlight, long style) {
    
            super(style | Field.FOCUSABLE);
    
            this.bitmap = Bitmap.getBitmapResource(image);
            this.bitmapHighlight = Bitmap.getBitmapResource(imageHighlight);
    
            b = bitmap;
    
        }
    
        public BitmapButtonField(String text, String image, String imageHighlight,
                long style) {
    
            super(style | Field.FOCUSABLE);
    
            this.text = text;
            this.bitmap = Bitmap.getBitmapResource(image);
            this.bitmapHighlight = Bitmap.getBitmapResource(imageHighlight);
    
            b = bitmap;
    
        }
    
        protected void drawFocus(Graphics graphics, boolean on) {
            // Do nothing
        }
    
        public int getPreferredHeight() {
            return bitmap.getHeight();
        }
    
        public int getPreferredWidth() {
            return bitmap.getWidth();
        }
    
        protected void layout(int width, int height) {
            setExtent(getPreferredWidth(), getPreferredHeight());
        }
    
        protected boolean navigationClick(int status, int time) {
            fieldChangeNotify(1);
            return true;
        }
    
        protected void onFocus(int direction) {
            b = bitmapHighlight;
            invalidate();
            System.out.println("FOCUSED");
    
        }
    
        protected void onUnfocus() {
            b = bitmap;
            invalidate();
            System.out.println("UNFOCUSED");
        }
    
        protected void paint(Graphics graphics) {
    
            int topTextPadding = (b.getHeight() - getFont().getHeight()) / 2;
            int sideTextPadding = (b.getWidth() - getFont().getAdvance(text)) / 2;
    
            graphics.drawBitmap(0, 0, getWidth(), getHeight(), b, 0, 0);
            graphics.setColor(Color.WHITE);
            if (text.length() > 0) {
                graphics.drawText(text, sideTextPadding, topTextPadding,
                        Graphics.ELLIPSIS, b.getWidth());
            }
        }
    }
    

    Have you looked at navigationMovement in the TableLayoutManager?  I confess that I rewrote it because it handles no left and right as I wanted.  Perhaps, you might be able to do the same thing.

  • visibility of custom dialog problem

    Hello

    I used a dialog box custom in my project to a pop up. I used the tutorial of the custom dialog box. Depending on whether, when the dialog box appears, the back groundpage will be inactive and when the dialog box is closed, which becomes active. My question is, when I click on the 'OK' button in the dialog box, the background page is not turned in the first press itself. It seems that, after awhile, the inactive background color became more dark or black color, and I need to continue to press the ok button in the dialog box several times to close the box.

    No idea how to get rid of this?

    It's the happening bcz every time when you go to the third page, the signal connects again and again. If you need to cut the signal back to the third page. This is how you handle this

    paneProperties: {NavigationPaneProperties}
    ButtonBack: {ActionItem}
    onTriggered: {}
    myApp.mySignal.disconnect (showPrompt)
    yourNavPaneId.pop ();
    }
    }
    }

    Place this code in your page 3, and I hope this will solve your problem.

    Please like this if you are answered.

  • Custom DropDownCellRenderer problem

    I'm trying for a few hours now to create a drop-down list that uses a custom converter to display colors (images will eventually become).

    This is the converter class:

    package UI.Renderers
    {
        import flash.display.Sprite;
    
        import qnx.ui.display.Image;
        import qnx.ui.listClasses.DropDownCellRenderer;
    
        public class IconListRenderer extends DropDownCellRenderer
        {
            private var img:Image;
            private var cell: Sprite;
    
            public function IconListRenderer()
            {
                super();
                img = new Image();
                cell = new Sprite();
            }
    
            override protected function onAdded():void{
                super.onAdded();
                if(this.data == null)
                    return;
                cell.graphics.clear();
                cell.graphics.beginFill(data.color, 1);
                cell.graphics.drawRect(3, 5, this.width - 7, this.height - 10);
                cell.graphics.endFill();
                /*this.addChild(this.cell);
                img.setImage(data.icon);
                img.width = 32;
                img.height = 32;
                img.x = (this.width - 32)/2;
                this.addChild(this.img);*/
            }
    
            override protected function onRemoved():void{
                super.onRemoved();
                this.removeChild(this.cell);
            }
        }
    }
    

    It was based on the examples in this thread. That's how I applied the converter and set up my instance of drop-down list:

    var dp:DropDown = new DropDown();
    dp.setListSkin(IconListRenderer);
    dp.rowHeight = 32;
    dp.width = iconLabel.width;
    dp.x = iconLabel.x + iconLabel.width;
    dp.y = iconLabel.y;
    var dataProvider:DataProvider = new DataProvider();
    dataProvider.addItem({label: "test1", color: 0xFF0000});
    dataProvider.addItem({label: "test2", color: 0x00FF00});
    dp.dataProvider = dataProvider;
    addChild(dp);
    

    The problem that I see is: the data is still nowhere in the onAdded method in my renderer. Any ideas on that?

    Hey zezke,

    My guess would be that the class of cell converter is under went changes since the thread on that you linked to has been worked. the flow of methods has probably changed. However, there was a post yesterday that renaun posted which seems to match what you want to achieve. It looks very good and very probably help here.

    Here is the link:

    http://supportforums.BlackBerry.com/T5/Tablet-OS-SDK-for-Adobe-Air/using-QNX-image-and-imagecache-in...

    hope that helps. Good luck!

  • Mobile with customer AnnyConnect problem

    Problem with any client of annyconnect cisco, password assistance '[' domain '] ' {open and close the hook set} is not authenticated when we use customer annyconnect. Is this bug or there is restriction of using special characters in customer AnnyConnect?

    Here's how to message that is displayed in the history.

    Please enter your username and password.

    Authentication failed.

    Authentication failed.

    Yes, there is a bug related to the use of special characters. It is documented here:

    http://Tools.Cisco.com/support/BugToolKit/search/getBugDetails.do?method=fetchBugDetails&bugId=CSCtn75204

    "It was noted only to apply with"&"and"<" characters="" but="" it="" may="" also="" apply="" to="" the="" brackets="" you="" see.="" can="" you="" upgrade="" to="" the="" current="" anyconnect="" release="" and="" see="" if="" it="" works="">

  • Support problems, CC LR update problems, customer service problems

    I tried several times to download creative cloud. It all started when you try to install the latest update of possessing LR component HDR. When the update has not taken effect, I tried to open CC who did not. I ran the CC cleaning tool following the instructions. I uninstalled LR and CC the computer think a 'clean slate' can solve the problem... but it didn't. I came up with in the last attempt and 50 error code an A12E1 error code. If anyone can help me that would be great, as it appears that Adobe is not interested in any type of customer support, happy to take your money and get the CC community make this part of their work for them

    A12... Download & install error http://forums.adobe.com/thread/1289484

    -A12... discussion http://forums.adobe.com/thread/1045283?tstart=0

    Error 50 https://forums.adobe.com/thread/1432237

  • Customer subscription problem - kiosk

    We received a complaint from a customer yesterday, saying that after the purchase of a subscription in November (that we sell), the December issue, which should appear as granted, presented with the button buy and subscribe instead. As a first time user, she clicked on buy and has been charged. We asked if perhaps there were multiple users signing in and out with their accounts iTunes on the iPad, and she said that it was only his.

    Everyone knows a similar problem? We looked at our back-end, and aside from the price, we expected in iTunes Connect, has not changed anything else.

    The increase in prices lead to the automatic cancellation of the subscription. I am facing this offline.

  • InDesign CS6: Custom preflight problems

    Hello:

    I can create a new custom preflight profile, but when I apply it to a document, InDesign freezes.

    I tried various documents.

    I tried just add minor controls to the preflight profile, but always without success.

    Thank you

    Cam

    CS6 on OSX 10.8

    It turns out that it is a police problem. I couldn't have a corrupt police who was specced to the file. I couldn't save IDML, export history or much else. I had to rebuild the file.

    Thanks Steve

  • (URGENT) Skining of components (datagrid &amp; combobox) problem

    Hello

    I m using FLASH CS3, I used a Datagrid and Combobox components Panel and just add data inside that.

    setupComboBox();
    function setupComboBox (): void
    {
    cb.setSize (200, 22);
    CB.prompt = "select a credit card;
    cb.addItem ({label: "MasterCard", data: 1});
    cb.addItem ({label: 'Visa', data: 2});
    cb.addItem ({label: "American Express", data: 3});

    }
    Import fl.controls.DataGrid;
    Import fl.controls.dataGridClasses.DataGridColumn;
    Import fl.data.DataProvider;
    import fl.events.DataGridEvent

    var dp:DataProvider = new DataProvider();
    dp.addItem ({col1: "1.A", col2: "point 1.B", col3: "point 1.C"});
    dp.addItem ({col1: "item 2.A", col2: "point 2.B", col3: "item 2.C"});
    dp.addItem ({col1: "item 3", col2: "point 3.B", col3: "item 3.C"});
    dp.addItem ({col1: "point 4.A", col2: "item 4.B", col3: "item 4.C"});
    myDataGrid.addColumn ("col1");
    myDataGrid.addColumn ("col2");
    myDataGrid.addColumn ("col3");
    myDataGrid.dataProvider = dp;
    myDataGrid.setSize (300, 200);
    myDataGrid.move (10, 10);

    It seems to work very well.

    My problem is, I want two different types of skining of two different (DataGrid & Combobox) components. in the same fla.

    .. for example, if the datagrid control have the type of skin color gray and combobox have skin color black type.

    Can someone has an idea?

    I also tried like this

    cb.setStyle ("upSkin", CellRenderer_upSkin2)

    It should be more like:

    cb.dropdown.setRendererStyle("upSkin", CellRenderer_upSkin2);
    
  • repeater nested with custom component problem

    Hello
    I'm really stuck with this problem and no help from you guys is greatly appreciated.
    For starters, I have a simple external nested xml file for the data: "book.xml".
    <? XML version = "1.0" encoding = "UTF-8"? >
    < book >
    < section >
    S1 < sectionnumber > < / sectionnumber >
    < chapter >
    C1 < chapternumber > < / chapternumber >
    < / section >
    < chapter >
    C2 < chapternumber > < / chapternumber >
    < / section >
    < / section >
    < section >
    s2 < sectionnumber > < / sectionnumber >
    < chapter >
    < chapternumber > c3 < / chapternumber >
    < / section >
    < / section >
    < / book >

    I also have a main app (NestedRepeater.mxml) of a control relay that contains a custom (Section.mxml) mxml component:
    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml " xmlns:comps ="rate"layout ="absolute">
    < mx:XML id = "data" source = "" data / book.xml "/ >"
    < mx:VBox >
    < mx:Repeater id = dataProvider = "{data.section"Repeater1"}" >
    < sectionNumber = "{Repeater1.currentItem.sectionnumber comps: Section}" / > "
    < / mx:Repeater >
    < / mx:VBox >
    < / mx:Application >

    And in my component (Section.mxml) custom, I have another relay that want it for the chapter in each section as a < mx: state > for the user to be able to show/hide the chapters in each section.

    <? XML version = "1.0" encoding = "utf-8"? >
    "< mx:Canvas xmlns:mx = ' http://www.adobe.com/2006/mxml" > "
    < mx:Script >
    <! [CDATA]
    [Bindable]
    public var sectionNumber:String;
    []] >
    < / mx:Script >
    "" < mx:XML id = 'data' source = '... / data / book.xml "/ >
    < mx:VBox >
    < mx:Panel id = "panel1" layout = "absolute" title = "Section" >
    < mx:VBox >
    < mx:Label text = "{this.sectionNumber}" / >
    < mx:Button id = "btnArticles" label = "show chapters" click = "this.currentState = 'Chapter'" / >
    < / mx:VBox >
    < / mx:Panel >
    < / mx:VBox >
    < mx: states >
    < name mx: State = 'Chapter' >
    < mx:AddChild relativeTo = "{panel1}" position = "after" >
    < mx:VBox >
    < mx:Repeater id = dataProvider = "{data.section.chapter"Repeater2"}" >
    < mx:Panel layout = "absolute" title = "Chapter" >
    < mx:Label text = "{Repeater2.currentItem.chapternumber}" / > "
    < / mx:Panel >
    < / mx:Repeater >
    < / mx:VBox >
    < / mx:AddChild >
    < / mx: State >
    < / mx: states >
    < / mx:Canvas >

    So the problem I have is the relationship of each chapter to its parent section, when I run the application, the result is:
    S1
    C1
    C2
    C3
    S2
    C1
    C2
    C3

    The correct output I want based on the xml, the data provider must be and don't have not all the chapters in each section:
    S1
    C1
    C2
    S2
    C3

    If anyone has any suggestion, would be appreciated greatl.
    Thank you

    Yes, do not try to get new data into the component, simply pass the crux of the entire section in the custom component:

    In this component has a public property or a setter function:
    [Bindable]
    public var xmlSection:XML;

    This variable will now have this in it:


    S1

    C1


    C2

    Repeater2 is therefore:





    Very simple, you follow? I do it very often. Repeater, XML and custom components are an impressive combination.

    Tracy

  • XML to the combobox problem

    I am fill combobox from xml file, right

    My case: I'm reading the xml file that look like this

    < Download >
    < pallets >
    < pal30 name = "First map" >
    map1.XML < color > < / color >
    < / pal30 >
    < pal20 name = 'Second map' >
    map2.XML < color > < / color >
    < / pal20 >
    < / pallets >
    < / upload >

    by
    < mx:XML format = "e4x" id = "mapp" source="Database/Map.xml"/ >
    < mx:ComboBox = "263" x = "10" width = "194".
    ID = "myCb" enabled = "true".
    dataProvider = "{mapp.". Upload.palettes.*.@name} ">"
    < / mx:ComboBox >

    So, what I try to do is when I click on "Foreground" my ComboBox, I want to have 'map1.xml' 'printed' in a mx:Text control

    I can get the attribute name in the box by < mx:Text text = "{myCb.selectedItem}" / > that might be in this case 'Foreground' and I want to have 'map1.xml' when I click on 'First map' in the combobox.

    Do I have to create a kind of out of my xml file where values are tied together as
    {name: 'Foreground', file:"map1.xml'}



    The problem is that your nodes are not always named. If you had and then you could set the dataProvider = "{mapp.pal}" and labelField="@name" then the selectedItem.colors would be what you want. "

    When you used the expression you have created an array of values name only - there is no context longer. Try this instead:

    In a Script block:

    private void paletteName (point: Object): String
    {
    .@name XML (element) return;
    }

    private function test (event: Event): void
    {
    output. Text = XML (event.target.selectedItem). * Colors;
    }

    Now the selectedItem will be the XML for a node pal so XML (selectedItem). * Colors will be map1.xml or map2.xml.

Maybe you are looking for

  • Help identify the Satellite Pro 2100 download driver

    I have a Satellite Pro (marked below as a PS210E-00C3G-EN and a P4 2000/256/30 G, 15XT, CDW, LW). I think it's a satellite Pro 2100, whatever. Problem I have is that when it comes to downloading the drivers, I can't find anything approaching this mod

  • local calls without the + 1?

    I don't seem to be able to make local calls within US 10-digit (area code + phone number) without Skype adding + 1 which in turn prevents calls to go through. Anyone else having this problem? A solution of Workaround available? Thank you!

  • iMac early 2008 fails to boot completely

    Hi all - I have an early 2008 iMac 3.06 GHz 24 "model that starts more completely. The system gets to the Apple screen and the progress bar comes in at halfway and there it is. I had replaced the original HARD with a SDD drive and had not had any pro

  • How can I change the language of Windows Vista on Satellite A300-1CO

    last summer, I was in the Portugal and I bought a laptop Toshiba A300-1CO in hopes that we can to change the language to English or Roman without reinstalling Windows. Can someone help me?

  • Color Laserjet Pro M452nw: Not accepted print job

    Just installed a new HP Color Laserjet Pro M452nw today, it connects using wireless to my network.  I followed the installation instructions and everything seemed fine and I was able to print the test sheet.  However, when I try to print a document f