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
Adobe FlashMultiMedia ApplicationsScripting Languages

Avatar of undefined
Last Comment
dev09

8/22/2022 - Mon
dgofman

You have to create mask for each movieclip (new instance)
dgofman

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
dgofman

I attach an example
Example.fla
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
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
dgofman

Why is so complecated for such easy task?
Check my attachment
Example.fla
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!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
dgofman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dev09

ASKER
Perfect, thank you so much!