A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Can't click a button inside a movieclip

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    2

    Can't click a button inside a movieclip

    Hi! I'm working on a school project consisting of a flash presentation. I have just started the flash project but have already run in to problems.

    I have made a sort of drop down menu of a movieclip. There are actually two, the first one named list_over_mc is only to detect when the mouse is in the area for when to drop down the menu (onRollOver) and the other one, list_mc, is holding the menu itself. The problem is that when the menu is down nothing happens when I click the button (now named knapp1_btn). I have tried with another but with the same sort of script (but placed outside of the movieclip list_over_mc) and that works so I'm guessing it is because the button is "over" the other movieclip.

    Unfortunately I cant attach the file bc it is 380kb :/

    Anyone who has any ideas? Very thankful for help!

    Best regards
    Erik

  2. #2
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    copy and paste the movieclips that make the menu into another .fla file and post that. Also, you could post some code. It's possible (though I doubt it) that it could be a coding issue.

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Hello ZippyDee, thanks for your time!

    Here is the second FLA!

    Edit: the code:

    list_mc.stop();

    list_mc.knapp1_btn.onRelease = function () {
    gotoAndPlay(10);
    }

    list_over_mc.onRollOver = function() {
    list_mc.gotoAndPlay(1);
    };
    list_over_mc.onRollOut = function() {
    list_mc.gotoAndPlay(25);
    };

    Regards
    Erik
    Attached Files Attached Files

  4. #4
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    I figured it out. The problem is that if there is a button on top of another button, onRollOver events will only trigger for the top layer button. In this case, you had the list_over_mc over list_mc which held knapp1_btn, so it always only recognized list_over_mc.

    I know that list_over_mc is not set as a button, but as soon as you give a movieclip any button-specific functions (onRelease, onPress, onRollover, onRollout, etc.) Flash automatically treats it like a button.

    Try this code:
    Code:
    stop();
    
    list_mc.stop();
    
    list_mc.knapp1_btn.onRelease = function () {
    	_root.gotoAndPlay(10);
    	_root.list_over_mc._visible=true;
    }
    
    list_over_mc.onRollOver = function() {
    		list_mc.gotoAndPlay(1);
    };
    
    list_mc.onEnterFrame = function() {
    	if(!hitTest(_xmouse,_ymouse,true)){
    		if(this._currentframe>=15 && this._currentframe<25) this.gotoAndPlay(25);
    		_root.list_over_mc._visible=true;
    	}else if(hitTest(_xmouse,_ymouse,true)){
    		_root.list_over_mc._visible=false;
    	}
    };
    That should solve the problem.
    Last edited by ZippyDee; 01-07-2010 at 08:30 PM.

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