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