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

  • SEARCH
  • Home
  • 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 1059111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:07:26+00:00 2026-05-16T18:07:26+00:00

I have a VGroup in my application that contains several custom components of type

  • 0

I have a VGroup in my application that contains several custom components of type MyComponent. Now I have a delete method in MyComponent that should once ran delete the element from the VGroup. I know I should use parentDocument.vgroupId.removeElement() but what to pass as a reference?

Note: I want to do the delete within a method from MyComponent

UPDATE: here is my source:
In my main application

<s:VGroup id="vgroupId" width="100%" height="100%" />

Now I add my custom component as:

 var cust:FunctionElement = new MyComponent(); // MyComponent extends spark Panel
 vgroupId.addElement(cust);

And from MyComponent I call

parentDocument.vgroupId.removeElement(this) // get this error => TypeError: Error #1034: Type Coercion failed: cannot convert global@5ed30d1 to mx.core.IVisualElement.

If I cast it as this as IVisualElement I get an error that it is equal to null

  • 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-16T18:07:27+00:00Added an answer on May 16, 2026 at 6:07 pm

    This example will show how you can do it..

    ExampleApp.mxml

    <?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">     
        <fx:Script>
            <![CDATA[
                protected function button1_mouseUpHandler(event:MouseEvent):void
                {
                    vgroup.addElement(new MyComponent());
                }
            ]]>
        </fx:Script>
        <s:VGroup id="vgroup" top="30" />
        <s:Button label="Add" mouseUp="button1_mouseUpHandler(event)"/>
    </s:Application>
    

    Define MyComponent.mxml like this…

    <?xml version="1.0" encoding="utf-8"?>
    <s:Group 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="100" height="35">
        <fx:Script>
            <![CDATA[
                import spark.components.VGroup;
                protected function button1_mouseUpHandler(event:MouseEvent):void
                {
                    // A few useful traces to see what's what and where.
                    trace(this);
                    trace(this.parent);
                    trace((this.parent as VGroup).getElementIndex(this));
                    // But all we actually need is ...
                    var vgroup:VGroup = (this.parent as VGroup);
                    vgroup.removeElement(this);
                    // (this.parent as VGroup).removeElement(this); // Would also work fine.
                }
            ]]>
        </fx:Script>
        <s:Button mouseUp="button1_mouseUpHandler(event)" label="Kill me!"/>
    </s:Group>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a group of spark label components within a VGroup. Is there a
I have a spark Window which contains a VGroup. Inside the VGroup are a
Have a query that should hopefully be nice and simple to answer. I have
I have a list that uses a itemRendererFunction to get custom item renderers. Is
I have a VGroup, and inside of it I am going to have a
I have code like the following: <s:VGroup gap=10 id=group height=100%> <s:Label text=This is page
Have I in some way delete this Task or it is self-destroyed? Task.Factory.StartNew(() =>
I have a flex 4.5 php app that runs perfectly on localhost. When I
I have a cursor that gets data and fetches it into @data_table. Then in
Have got a method which returns IEnumerable<User> which I have been using Linq /

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.