Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:24:53+00:00 2026-05-28T08:24:53+00:00

I works with Flex 4.5 and I like to create a custom dropdownlist. Indeed,

  • 0

I works with Flex 4.5 and I like to create a custom dropdownlist. Indeed, I’d like to show in each line on my dropdownlist a label and a delete button.
The goal is to delete the line on click to delete button.
This look like simple, but I don’t found how to do that.

Thanks for helping

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:24:54+00:00Added an answer on May 28, 2026 at 8:24 am

    You have to jump through a few hoops for this one because DropDownList prevents any MouseEvent.CLICK from an object inside an ItemRenderer from being fired.

    First things first: you will need a custom event for this to work. One that carries your item or at least its index. e.g.:

    public class ItemEvent extends Event {
        public static const REMOVE:String = "itemRemove";
    
        public var item:MyClass;
    
        public function ItemEvent(type:String, item:MyClass, 
                                  bubbles:Boolean=false, 
                                  cancelable:Boolean=false) {
            super(type, bubbles, cancelable);
            this.item = item;
        }
    
        override public function clone():Event {
            return new ItemEvent(type, item, bubbles, cancelable);
        }
    
    }
    

    Then you create a custom ItemRenderer with a ‘delete’ Button that will dispatch this event.

    <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                    xmlns:s="library://ns.adobe.com/flex/spark">
    
        <fx:Script>
            <![CDATA[
                private function remove():void {
                    owner.dispatchEvent(
                        new ItemEvent(ItemEvent.REMOVE, data as MyClass)
                    );
                }
            ]]>
        </fx:Script>
    
        <s:Label id="labelDisplay" verticalCenter="0" left="10" />
    
        <s:Button verticalCenter="0" right="10" width="16" height="16"
                  mouseDown="remove()" />
    
    </s:ItemRenderer>
    

    Important here is that you catch the MOUSE_DOWN event of the Button, since its CLICK event doesn’t fire (as mentioned before). The owner property of the ItemRenderer refers to the List it is a child of.

    Now the last piece of the puzzle. Here’s your DropDownList with custom ItemRenderer:

    <s:DropDownList id="myDropDownList" dataProvider="{dp}"
                    itemRenderer="MyItemRenderer" />
    

    And here’s how you listen for that custom event and remove the selected item:

    myDropDownList.addEventListener(ItemEvent.REMOVE, removeSelectedItem);
    
    private function removeSelectedItem(event:ItemEvent):void {
        var items:IList = myDropDownList.dataProvider;
        var index:int = items.getItemIndex(event.item);
        items.removeItemAt(index);
    }
    

    Because we caught the MOUSE_DOWN instead of CLICK the myDropDownList.selectedIndex property will still be at the previously selected item (or -1 if none was selected). This is why we needed the custom event, because there was no other way of knowing which is the item you want to remove.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am accessing custom UIComponent via SWC file from Flex 3. This component works
I am trying to create a custom component in flex that consists of a
I want to create a custom button in ActionScript. This is my code: import
I've got a Flex 3 project. It works fine. But, I'd like to make
I have created a Flex custom preloader, exactly like it is done in this
I've created something that works like a ToolTip in my Flex application. When I
Does websites created by Flex Builder works on every browsers that use Flash ?
Our flex project, which works fine in its current environment with coldfusion 7 single
I've got a flex component which works pretty well but unfortunately turns into a
Is there a good Flex IDE/development env that works on Ubuntu? Where can this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.