Frump1 extends Frump

My Kind of Linkage Box
The art people hand you a Fla with a dozen symbols that you want to manage with a single ActionScript class. Now what was that trick Moock described?
The symbols are Frump1, Frump2, Frump3 and so on. They do complex things. Lots of ActionScript.
Frump1 could never be mistaken for Frump2 by the art people. But to your ActionScript they do the same things.
You don’t want to repeat the ActionScript each time, copy and paste, copy and paste, Frump1, Frump2…. Later if you get something wrong you have to fix it again in every Frump.
No, you want Frump1 extends Frump. The family resemblances go into Frump, the Frump ActionScript class. That leaves Frump1 and Frump2 looking bare, just the skeleton of an ActionScript class. Fine, if they only differ outwardly, as drawn by the art people.
So you click Linkage for Frump1 in the library. Linkage links sketches to scripts, art work to ActionScript. Puts the motors inside the dolls for Tim Burton’s Corpse Bride.
Frump1, the box says up top, the symbol name from the library. Movie Clip, you say, not Button or Graphic. Export for Actionscript, check. Export in frame one, check.
Now the empty box for Class. You want to type:
Class: Frump1
Base Class: Frump
But the box below already says:
Base Class: flash.display.MovieClip
There’s a way. You’ve done it many times. But you can also get this wrong, and go around and around for the next hour. You’ve done that too, many times.
What was the trick Moock showed us? The little rain dance you do. Give Flash one of these and let Flash generate the other. But which?
Flush that, Flash.
So I wrote my own Linkage Box.
Now, after I write the ActionScripts for Frump and Frump1 (which extends Frump), I pull up my Linkage Box.
I select Frump1 in the library and select SetClass from the Command menu.
A box asks me to confirm
Symbol: Frump1
Then in my own Linkage Box I write:
Class: Frump1
Base Class: Frump
“Done!”
So here’s the Command. SetClass, a JavaScript inside Flash.
To put this on your Command list, put SetClass.jsfl in a Flash folder. Mine is
c:\Users\John\AppData\Local\Adobe\Flash CS3\en\Configuration\Commands
Two files actually. One is SetClass.xml, which makes the box you see:
<dialog title="Options" buttons="accept,cancel"><grid><columns><column /><column /></columns><rows><row><br /></row><row><label value="class:" /><textbox id="aClassName" value="" /></row><row><label value="base class:" /><textbox id="aBaseClassName" value="" /></row></rows></grid></dialog><!-- Copyright 2008 John Hicks, Cerium Component Software Inc. Available under the terms of the Creative Commons Attribution-Share Alike 3.0 Unported license: http://creativecommons.org/licenses/by-sa/3.0/ -->
Then SetClass.jsfl
function setClass() {var aDoc = fl.getDocumentDOM();var aLib = aDoc.library;if(aLib.getSelectedItems().length == 0) {alert("Select library symbol!");return;}var aLibraryItemName = aLib.getSelectedItems()[0].name;alert("symbol: " + aLibraryItemName);var aInput = flash.getDocumentDOM().xmlPanel(fl.configURI + "Commands/SetClass.xml");if(aInput.dismiss != "accept") {alert("Ok, cancel.");return;}aLib.selectItem(aLibraryItemName);aLib.setItemProperty("linkageExportForAS", true);aLib.setItemProperty("linkageExportInFirstFrame", true);aLib.setItemProperty("linkageClassName", aInput.aClassName);aLib.setItemProperty("linkageBaseClass", aInput.aBaseClassName);alert("Done!");}setClass();<!-- Copyright 2008 John Hicks, Cerium Component Software Inc. Available under the terms of the Creative Commons Attribution-Share Alike 3.0 Unported license: http://creativecommons.org/licenses/by-sa/3.0/ -->