A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Targeting mc's

Threaded View

  1. #1
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540

    Targeting mc's

    Hey everyone, this one has me really confused, been trying for a few days now. Here's my issue, I have some buttons(dynamic mc's) set up with an ROLL_OVER/ROLL_OUT MouseEvent handler and have put them in an array. No problem there.

    Code:
    var btnArray:Array = [];
    for(var i:int = 0; i < 5; i++) {
    	var bg:Bg = new Bg();
    	bg.width = 173;
    	bg.height = 20;
    	bg.x = 25;
    	bg.y = (22 * i) + 40;
    	bg.name = "bg"+i;
    	
    	container.addChild(bg);
    	btnArray.push(bg.name);
    
        bg.addEventListener(MouseEvent.ROLL_OVER, mOver);
        bg.addEventListener(MouseEvent.ROLL_OUT, mOut);
    }
    function mOver(e:MouseEvent):void {
        var twIn:Tween = new Tween(e.currentTarget, "alpha", Regular.easeOut, 0.5, 1, .5, true);
        if(legendArray[idNum][0] == 1) {
            TweenMax.to(dtrArray[0], 1, {tint:0x14170C}); 
        }
        if(legendArray[idNum][1] == 1) {
    	TweenMax.to(dtrArray[1], 1, {tint:0x89FC01});
        } etc...
    }
    function mOut(e:MouseEvent):void {
        var twOut:Tween = new Tween(e.currentTarget, "alpha", Regular.easeOut, 1, 0.5, .5, true);
        TweenMax.to(dtrArray[0], 1, {tint:0x14170C});
        TweenMax.to(dtrArray[1], 1, {tint:0x14170C});
        etc...
    }
    Next, I set up another array to contain some numeric values that will determine if a mc's tint is changed.(0 = doesn't change, 1 = change).
    Code:
    var legArray:Array = [[1,1,1,0,1],[1,1,0,0,1],[1,0,1,1,0],[0,1,1,0,1],[0,1,0,1,1]];
    No issue there either. Next, (this is where questions arise), I dynamically set another group of mc's, and positioned them over the button mc's. So basically 5 mc's( Dot ) per row, and pushed them in an array as well.

    Code:
    var dtrArray:Array = [];
    for(var c:int = 0; c < legendArray.length; c++) {
    	for(var r:int = 0; r < 5; r++) {
    		var dtr:Dot = new Dot();
    		dtr.x = 150 + (10 * c);
    		dtr.y = 50 + (22 * r);
    		dtr.name = "dtr" + r;
    		addChild(dtr);
    		dtrArray.push(dtr.name);
    	}
    }
    The problem is I can't seem to target the dtr mc's (Dot) at all even when they're in an array. Anyone have any strategies I can use to make this concept finally work? I've been able to do it as long as the dot mc's are a child of the button mc's, but I don't want the rollOver/rollOut effects to effect the child, therefore the separation. Please somebody help me!

    I hope it's clear.
    Last edited by Robb@exo; 05-07-2009 at 11:41 AM.
    Wile E. Coyote - "Clear as mud?"

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center