BIT-101 [2003-2017]

Custom Parameter UIs for Components in Flash CS3


When you are making a UI component in Flash, you can specify certain public variables or getter/setters as Inspectable with metadata. This changes them into “component parameters” that show up in the Properties Panel and / or the Component Inspector Panel. If you don’t like the UI that the panels provide, you can create a custom SWF to use in its place. This is known as a “Custom UI”. This SWF gets loaded into the Properties Panel or the Component Inspector Panel. You would supply some kind of UI for getting and setting the various component parameters. This has existed for many versions of Flash, probably way back to Flash 5 Smart Clips.

Unfortunately, this mechanism is kind of broken in Flash CS3. The problem is that a custom UI uses a special variable, _root.xch, as a bridge between the ui itself and the Flash IDE. This _root.xch object is not supported in AS3 though. I thought I could get around this using MMExecute and JSFL. I got almost all the way there, too. I can find the selected item on stage, which is always the component that is linked to the custom ui. I can read its parameter list. I can access individual parameters in the list. I can access the individual properties of each parameter. I can get and set the value of each parameter. Great! Except for one minor glitch: when you use a custom ui, the “name” property of all parameters is – for some reason – empty. Thus, if you have more than one parameter, there is no way to tell which is which. There may be other glitches beyond that, but that one pretty much killed me.

There are a couple of options here.

  1. You can do what John Grden did with his PV3D component and make a Window SWF that does exactly what I just described with JSFL. As long as you don’t set a custom UI, all the parameters work exactly as expected. The thing I don’t like about that is that it may not be so obvious to the end user that that Window SWF even exists. With a custom UI, it either shows up in the Properties Panel, or you get a big button telling you to open your Component Inspector, where the custom UI is.

  2. You can use AS2 to code your custom UI, using the _root.xch object as we have for a while. I guess that’s not a horrible option. A custom UI shouldn’t be some massively complex application. You’re just setting and getting a few values.

Anyway, I just thought I’d mention this, as I spent quite a bit of time trying to work this one out. Finally after talking to John Grden extensively, I went to Grant Skinner, who got me in touch with Nivesh at Adobe, who verified that this is indeed a bug in the Flash IDE and gave me the solutions I just mentioned. Hopefully this saves someone else some time in the future.

« Previous Post
Next Post »