Flash AS2 - on(press) to attach MovieClip and reveal image

dev09
dev09 used Ask the Experts™
on
Hi Guys,

I'm stuck on some code I hope someone can help with. It's Actionscript 2 in Flash CS4.

I have a MovieClip that i want to attach to the Stage onClick, and for that to start to reveal an image on the lowest layer.  I have a MovieClip which i want to gradually be remove(masked) everytime i click.  So onClick 'newName' will affect 'maskMC' to reveal the image underneath.


This is what i have so far...

on(press) {
	_root.clickAmount++;
	// ATTACH MOVIE
	newName = "crack"+_root.clickAmount;
	_root.attachMovie("crackMC", newName, _root.clickAmount, {_x:this._x, _y:this._y});
	// MASK
	_root.newName.setMask(maskMC);  // This doesnt work, not sure how to make it work
}

Open in new window


Hope someone can help.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011

Commented:
You have to create mask for each movieclip (new instance)
Top Expert 2011

Commented:
By the way try this code

on(press) {
      var depth:Number = _root.getNextHighestDepth()
      // ATTACH MOVIE
      var mc:MovieClip = _root.attachMovie("crackMC", "crack" + depth, depth, {_x:this._x, _y:this._y});
      // MASK
      mc.mask = maskMC;  // This doesnt work, not sure how to make it work
}

I don't know where did you get setMask command
Top Expert 2011

Commented:
I attach an example
Example.fla

Author

Commented:
Hi dgofman,

Thanks, i've had a play with your file and it's close but doesn't quite solve the problem i have.
I have added a test tree image to your file, when I click it shows only that one part of the tree.  I want to click all over the place and reveal the full image... is this possible?

Thanks


Example.fla
Top Expert 2011

Commented:
Why is so complecated for such easy task?
Check my attachment
Example.fla

Author

Commented:
Hi dgofman,

So close...  thank you so much for what you have done, its great.. but can we set it to on Click, rather than on drag...  only when you click it will use a movie clip from the library to appear where clicked to reveal the photo of the tree.

Thank you so much!
Top Expert 2011
Commented:
That you should figure out yourself, did you try to play with code before write this comment?

var mouseListener = new Object();
mouseListener.onMouseDown = function() {
      drawCircle(circle._xmouse, circle._ymouse, 20);
};
Mouse.addListener(mouseListener);

Author

Commented:
Perfect, thank you so much!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial