Link to home
Start Free TrialLog in
Avatar of dev09
dev09

asked on

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

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
Avatar of dgofman
dgofman
Flag of United States of America image

You have to create mask for each movieclip (new instance)
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
I attach an example
Example.fla
Avatar of dev09
dev09

ASKER

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
Why is so complecated for such easy task?
Check my attachment
Example.fla
Avatar of dev09

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dev09

ASKER

Perfect, thank you so much!