by David LeMieux
Recently, I came upon an interesting problem regarding Flash components. It wasn't the first time something like this had happened. In brief, I was moving a design created in a Flash 10 environment in to a Flash 9 coding environment. Perhaps my situation was unique (or I had some kind of bad setting) but I thought that the Flash IDE would be smart enough to know what I was trying to accomplish.
Here is what I saw:
I had a design done with Flash 10 selected as the publish type. I began copying assets from the stage and library in to another movie clip that I had set up to publish with Flash 9. I was moving all those things because the designer had comped the design with timeline animations and the like in order to illustrate how it should work. This is how we roll at work. Our process usually works well. The business team gets a good feel for how things will look and feel, then I take the animated prototype and start putting in all the wiring. This usually means retooling some of the layout (nesting clips differently, movie things in to the Library for later export, etc.).
Part of the design had a component button. Not a SimpleButton, but a button component from the component library. Everything copied just fine. In the preview it all looked great. The trouble came when I compiled. I was given no errors, but the button lost its label. In fact, when I traced the value of the label instead of "Browse," the value set in the component inspector, it came back as "Label." Somehow it was being reset and then taking on some kind of default behavior.
Here is what I tried:
I tried myriad things to solve this problem. I removed the button and all the assets from the library and tried importing a new one. I tried taking it off the stage and adding it dynamically (addChild) in the code. I even tried leaving it on the state, duplicating it with the code, removing the original and adding the duplicate. Each time the same thing.
Then, in a kind of "ah ha!" moment, I turned the publish setting to Flash 10 and all my troubles went away. Why? I have no idea. I can only assume that something in the setting or some part of the component library knew it had been originally set in Flash 10 and was therefor using resources not available to Flash 9. Eventually we made a new SimpleButton and used that instead.
Here is what I conclude:
This button issue is just one in a long list of complaints I have against Flash Components. Don't get me wrong, components are great. When they work they work well. They are very customizable. They are robust. They do the job and make development time faster... unless they don't work which is, for me, often the case.
Another downside to components is the massive amount of file size they add to your Flash files. At work we have one particular file that is served a large number of times each day. It used to have a Loader component as well as a in-house-developed component. The file size was around (when all is said in done) about 120Kb. We removed all the components and replaced them with classes (MovieClipLoader, XML, and a component-to-class conversion of the in-house one) and now the same product can do much, much more and weighs in at about 60Kb, half the original size because we removed components.
Actually, we did implement a bunch of new features, so really removing the components got the size down to about 25Kb, or about one fifth the size. We just removed two components. Over millions of downloads that saves use quite a bit of bandwidth. (example: If the file had been accessed 1,000,000 times in a day, with components that is 14GB of data transfer. Without components that is 3GB of data transfer)
I wish I could have some kind of solution for this problem. Some clever hack to make components work. I do not. I welcome any suggestions, though. I want to contribute to the Flash community, no just whine all the time.
Components should be easy to work with but aren't. When they work they are great and really help speed up development time. Unfortunately they are bulky as far as file size is concerned, and if you are dealing with any high amount of traffic their benefit is quickly outweighed by the extra expense they will bring to your bandwidth bill. Bandwidth aside, the built in Flash components are often buggy or don't seem to work they way they should. Maybe I am "doing it wrong," but with nearly ten years of Flash experience under my belt I would hope that by now I would know what I was doing.
If you are having trouble with a Flash component stop blaming yourself, it probably isn't you. It's them.