I have a number of movieclips on the stage, each has a number of child MCs. The parent MC represent files and the child MC represent targets. This is a tool for “mapping out” a story-lin scenario graphically and producing a XML file.
So the user drags these files onto the stage and then can draw lines from one file to another to map path to other files based on student choices.
I am using 2 dictionairies. Each file has a dictionay associated with it which holds another dictionary and then this dictionary has an array in it. The array will ultimately have information such as “choice1, filename”. I am using dictionaries for their object indexing feature.
I am having a problem keeping track of this stuff. Could someone help? I realize that this is a bit of a mess. This is not all of the code but I believe this is what is needed.
var fileMap:Dictionary = new Dictionary();
var choiceMap:Dictionary = new Dictionary();
var fileMapRef:Object = new Object();
var choiceMapRef:Object = new Object();
function drawStart(evt:MouseEvent):void
{
beginDrawPoint.x = evt.currentTarget.parent.x + evt.currentTarget.x;
beginDrawPoint.y = evt.currentTarget.parent.y + evt.currentTarget.y;
clip.graphics.lineStyle(2,0x333333);
clip.graphics.moveTo(beginDrawPoint.x, beginDrawPoint.y);
fileMapRef = evt.currentTarget.parent;
choiceMapRef = evt.currentTarget;
//trace(fileMap[evt.currentTarget.parent][evt.currentTarget]);
}
function drawFinish(evt:MouseEvent):void
{
//trace(fileMap[fileMapRef][choiceMapRef]); //= evt.currentTarget.parent.name;
var forCounter:uint = 0;
for (var prop:* in fileMap)
{
forCounter++;
//trace(prop); // traces: [object Object], [object Object]
trace(fileMap[fileMapRef][prop]); // traces: 1, 2[choiceMapRef]
}
trace(forCounter);
endDrawPoint.x = evt.currentTarget.parent.x + evt.currentTarget.x;
endDrawPoint.y = evt.currentTarget.parent.y + evt.currentTarget.y;
clip.graphics.clear();
var lineContainer:Sprite = new Sprite();
lineContainer.graphics.lineStyle(2,0x333333);
lineContainer.graphics.moveTo(beginDrawPoint.x, beginDrawPoint.y);
lineContainer.graphics.lineTo(endDrawPoint.x, endDrawPoint.y);
lineContainer.addEventListener(MouseEvent.CLICK, handleRemLine);
this.addChild(lineContainer);
//trace(fileMap[fileMapRef][choiceMapRef]);
}
function handleSubmitFile(evt:Event):void
{
var choiceVsFile:Array = new Array();
var numberChoices:uint = mcAttribute1.comboAttribute.selectedItem.data;
fileMap[file] = choiceMap;
//choiceMap = [[],[]];
if (mcAttribute1.txtAttribute.text != "" && mcAttribute1.comboAttribute.selectedIndex != -1)
{
var fileHeight:int = file.height;
file.txtFileName.text = file.name = mcAttribute1.txtAttribute.text;
var mcFileTarget1:mcFileTarget = new mcFileTarget();
mcFileTarget1.x= file.width/2;
mcFileTarget1.y = 0;
//mcFileTarget1.label = file.name;
mcFileTarget1.addEventListener(MouseEvent.MOUSE_DOWN, drawStart);
mcFileTarget1.addEventListener(MouseEvent.MOUSE_UP, drawFinish);
file.addChild(mcFileTarget1);
var fileArray:Array = [file];
for(var i:uint = 0; i<numberChoices; i++)
{
var mcChoiceTarget2:mcChoiceTarget = new mcChoiceTarget();
mcChoiceTarget2.x= (file.width/numberChoices * i) + (5) + (3 * i) ;
mcChoiceTarget2.y = fileHeight;
mcChoiceTarget2.label = "choice"+(i+1);
mcChoiceTarget2.addEventListener(MouseEvent.MOUSE_DOWN, drawStart);
mcChoiceTarget2.addEventListener(MouseEvent.MOUSE_UP, drawFinish);
file.addChild(mcChoiceTarget2);
//choiceMap[mcChoiceTarget2] = [mcChoiceTarget2.label];
choiceVsFile* = [mcChoiceTarget2.label];
choiceMap[mcChoiceTarget2] = choiceVsFile;
fileMap[file][mcChoiceTarget2] = choiceMap;//"qwf"+i + file.txtFileName.text;
//fileArray[file]* = [mcChoiceTarget2.label, file.name];
//trace(fileMap[file][mcChoiceTarget2]);
}