I am trying to ascertain which sub array from the main array received a click event. My approach below makes use of a switch case at the end for this purpose;
Code:
var localSegment:Array = [segment1.system_Cab, segment1.programs_Cab, segment1.userFiles_Cab, segment1.rollback_Cab]
var external_MediaSegment:Array = [segment2.externalHD_Cab, segment2.virtualDisk_Cab]
var network_LocationSegment:Array = [segment3.homeServer_Cab, segment3.wifiFlashdrive_Cab, segment3.encrivaPlay_Cab]
var superVolumes:Array = [localSegment, external_MediaSegment, network_LocationSegment]
for (var i:Number = 0; i < superVolumes.length; i++ ){
for (var j:Number = 0; j< superVolumes[i].length; j++){
var fmCabinent = superVolumes[i][j];
fmCabinent.addEventListener(MouseEvent.CLICK, openCabinet);
}
}
var arrayContainer:Array; //create a var to reference the clicked item's parent array
var curIndex:int; //a temporary variable to store the index of clicked object
var targetCabinent;
function openCabinet (e:MouseEvent):void{
targetCabinent = e.currentTarget;
for (var i:Number = 0; i < superVolumes.length; i++ ){
curIndex = superVolumes[i].indexOf(e.currentTarget); //see if the sub array contains the clicked item
if(curIndex > -1){
//if the sub array contains the clicked item (e.currentTarget)
arrayContainer = superVolumes[i][curIndex];
break; //stop looping since you found the array
}
if (targetCabinent.currentFrame == 1){
targetCabinent.play();
}else {
fmCabinent.addEventListener(Event.ENTER_FRAME, closeCabinet);
}
switch(arrayContainer){
case localSegment:
trace("You clicked an item from local segment");
break;
case external_MediaSegment:
trace("YOu clicked something from media segment");
break;
case network_LocationSegment:
trace("You clicked something from network_LocationSegment");
break;
}
}
} //stage.addEventListener (MouseEvent.CLICK, outFocusClose);
function closeCabinet (e:Event):void{
if (targetCabinent.currentFrame > 1){
targetCabinent.prevFrame();
}else{
fmCabinent.removeEventListener(Event.ENTER_FRAME, closeCabinet);
//stage.removeEventListener (MouseEvent.CLICK, outFocusClose);
}
}
However I keep getting a type error in the output tab that says:
TypeError: Error #1034: Type Coercion failed: cannot convert Phoenix_Assetbuilder_fla::Systemfilescabinet_17@5d 1b5661 to Array.
Thanks for your input, it would have been smart approach except that the trace logic was just for debugging, to test weather flash could identify what array the clicked object belong to. In essence the idea is that clicking and object from say; externalMedia array will execute a function which handles a chain of movie clip tweens and so the only way to know if it would be able accomplish running the functions made for it is by testing it through the trace statement. Don't know if I am making sense?
Not really no.
If you mean importing arrays I am positive that you can create and fill the holding arrays and reference them.
For output purpose you just swap the traces for some other code or call another function etc etc