Monday, September 5, 2011

Flash Combo Box corrupted when loading

There are lot of issues with Flash AS2 components, It is all because of the uncleared global styles. Components styles are stored in a global variable, Which is not getting cleared even after removing the entire component from the SWF file.

Because of this Some time the dynamic components are displayed as corrupted. For example we can take ComboBox component. Test the following scenario in you flash file.



  1. Create a New Flash file, Drag and drop two ComboBox V2 component in to your stage and add some values to display

  2. Make one Combo enabled and other one as disabled.

  3. Save it as myCombo.fla, Now publish the file and close it.

  4. Create a New Flash file and name it ComboTest.fla and place a Button on stage, and place an empty movieclip say "content_mc" on stage.

  5. To the button Provide the functionality to unload the Existing content from content_mc and load the "myCombo.swf". The unloading is usefull to remove the existing content before loading a new one.

  6. Now Publish your ComboTest.fla file

When you run the file, it will display the Combobox element perfectly without any error. But if you unload the content and reload the SWF, Oops the disabled Combobox displayed as corrupted. The Dropdown part of the disabled combo displays as wiered boxes.

This problem is due to uncleared global Skin variables. You can test this in your Flash file by doing this simple step.


Load a Component into a MovieClip, Then remove it completely from your swf file. Now Click on "Debug" Menu button in your SWF window and select "List Variable" menu item.

It will display you a number of uncleared Variables. Few important variables are listed below
_global.mx;
_global.style;
_global.cascadingStyles;
_global.styles;
_global.skinRegistry;
_global.getStyleCounter;


To reset your skin problems you need to clear the "skinRegistry" variable to do this just delete the variable

delete _global.skinRegistry;

So, If you are facing problem with component skinning, Just delete the skinRegistery and load your component.

Thats it, it will work