A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Targeting mc's

  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?"

  2. #2
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    I hope it's clear.
    Not really lol.

    Are you getting an error anywhere? What's the line where your trying to target the MC's and it's not working?

  3. #3
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Figure it's not clear,... that sucks, oh well,
    In the mOver/mOut functions using TweenMax is where I get my errors, usually a 1069.

    ReferenceError: Error #1069: Property tint not found on String and there is no default value.
    at gs::TweenLite/initTweenVals()
    at gs::TweenMax/initTweenVals()
    at gs::TweenLite/activate()
    at gs::TweenLite$/updateAll()


    Thanks for the look, much appreciated.
    Wile E. Coyote - "Clear as mud?"

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You're pushing the names into dtrArray instead of the actual dots.

    Change the push line to this:
    Code:
    dtrArray.push(dtr); //things are not names.

  5. #5
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Yeah the problem definitely lies within the attempt to target any of the indices of dtrArray. Just tried running a trace statement in the mOver function (omitting everything else), still getting an error, all be it a different one, #1009, Cannot access a property or method of a null object reference.
    Wile E. Coyote - "Clear as mud?"

  6. #6
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Just tried 5TonsOfFlaxs' suggestion, still get the 1009 error.
    Wile E. Coyote - "Clear as mud?"

  7. #7
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    I'm assuming here Dot is a Movie Clip

    Code:
    TweenMax.to(MovieClip(dtrArray[0]), 1, {tint:0x14170C});
    Try that, see if that works.

  8. #8
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    That did the trick, thanks Beathoven. Of course that has issued a completely new problem, but at least now the mc are being properly referenced. Now it's just the first row of dots that are changing tint. Should I have set up the dots differently? Or do I need to make some alterations as to how the rest are to be referenced?
    Last edited by Robb@exo; 05-07-2009 at 02:35 PM.
    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