How+to+CLIPS+Tools

Useful external links:
 * Zen Docs for ubToolContainer and ToolTalk
 * Check Your Understanding (activity 8.1.6 from Multiplying Fractions cluster) - example of using Tool Container and CLIPS Tools with feedback

Main sections of this How To wikipage:


 * **Tool Container** || **Tools and ToolTalk** || **Cluster 8 Code Snippets** ||
 * * Setup of Tool Container
 * Simulating Tool Container / Tool selection clicks
 * Tool Container onEvents
 * Setup of Tool Container "My Activity Tools"
 * Hops Example || * Setup of Tools
 * Common Tool Talk - Feedback levels
 * Common Tool Talk - doFeedback commands
 * Extra info available about state of tools || * Flash Tool Icon
 * Setup of Tools with Pods
 * Setup of Tools to be Embedded
 * Auto do solution upon Tool Selection
 * Auto advance when Feedback animation done ||

= **Tool Container** = The Tool Container is now a part of the standard CLIPS wrapper and mini-wrapper, and is designed to be available whether accessing an activity from the big wrapper directly from the MathCLIPS.ca website, or whether using an activity in standalone mode. There is also a standalone version of the CLIPS Tools Container that can be used in a separate browser window, or downloaded separately onto any computer desktop (and then imported into an IWB notebook lesson).

An optional tab can be created (and made the default tab opened up initially) called "**My Activity Tools**" which will contain a subset of available tools, customized to work specifically with this particular activity (and potentially customized from scene to scene of an activity.)

Setup of Tool Container ^
The Tool Container will automatically exist and be connected to the Tools icon in the right panel of CLIPS icons. No extra coding is necessary to make it available.

If your activity needs to customize the Tool Container, or respond to how it is used, or track the tools that are created with it, then you will need to use some of the following code snippets.

The following code is in frame 1 of the actions & initialize layer, but commented out until needed. Uncomment the sections you need to use or modify. Note: toolsPod is a standard variable set in scene01.as. code format="actionscript" // hide tools pod if it was left open at end of previous scene (optional) toolsPod._visible = false;

// clearing My Activity Tools - tab will not show up - tool container will show only default tools (optional) toolsPod.setActivityTools ( [] );

// adding a listener so that this scene can "hear" when a new tool has been selected (optional) toolsPod.addListener( this );

// defining the event function to pick up the ToolPod's broadcasts whenever a tool has been selected and is now ready to use this.onToolReady = function(which, whatTool, whatPod, toolType, newOrExisting, stdOrActivity){ tracev("\nTOOL SELECTED : " + which + " has selected a tool of type " + toolType + " : instance = " + whatTool +        ", tool pod = " + whatPod + " , newOrExisting = " + newOrExisting + " , stdOrActivity tool = " + stdOrActivity); }

code //NOTE: For code to CREATE a customized "My Activitiy Tools" tab, see the section on Setup of "My Activity Tools" later on this page//

Other useful code to further customize the Tool Container code format="actionscript" // customize the position of the tools pod for when it is opened initially (optional) toolsPod._x = 180; toolsPod._y = 70; code

A more fullsome event function for when a new tool is selected and ready to use: code format="actionscript" this.onToolReady = function(which, whatTool, whatPod, toolType, newOrExisting, stdOrActivity){ // add listener to the new tool just created (optional) whatTool.addListener( this ); // add listener to pod that contains tool just newly created (optional) whatPod.addListener( this );

if (whatTool.constructor.name == "ubFractionStripToolBox" ) { // do something special here for this one specific type of newly created tool }

// get list of currently open tools var openToolsArray = toolsPod.getListOfOpenTools; // Check for other open tools, and do something special if one type of tool is found (optional - example) for (var i = 0; i < openToolsArray.length; i++ ) { if (openToolsArray[i] instanceof ubFractionSquare) { // do something special for this type of tool }   }    // Check for other open tool pods ... and minimize if you find them (optional) // - useful if you only want 1 open tool at a time var openToolPodsArray = toolsPod.getListOfOpenToolPods; for (var i = 0; i < openToolPodsArray.length; i++ ) { if (whatPod != openToolPodsArray[i] ) openToolPodsArray[i].minimize; }

} code

code format="actionscript" // Some tools (in development stages at least) require this event to be defined so that their innards do not get skewed // when pods containing them are resized // There may be other reasons you want to know when a pod is resized as well ... and this event will keep you informed this.onPodResize = function ( which ) { trace("RESIZING pod " + which + " and insides " + which.getInsides ); which.getInsides._x = 0; which.getInsides._y = 0; }

code

NOTE: Another event has been defined **onToolRequested** that is fired the instant a button is clicked in the Tool Container. It might be useful to capture this event especially in the case of tools that take a while to fully bake, since the onToolReady event is NOT fired until the tool is totally ready to use. The **onToolRequested** event, in those cases, will allow instant feedback to occur, and inform the user that their request is being processed (and be patient). Back to Top

Simulating Tool Container / Tool selection clicks ^
The Tool Container has some functions built into it that will allow you to simulate clicking on its round wrench icon to activate it, selecting a specific tab, and even choosing a particular tool that is available. code format="actionscript" toolsPod.simulateToolIconClick(true, true); // 1st true = onlyIfNeeded,  2nd true = desiredVisibility of ToolContainer after the click

code //Note 1: IF onlyIfNeeded = true, then If desiredVisibility and the Tool Container's current visibility are the same, no animation will occur.// //IF onlyIfNeeded were false, then an animation would occur regardless of what was on stage or not.//

code format="actionscript" toolsPod.simulateToolTabPress( "Fractions" ); // simulates clicking on the Fractions tab of the Tool Container

code //Note 1: If the Tool Container is not visible, it is first opened up (using the animation of simulateToolIconClick routine)// //Note 2: If "My Activity Tools" is visible, and the "Fractions" tab is hidden, then the "Index" tab is initally clicked, followed by a click on the "Fractions" under-tab//

code format="actionscript" toolsPod.simulateToolButtonPress("My Activity Tools", "Fraction Strips" ); // simulates clicking on the button to open up a new Fraction Strips tool from "My Activity Tools" tab

code //Note 1: If the Tool Container is not visible, or "My Activity Tools" is not the currently selected tab, they are made visible and selected using the animations from simulateToolIconClick and simulateToolTabPress// //Note 2: An actual tool pod and working tool is created after the animation is done, and the Tool Container is once again hidden.// Back to Top

Tool Container onEvents ^
The Tool Container can be listened to for events that are broadcast. Not all events that are broadcast need be listened to specifically, but the following are those that are available.

code format="actionscript" onToolContainerChanged (which, how ) code broadcast whenever ths Tool Container's visibility is changed. which = pointer to Tool Container how = visibility of Tool Container now code format="actionscript" onToolContainerTabSelected (which, tabName ) code broadcast whenever a new tab is selected

code format="actionscript" onToolRequested( which, toolType, newOrExisting, stdOrActivity )

code broadcast whenever a new tool is selected from the Tool Container (occurs the instant a button is pressed in the Tool Container, and is fired BEFORE the tool is actually created) which = pointer to Tool Container toolType = name of the label of the button pressed in the Tool Container (e.g. "Fraction Strips" ) (String) newOrExisting = String "new" / "existing" - depending on whether this is a fresh tool, or a previously created one just re-opened stdOrActivity = String "std" / "act" - depending on whether it came from a generic tab, or from "My Activity Tools" tab

code format="actionscript" onToolReady( which, whatTool, whatPod, toolType, newOrExisting, stdOrActivity ) code broadcast whenever a new tool is selected from the Tool Container (and new tool created, or a previous one re-opened) which = pointer to Tool Container whatTool = pointer to new tool whatPod = pointer to pod containing new tool toolType = name of the creator function of the tool (e.g. "ubFractionStripToolBox" ) (String) newOrExisting = String "new" / "existing" - depending on whether this is a fresh tool, or a previously created one just re-opened stdOrActivity = String "std" / "act" - depending on whether it came from a generic tab, or from "My Activity Tools" tab code onSimulationToolIconClicked(which, endVisibility) code broadcast whenver the tool icon (wrench icon) is clicked via a simulation call (i.e. not clicked directly by user) which = pointer to Tool Container endVisibility = whether tool container is visible after the click or not Back to Top

To setup "My Activity Tools" you must send the Tool Container an array of objects or an array of arrays. Each object/array in the big array corresponds to a tool that you wish to add to "My Activity Tools", and has the information needed for the ubButton inside the tab panel, as well as the details needed to create the tool itself

code format="actionscript" // return tools pod to standard generic form toolsPod.setActivityTools ( [] ); // hides "My Activity Tools", returns all tabs and tools to standard view code OR code format="actionscript" // customize tools pod - command to populate the "My Activity Tools" tab // activityTools is an array of objects or an array of arrays toolsPod.setActivityTools ( activityTools ); code

(NOTE about Import statements: You need an import statement before creating the activityTools array to be able to import the class of each class referenced, especially classes like ubIcon, ubColour and Fraction. The likely culprits are listed below.) code format="actionscript" import edu.clips.fraction.Fraction; import edu.clips.draw.ubIcon; import edu.clips.util.ubColour; code

code format="actionscript" // setup Activity Tools // supply the category and name of each tool and any overriding properties for the tool, icon or pod // the name must match exactly with the name in the standard tools var activityTools:Array = [       {            category:"Fraction", toolName: "Hops on a Line" },       {            category:"Fraction", toolName: "Slicing Wholes" },       {            category:"Fraction", toolName: "Fraction Squares", toolInit:{_x:15, _y:15, smallestSize:15}, iconInit:{wid:30}, podInit:{Podwidth:350} }   ];

// populate the "My Activity Tools" tab toolsPod.setActivityTools ( activityTools );

code

The setActivityTools can be sent an array of arrays instead. code format="actionscript" var activityTools:Array = new Array; activityTools.push(   [     "Fraction",        "Pictorial Model",        this.createPicModel,        {_x:350, _y:20, statusBarText:"Pictorial Model - virtual representations of physical objects that can be manipulated" },        {name:ubIcon.drawHappyFaceIcon, size:20, wid:20, _x:-10, _y:-10, dy:7},        {PodallowMove:false, PodhtmlText:"Pictorial Model ", PodallowTitleMove:true, Podwidth:300, Podheight:200,_x:400 , _y:55 }    ] ); code

Note: In the above example, the tool defined for "My Activity Tools" is the "Pictorial Model", and its creator function is a custom function (createPicModel) that would be defined in this scene directly (on this frame). WARNING: Any custom function you define to make up your own customized tools must create the tool totally from scratch (using classes for components is okay), but NOT rely on Library items (except for standard Template items) since the big wrapper will not have access to customized Library objects inside an activity.

If "My Activity Tools" is to be consistent throughout an entire activity, then the code to define it should be in one place, and called only if needed. In this scenario, it is recommended to use the top level Scene 1 - actions layer - Frame 1 as the place for the code. Check out this example. code format="actionscript" // IN Top level Scene 1 - actions layer - Frame 1 // setup Tools Pod var activityToolsDefined:Boolean; // flag to determine whether "My Activity Tools" is setup
 * Programming Suggestion:**

var activityTools:Array = [ {category:"Fraction", toolName: "Fraction Squares"}, {category:"Fraction", toolName: "Fraction Strips"}, {category:"Fraction", toolName: "Hops on a Line"} ];

function setupActivityToolsTab { if (!activityToolsDefined == true) { // customize tools pod - command to populate the "My Activity Tools" tab toolsPod.setActivityTools(activityTools); activityToolsDefined = true; } }

code

code format="actionscript" // In EACH SCENE - actions & initialize layer - Frame 1 this._parent.setupActivityToolsTab; // calls the setup routine at the topmost level, which does something the first time, sets the flag, then ignores it every other scene.

code //Note: This call to setupActivityToolsTab must go in every scene (except Start and End page scenes) so that Tool Container will be setup even if someone loads the activity and uses the scene selector to jump around in non-standard order//

To deconstruct the array required to setup each individual tool inside "My Activity Tools, the elements are: [tabNames, toolName, toolCreatorFunction, toolInitObject, iconInitObject, podInitObject]

//NOTE 1: One property of toolInitObject must be statusBarText : String - this will be the text that appears when you rollover the button in the Tool Container// //NOTE 2: If you need to add your tool to the stage with NO POD showing (and have it stuck to the stage and not moveable or resizeable or closeable), then use the following additional properties in the toolInitObject:// //NOTE 3: If you wish to use podTarget : with a movieclip other than "this" (which represents the scene you're on), you can actually attach a tool to any movieclip - for example the tab panel of a tab container.//
 * tabNames** - a single String or Array of Strings that correspond to the names of the tabs where this tool can be found. (Even though you are defining tools for My Activity Tools, you need to define their "home" tab where they would belong in the standard Tool Container here)
 * toolName** - String - this is what will appear on button used to create the tool
 * toolCreatorFunction** - for most tools created from a class, this will be a .create statement. Note however that it can be a reference to a function defined on the scene.
 * toolInitObject** - the init object required to create the tool - with all the specifics to customize the tools look and feel.
 * affixToTarget : true,**
 * podTarget : this,**

Back to Top
 * iconInitObject** - to draw the icon on the button inside the Tool Container
 * podInitObject** - to customize the size, location, and other setup parameters of the pod that will contain the tool

Hops on Line Example
code format="actionscript" import edu.clips.fraction.Fraction; import edu.clips.fraction.ubFractionOpTool;

// hide tools pod if it was left open at end of previous scene (optional) toolsPod._visible = false;

// setup Activity Tool var activityTools:Array = [       {            category:"Fraction", toolName: "Hops on a Line", toolInit: { allowLineConfiguration:false, initialFraction: new Fraction(3, 4), numLines:0, //using our own line ftoolInit:{numParts:4, numWholes:2}, sHopsInit:{autoScaleWidth:false} },           podInit:{ PodallowTitleMove:false, playerInitObj:{podInitObj:{PodcloseVisible:true}} }       }    ];

toolsPod.setActivityTools(activityTools);

// adding a listener so that this scene can "hear" when a new tool has been selected (optional) toolsPod.addListener( this );

//the line for the stage ubFractionOpTool.create(this, "fracTool2_mc",   {_x:-65,    _y:200,    title:"",    maxx:175+500, //175 for dead space at beginning    unitLength:100,    oneLineOnly:true, //Hops Tool only uses the top line    ubFractionNumberLineVersion: 2, //uses ubNumberLine2    use_ubFractionInput: true, //uses ubFractionInput    show1:"N",    showButtons:"",    allow1:" point line input  unitpt strip",    showLabelDividers:"",    useMaxPixels:true,    fraction1:[0,0,1, true],    initialMixed:true,    allowSub:false}    );

// broadcasted when a tool is clicked on this.onToolRequested = function(which, toolType, newOrExisting, stdOrActivity){ trace("\nTOOL Requested : " + which +          "\nhas selected a tool of type " + toolType +          "\nnewOrExisting = " + newOrExisting +          "\nstdOrActivity tool = " + stdOrActivity); } //broadcasted when a tool is ready to use this.onToolReady = function(which, whatTool, whatPod, toolType, newOrExisting, stdOrActivity){ trace("\nTOOL READY in Activity Example: " + which +         "\nhas selected a tool of type " + toolType +          "\ninstance = " + whatTool +          "\ntool pod = " + whatPod +          "\nnewOrExisting: " + newOrExisting + ", stdOrActivity tool: " + stdOrActivity); if (toolType == "ubSkipCountingTool" && stdOrActivity == "act"){ trace("Registering my ubFractionOpTool"); this.mySCT = whatTool; this.mySCT.registerSuperHops(this.fracTool2_mc); } } code Back to Top = **Tools and ToolTalk** =

Each CLIPS tool that has been created and now is available from the Tool Container has some standard behaviour associated with it, as well as individual properties and methods that allow it to function uniquely.

Setup of Tools ^
Tools that are created from the Tool Container have a set standard form when they are initially created, as determined by the Tool Container, or in the case of those tools created from "My Activity Tools" tab, determined by the .setActivityTools parameters. Check out the ZenDocs for specific details about specific tools.

Each tool that is created with the Tool Container has a pointer ( .pod ) to its enclosing pod. code format="actionscript" var myTool:MovieClip; // create a variable pointer to be used for tool in the scene // bunch of stuff happens .... // ... myTool.pod._x = 200 ; // Move the pod for myTool to a new location  (and the tool inside it of course)

code Similarly, each pod has a pointer directly to the tool contained within it (.tool ) Using the example above, code format="actionscript" myTool.pod.tool == myTool code //(though that's dangerous to use such circular definitions, especially in for loops !)//

To listen for when new tools are created from the Tool Container, setup a listener to the Tool Container, and then capture the onToolReady event code format="actionscript" var currentTool:MovieClip;

// adding a listener so that this scene can "hear" when a new tool has been selected (optional) toolsPod.addListener( this );

// defining the event function to pick up the ToolPod's broadcasts whenever a tool has been selected this.onToolReady = function(which, whatTool, whatPod, toolType, newOrExisting, stdOrActivity){ tracev("\nTOOL Ready : " + which + " has selected a tool of type " + toolType + " : instance = " +       whatTool + ", tool pod = " + whatPod + " , newOrExisting = " + newOrExisting + " , stdOrActivity tool = " + stdOrActivity); currentTool = whatTool; }

code //Note 1: In the brief example above, a pointer (currentTool) is assigned to the most recent tool created (and will be reassigned if a new tool is created later)// //Note 2: A fuller example of the onToolReadyevent with some sample code is available above.//

If a tool needs to be customized to a specific scenario, that can be done in the onToolReady function initially, or later on, using the pointer to the tool.

To get a list of tools that are currently open, query the Tool Container using the getListOfOpenTools function. (Note - this will return the list of all tools that are currently open on the stage that were created using the Tool Container. code format="actionscript" var openTools : Array = toolsPod.getListOfOpenTools;

code //Note 1: Any tools that are built into the activity scene, and were not initially created via the Tool Container, will not show up in this array. Tools created using the simulation commands with the Tool Container WILL show up in the array.//

To get a list of ALL tools that were created (whether or not they are currently open), use the getListOfAllTools function. code format="actionscript" var allTools : Array = toolsPod.getListOfAllTools;

code Similarly, there are corresponding functions that will query the Tool Container for the pods that contain said tools. (Very useful if you want to minimize all or hide all pods that contain tools to clean up the stage for the next scene.) code format="actionscript" var openToolPods : Array = toolsPod.getListOfOpenToolPods; var allToolPods : Array = toolsPod.getListOfAllToolPods;

code Back to Top

Common Tool Talk - Feedback levels ^
The standard set of routines is called ToolTalk, and most of them are accessed via the **.toolTalk** object (lowercase t in tool, uppercase T in Talk).

All tools have a **.toolTalk.getFeedbackLevel** routine defined, which will return an object that includes a level, as well as a number of other pieces of information that can be used by the activity to determine the proper course of action / feedback to continue with.

For Multiplying a Whole Number by a Fraction, the feedback levels are as follows:
 * ~ Level ||~ Description of Feedback Level defined ||
 * < 0 ||< Haven't started using the tool ||
 * < 1 ||< Haven't added to workspace, design is OK ||
 * < 2 ||< Started but all wrong ||
 * < 3 ||< Started with some right and some wrong ||
 * < 4 ||< Started with some right, wrong mix ||
 * < 5 ||< Started but too little ||
 * < 6 ||< Started but too much ||
 * < 7 ||< Created with enough stuff but not simplified (does not apply to Hops) ||
 * < 8 ||< Complete and simplified ||
 * < 9 ||< Complete and simplified and wholes separated ||

code format="actionscript" var currFeedback : Object = myTool.toolTalk.getFeedbackLevel("x", 3, new Fraction(2, 3) );

if (currFeedback.level < 8 ) { trace("You are not quite complete yet."); } code This code will return traces based on each level from the above table. It uses a lot of if statements but it works!!! If you prefer you can use an array. code format="actionscript" function checkModel { //checks to see if user uses the model correctly //!!!!!! need to define currentTool = whatTool; inside the //   this.onToolReady = function(which, whatTool, whatPod, toolType, newOrExisting, stdOrActivity) //   function defined on frame 1  !!!!! //this is checking to see if the user has modelled 3 x 2 1/3 properly - you may need to adjust this accordingly //need to import edu.clips.fraction.Fraction; so that new Fraction works var currFeedback:Object = currentTool.toolTalk.getFeedbackLevel("x", 3, new Fraction(2, 1, 3)); //x means multiply, 3 is the one number and 2 and 1/3 is the other number that should be modelled trace("current Feedback is "+currFeedback.level); if (currFeedback.level == 0) { trace("Not using tool yet."); } else if (currFeedback.level == 1) { trace("Haven't added to workspace, design in OK"); } else if (currFeedback.level == 2) { trace("Started but all wrong"); } else if (currFeedback.level == 3) { trace("Started with some right and some wrong"); } else if (currFeedback.level == 4) { trace("Started with some right, but not correct mix"); } else if (currFeedback.level == 5) { trace("Started but too little"); } else if (currFeedback.level == 6) { trace("Started but too much"); } else if (currFeedback.level == 7) { trace("Created with enough stuff but not simplified"); } else if (currFeedback.level == 8) { trace("Complete and simplified"); } else if (currFeedback.level == 9) { trace("Complete and simplified and wholes separated"); } else { trace("feedback level is not defined in chart"); } } code

operator : String ("x") num1 : Number ( 3 ) num2 : Fraction initObject : Object (not used currently, but may be needed for future implementation)
 * getFeedbackLevel** takes 3 input parameters ( a 4th one is defined in the official function definition, but not currently used)


 * getFeedbackLevel** returns the following pieces in its return object:

.level : Number .designValue : new Fraction (undefined for some tools, such as fraction strips) .grandTotalMatch: Boolean (whether the sum is correct - use getSum to determine sum)

In addition, each tool keeps additional information, typically used for doFeedback, some of which might be interesting to an activity programmer, such as

.compResult = compareObject resulting from methods like ubObject.compareFractionArrays, which may include: Back to Top
 * .missingArray
 * .extraArray
 * .matchingArray
 * .correctSum
 * .numInMatching : Number
 * .numInMissing : Number
 * .numInMatching : Number
 * .numInExtra : Number
 * .onlyAcceptableExtraFractions : Boolean

Common Tool Talk - doFeedback commands ^
All tools have a **.toolTalk.doFeedback** routine defined, which will manipulate a tool to bring it into a representation of the expression requested, up to the feedback step specified. Hops - highlight input fraction || Hops - gather units at front of number line ||
 * ~ Feedback command ||~ Description of Feedback ||~ Example of Action ||
 * < PointAtStartingPoint ||< Point at designer spot || Fr Strips - highlight fraction strip values to be used
 * SetDesign || set designer to a value || Set the input fraction to the correct value ||
 * < FlashExtras ||< flash incorrect pieces || Highlight and flash the extra bits on the stage that represent incorrect unwanted fractions ||
 * < Delete Extras ||< delete incorrect pieces || Delete those extra unwanted bits ||
 * < FlashDesign ||< flash insert thing || Flash the proper design fraction, or builder, or insert button ||
 * < NextStepOfBuild ||< put one on / insert 1 || Drag one copy of the designed square / strip / hop onto the tool ||
 * < Build ||< build all || Finish the building of the model (usually as separate pieces) ||
 * < Complete ||< complete (or simplify the model) || Collect the parts of the model together (Fr Strip - in a single strip ) ||
 * < CollectWholes ||< separate wholes || Fr Strip - separate the wholes from the partial fractions (only appropriate for mixed number examples)

code format="actionscript" myTool.toolTalk.doFeedback("x", 3, new Fraction ( 2, 3) , {type:"Complete", clear:true, animationType:"fast"} ); code

operator : String ("x") num1 : Number ( 3 ) num2 : Fraction initObject : Object (determines how the feedback animation is processed) initObject.type : String (the specific Feedback command as entered in the table above - one word using CamelCase) initObject.clear : Boolean (if TRUE, then clear the model completely and start from scratch, if FALSE, work with what's there and adjust as needed) initObject.animationType : String (how the animation is to happen. "slow", "fast", "normal", "instant" ... and in the future perhaps "playerAutoPlay", "playerSetup" ) initObject.thisTypeOnly:Boolean - whether or not to do all actions leading up to requested command. (Default : FALSE - ie - always do animations that build to final command. If TRUE, then only do this specific animation based on command, irregardless of actual status of tool. Warning - this could have dangerous side effects, or, lead the tool to show misleading or incorrect models of an operation
 * doFeedback** takes 4 input parameters

At the beginning of each scene the following variables are setup by scene01.as: code format="actionscript" import edu.clips.transform.ubWait; // will wait for 15 seconds for a click on the wrench icon... and if nothing happens in that time, will flash a yellow circle around it ubWait.waitFor( [toolIcon]); code
 * toolsPod** is assigned to the Tool Container (to hide it or show it instantly in the middle of a scene you can thus use toolsPod._visible = false (or true) )
 * toolIcon** is assigned to the actual wrench icon button in the wrapper

Setting up My Activity Tools - tools to be used within pods
code format="actionscript" // setup MY ACTIVITY TOOLS on the Tools Pod // Note: see above for the simpler way to defined activityTools var activityTools:Array = new Array; // setup array to hold definitions of new tools to add

/////////////////////////////////////////////////////////// // POD CONTAINED TOOLS /////////////////////////////////////////////////////////// activityTools.push([ "Fraction", "Designer Squares", ubFractionSquare.create , { dev:"review",_x:0, _y:0, size:50, smallestSize:30, builderInit:{Podwidth:135, Podheight:120} , statusBarText:"Designer Squares - for modelling addition of fractions or x of a whole number and a fraction by shading parts of squares", maxWholes:2, snapNextPosition:false}, {name:ubIcon.drawFractionSquaresIcon, wid:40, ht:20, dy:7} , { _x:305 , _y:125,Podwidth:400, Podheight:205, PodallowMove:false, avoidJiggleOnResize:true, PodallowTitleMove:true, minimizeOnClose:true, PodnoFit:true , allowInsideResize:false}] ); activityTools.push([ "Fraction", "Hops on a Line", ubSkipCountingTool.create , {dev:"released", statusBarText:"Hop Graphing tool - build hops along a number line to model fraction operations (in dev)", maxx:500, menuInit:{titleBackgroundColour:ubColour.CLIPSBLUE, titleActiveColour:ubColour.CLIPSBLUEbrighter , titleOverColour:ubColour.CLIPSBLUEbrighter , podInit:{statusBar_fmt:{color:ubColour.WHITE} } , titleInit:{FTtext_fmt:{color:ubColour.WHITE} }, dialogInit:{FTtext_fmt:{color:ubColour.WHITE}  } } }, {name:ubIcon.drawSkipCountingIcon, wid:100, ht:20, dy:7}, { _x:335 , _y:55, PodallowMove:false, PodallowTitleMove:true, createsOwnPod:true, ownPodTarget:"toolPod_mc", PodtitleColour:ubColour.CLIPSBLUE, statusBar_fmt:{color:ubColour.WHITE} , PodborderColour:ubColour.CLIPSBLUE,  onToolReadyFunction:"onSkipCountingToolReady" , playerInitObj:{podInitObj:{PodcloseVisible:true}}}] );

activityTools.push([ "Fraction", "Fraction Strips", ubFractionStripToolBox.create , {dev:"released",_x:0, _y:0, unitLength:80,  stripHeight:12, showGears:true, autoDivideRefBar:true, toolBoxFractions:[1,2,3,4,5,6,7,8,9,10], statusBarText:"Fraction Strips  - virtual manipulatives that can model many types of numbers and operations" }, {name:ubIcon.drawFractionStripsIcon, wid:72, ht:20, dy:7} ,{PodallowMove:false, PodallowTitleMove:true, Podwidth:350, Podheight:200,_x:350 , _y:125, avoidJiggleOnResize:true, PodnoFit:true, allowInsideResize:false, createStatusBar:true, statusBarHeight:18, statusBarInit:{FTmargin:0, FTtext_fmt:{font:"Arial", size:12, color:0xFFFFFF, bold:false }} } ] );

// customize tools pod - command to populate the "My Activity Tools" tab - and revise tools to current version (with pods) toolsPod.setActivityTools ( activityTools, false);

code

Setting up My Activity Tools - tools to be used sans pods - embedded ON the stage
code format="actionscript" // setup MY ACTIVITY TOOLS on the Tools Pod var activityTools:Array = new Array; // setup array to hold definitions of new tools to add

/////////////////////////////////////////////////////////// // ON STAGE EMBEDDED TOOLS ///////////////////////////////////////////////////////////

activityTools.push([ "Fraction", "Designer Squares", ubFractionSquare.create, { dev:"review",_x:0, _y:15, size:50, smallestSize:30, builderInit:{Podwidth:135, Podheight:120} ,affixToTarget : true, podTarget : this, statusBarText:"Designer Squares - for modelling addition of fractions or x of a whole number and a fraction by shading parts of squares", maxWholes:2, snapNextPosition:false, showGears:false}, {name:ubIcon.drawFractionSquaresIcon, wid:40, ht:20, dy:7} , { _x:205 , _y:105,Podwidth:400, Podheight:205, PodallowMove:false, avoidJiggleOnResize:true, PodallowTitleMove:false, minimizeOnClose:true, PodnoFit:true , allowInsideResize:false}] );

activityTools.push([ "Fraction", "Hops on Lines", ubSkipCountingTool.create , {_y:0, _x:0, allowLineConfiguration:false, statusBarText:"Hop Graphing tool - build hops along a number line to model fraction operations" , initialFraction: new Fraction(1,4), numLines:0,  ftoolInit:{numParts:4, numWholes:2}, menuInit:{}, titleInit:{}, sHopsInit:{autoScaleWidth:false}}, {name:ubIcon.drawSkipCountingIcon, wid:100, ht:20, dy:7, _x:20 , _y:65}, { _x:335 , _y:55, PodallowMove:false, PodallowTitleMove:false, createsOwnPod:true, ownPodTarget:"toolPod_mc", onToolReadyFunction:"onSkipCountingToolReady", playerInitObj:{podInitObj:{PodcloseVisible:true}}}] );

activityTools.push(["Fraction", "Fraction Strips", ubFractionStripToolBox.create, {affixToTarget : true, podTarget : this, _x:0, _y:0, unitLength:80, stripHeight:12, toolBoxFractions:[1,2,3,4,5,6,7,8,9,10], statusBarText:"Fraction Strips - virtual manipulatives that can model many types of numbers and operations"}, {name:ubIcon.drawFractionStripsIcon, wid:72, ht:20, dy:7}, {PodallowMove:false, PodallowTitleMove:false, _x:350, _y:95, Podwidth:350, Podheight:220, avoidJiggleOnResize:true, PodnoFit:true, allowInsideResize:false}]);

// customize tools pod - command to populate the "My Activity Tools" tab - and revise tools to current version (with out pods) toolsPod.setActivityTools(activityTools, false); code

Automatically Do Feedback - animate solution - immediately after Tool is Selected
code format="actionscript" // defining the event function to pick up the ToolPod's broadcasts whenever a tool has been selected

this.onToolRequested = function(which, toolType, newOrExisting, stdOrActivity) { // after initial click of button in Tool Container, switch to new frame ... before tool starts baking if ( toolType == "ubSkipCountingTool" && stdOrActivity == "act" ) { this.gotoAndPlay("Hops"); } else if (toolType == "ubFractionSquare" && stdOrActivity == "act" ) { this.gotoAndPlay("Squares"); } }

this.onToolReady = function(which, whatTool, whatPod, toolType, newOrExisting, stdOrActivity){ // when the tool is ready - show the full monty! if (toolType == "ubSkipCountingTool" && stdOrActivity == "act" ){ whatTool.addListener( this ); var myHops = whatTool; myHops.registerSuperHops(this.fracTool_mc); mySuperHops = myHops.superHopsArray[myHops.superHopsArray.length - 1]; fracTool_mc._visible = true;

myHops.enabled = false; // disable the tool so that it can't be manipulated myHops.toolTalk.doFeedback("x", 4, new Fraction ( 1, 4) , {type:"Complete", clear:true, animationType:"fast"} );

} else if (toolType == "ubFractionSquare" && stdOrActivity == "act") { whatTool.addListener( this ); var mySqu = whatTool; mySqu.enabled = false; mySqu.toolTalk.doFeedback("x", 5, new Fraction (2, 5), {type:"Build", clear:true, animationType:"fast"} ); }

// additional else ifs could go here to check for other tools / combinations etc...

// MINIMIZE all other OPEN PODS so the most recently opened tool is the main focus for the scene var openToolPodsArray = toolsPod.getListOfOpenToolPods; for (var i = 0; i < openToolPodsArray.length; i++ ) { if (whatPod != openToolPodsArray[i] ) openToolPodsArray[i].minimize; }

} code

Auto Advance to Different Frame when Feedback Animation is Done
code format="actionscript" // This event is broadcast when a Tool has completed its doFeedback request // (Only tools that have a listener added to them, and have been asked to doFeedback via code will broadcast this) // PLACE this EVENT at the beginning of the FRAME for a SPECIFIC TOOL

onFeedbackDone = function (which, what, feedbackObj) { this.gotoAndPlay( "HopsDone" ); }

code

See list of Object that is returned from getFeedbackLevel

Some tools give additional information, but the standard getFeedbackLevel object contains the following code format="actionscript" var currFeedback : Object = myTool.toolTalk.getFeedbackLevel("x", 3, new Fraction(2, 3) );

// currFeedback.level = level number // currFeedback.compResult = comparison object used to compare the current tool to the desired tool's contents // currFeedback.compOrderlessResult = object resulting from orderless match // currFeedback.numInMatching // currFeedback.numInMissing // currFeedback.numInExtra // currFeedback.onlyAcceptableExtraFractions  : Boolean

code

Stay tuned for more later .... Back to Top