Skip navigation
karenehartley
Currently Being Moderated

Error on actionscript state change using RemoveChild

Apr 12, 2012 3:42 PM

Tags: #flex #actionscript #removechild #4.6 #states

I have an actionscript component (a View) with a number of states defined in the following manner:

 

var stateDefault:State = new State();

stateDefault.name = "DefaultState";

stateDefault.overrides = new Array();// array of IOverride

states.push(stateDefault);

stateDefault.overrides.push(new RemoveChild(btn_MatterPicker_Search));

 

When attempting to run the line

     currentState = "DefaultState";

the error below occurs.  I'm hoping that someone has a simple solution to this - the only thing I can think of at the moment is to write my own state change handler that adds and removes the appropriate items from each state manually.  Does anyone have a more elegant solution?  (The code needs to remain as actionscript, can't switch to mxml.)

 

Here's the error:

Error: removeChild() is not available in this class. Instead, use removeElement() or modify the skin, if you have one.

    at spark.components::Group/removeChild()[E:\dev\4.y\frameworks\projects\ spark\src\spark\components\Group.as:2136]

    at mx.states::RemoveChild/apply()[E:\dev\4.y\frameworks\projects\framewo rk\src\mx\states\RemoveChild.as:150]

    at mx.core::UIComponent/applyState()[E:\dev\4.y\frameworks\projects\fram ework\src\mx\core\UIComponent.as:10741]

    at mx.core::UIComponent/commitCurrentState()[E:\dev\4.y\frameworks\proje cts\framework\src\mx\core\UIComponent.as:10487]

    at mx.core::UIComponent/setCurrentState()[E:\dev\4.y\frameworks\projects \framework\src\mx\core\UIComponent.as:10323]

    at mx.core::UIComponent/set currentState()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\U IComponent.as:6425]

    at com.chromeriver.components.matter::MatterSearchBar/setDefaultState(). ..MatterSearchBar.as:288]

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points