Adding+Helper+Classes+to+Reduce+File+Size

Adobe Technical Support is adamant that the source file size of any included or imported .as file must not exceed 32K (see
 * []**)

Helper .as files can be created with chunks of code.
> class edu.clips.draw.//**helper**//.ubShape_Helper1 extends MovieClip { > and > static var symbolName:String = "__Packages.edu.clips.draw.//**helper**//.ubShape_Helper1"; >> this.helper1 = ubShape_Helper1.create(this, "h1", {}); >> This needs to be done before the first method that is called by it. If the class creates movieclips at specific depths, then you will need to be careful to put the helpers at at depth that won't contradict their name. >> e.g., >> function set(newShape, newSize, newColour){ >> this.helper1.set.call(this, newShape, newSize, newColour); >> } >> The call statement is used to scope "this" in the helper's function as the instance of the original class. >>  private var tracev:Function; >> private var addGroupAccoutrement:Function; >> private var addAccoutrement:Function;
 * 1) Copy the top part of the original class to a new file and save it in a helper subfolder in the directory of the current class, e.g., classes/edu/clips/draw/helper
 * 2) Change the name of the class (e.g., from ubShape to ubShape_Helper1) in the class statement and create statements etc. There seems to be some sort of size limit that makes a class with a length like edu.clips.graph.helper.ubSkipCountingTool_Helper1 too long.
 * 3) Add **//helper//** to the class definition path e.g.,
 * 1) Delete the code inside the constructor function. Delete getVersionInfo.
 * 2) Remove comments for the properties.
 * 3) Search for any existing .call methods and any MouseManagers or other things that already use scope-changing calls.
 * 4) To move the code from inside a method like set(parm1, parm2) to the helper class do the following:
 * 5) Add an import statement at the top of the class, e.g., import edu.clips.draw.helper.ubShape_Helper1;
 * 6) Add a private var for the new instance of the helper. e.g., private var helper1:ubShape_Helper1;
 * 7) create an new instance of the helper in the constructor. e.g.,
 * 1) copy methods from the original class to the helper - something around 600 lines is about the size (27K) desired.
 * 2) replace the inside of the method in the original class with an equivalent call to the helper.
 * 1) If the function returns a value, then return should be added in front of the call. This is one reason why is it good to declare the return type with the variable so that someone doesn't spend two hours figuring out why a class is broken.
 * 2) Test with an .fla that uses the class. Note any compiler errors.
 * 3) You may need to add declarations to functions that don't appear in the helper. e.g.,
 * 1) Functions in the helper class will need to be public.
 * 2) Be very careful of references to static variables or functions, these will have to have the main class' name used with them.

Changing classes to use "CLIPS_Empty"
Each class and helper that extends Movieclip should be changed as follows - all of which can be accomplished by doing a


 * window.run_command("update_all_versions_verboses_creates") **

> code format="actionscript" public static function create(container:MovieClip, instanceName:String, initObj:Object, depth) { //this function will attach a ubOptionButton object on the container with the instance name symbolName = "CLIPS_Empty"; symbolLinked = Object.registerClass(symbolName, symbolOwner); if (depth == undefined) { var mc = container.attachMovie(symbolName,instanceName,container.getNextHighestDepth,initObj); } else { var mc = container.attachMovie(symbolName,instanceName,depth,initObj); }   if (mc == undefined) trace("Warning:  ubOptionButton_Helper1.create failed for "+container+"["+instanceName+"] - do you have CLIPS_Empty in the library?"); return ubOptionButton_Helper1(container[instanceName]); } code > The first two lines are new. The two "var mc = " are new. The "if" is new and its trace should reflect the class name > **window.run_command("update_all_creates")** > > > code format="actionscript" public static function getVersionInfo:String { return "ubOptionButton_Helper1 Version November 23, 2011"; } code > and each **main class** should call the getVersionInfo method of all its helpers (that is right ubSCT....). > code format="actionscript" /**Used to determine which version of the class is actually stored and used public static function getVersionInfo:String { trace(ubOptionButton_Helper0.getVersionInfo); trace(ubOptionButton_Helper1.getVersionInfo); trace(ubOptionButton_Helper2.getVersionInfo); return "ubOptionButton Version November 23, 2011"; } code > **window.run_command('update_all_version_dates')** > > > code format="actionscript" /**used to decide whether more traces should appear. */ public var verbose:Boolean = false; code > **window.run_command("update_all_verboses")** > >
 * 1) The create function should be changed to look like:
 * 1) Each **helper class** should have a static getVersionInfo method.
 * @returns (String) Details of the current version. */
 * 1) Each class should have an instance variable declaration

Work Schedule
Make sure that all classes are 32K or less
 * ubFractionMultOpTool - Greg
 * ubMenuHelper2 - Greg
 * ubToolContainer - Greg
 * ubMenuHelper2 - Greg
 * ubToolContainer - Greg


 * ubShape - Ross (done)
 * ubFractionInput - Markus (done)
 * ubFraction - Markus (done)
 * ubFraction_Helper1 - Markus (done)
 * ubMovieClipTransform - Ross (done)
 * ubMultipleSelect - Greg (done - Ross)
 * ubEstimator - Markus (done)
 * ubOptionButton - Ross (done)
 * ubNumberLine2 - Ross (done)
 * ubSkipCountingTool and several helpers - Greg (done)
 * ubSuperHops & ubSuperHops_Helper2 - Greg (done)
 * ubFractionSquare and helpers - Greg (done)
 * ubFractionStripToolBox and helpers - Bailey (and Greg) (done)
 * ubFractionOpTool and ubFractionOpToolSimulator (Greg) (done)
 * ubIntegerOpTool (Greg) (done)