dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: HELP!! How do I listen for clicks on many movieclips

  1. #1
    Grandmaster Flash
    Join Date
    Apr 2004
    Location
    Edinburgh, Scotland
    Posts
    139

    HELP!! How do I listen for clicks on many movieclips

    Hi

    I am trying to create a set of attached movieclips, which do something when they are clicked. Below is a snippet from my code. The below works if I take out the mc_this.onRelease() = function():Void handler. I need to know which clip was clicked from the handler/listener.

    Can someone point me in the right direction of a good tutorial or give me a hint on this code please?

    Code:
    for(var j=0; j<6; j++)
    {
    	for(var i=0; i<7; i++)
    	{
    		var mc_this:MovieClip = this.attachMovie('cloneme', 'd' + dayNumber, this.getNextHighestDepth())
    		mc_this._x = (i*_global.w);
    		mc_this._y = (j*_global.h);
    					
    		mc_this.onRelease() = function():Void
    		{
    			trace("clicked on");
    		}
    	}
    }
    The above code is in a class which extends movieclip and I'm using Flash 8.

    TIA
    If it ain't broke, don't fix it.

  2. #2
    I Just Started Flash Today johnglynn's Avatar
    Join Date
    Mar 2001
    Posts
    180

    too many ()s

    This does not seem right:

    mc_this.onRelease() = function():Void
    {
    trace("clicked on");
    }
    Try this:

    Code:
    mc_this.onRelease = function():Void{
          trace("this mc: " + this)
    }

  3. #3
    Grandmaster Flash
    Join Date
    Apr 2004
    Location
    Edinburgh, Scotland
    Posts
    139
    Excellent. That works a treat.

    Many thanks
    If it ain't broke, don't fix it.

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