Skip navigation
boomsc
Currently Being Moderated

How to make a Dynamic Mask switch to a different keyframe?

Jun 28, 2012 2:45 PM

Tags: #mask #dynamic #button #3 #actionscript #actionscript3 #moving #masking

I'm making a science game of sorts, showing the human body in slices, like a virtual disection. I'll have the a picture of the person, and mousing over moves the mask to reveal the first 'layer' of organs (in this case Lungs) and the text, then clicking a button will cause the mouse to reveal the stomach and intestines + text, and so on and so forth.

 

 

I've got a single mask down, using the following code. lungs is the symbol containing the picture of the lungs and text, circlemc is the circular mask (with blurry edges)

 

lungs.mask=circlemc;

lungs.cacheAsBitmap=true;

circlemc:cacheAsBitmap=true;

stage.addChild(circlemc);

circlemc.mouseEnabled = false;

circlemc.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);

 

function fl_CustomMouseCursor(event:Event)

{

    circlemc.x = stage.mouseX;

    circlemc.y = stage.mouseY;

}

Mouse.hide();

 

 

 

I'm thinking, it I set all the 'internal' pictures as seperate keyframes on a single layer. So for example the final layout would look like this

Layer 1 (bottom). Keyframe 1 contains Lungs, Keyframe 2 contains digestive tract, Keyframe 3 contains liver.

Layer 2 (above layer1) contains mask shape

Layer 3 contains buttons, intending to toggle between the layer 1 keyframes.

Layer 4 contains actionscript.

 

Would this work? and how would I go about making it work?

I assume the simple snippet code

 

[buttonname].addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

{

    gotoAndStop(2);

}

 

would for example move the animation from the lungs to the digestive tract, but would the masking continue to work or would it just show the lungs still, would I need to re-code a seperate mask on keyframe2 to mask the digestive tract, and how would I keep the seperate masks apart and prevent one working until the button is clicked?

 
Replies
  • kglad
    62,161 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 28, 2012 4:44 PM   in reply to boomsc

    it should work if you either use actionscript to assign your mask or use the timeline, not both.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points