Skip navigation
CSulzmann
Currently Being Moderated

Making movie clip disappear with button

Jun 15, 2012 3:38 AM

Hi All,

Thank you very much for looking at my post and I hope you can answer my question

 

Basically I have an interactive 3D project that when the viewer clicks on the window and drags either right or left, then it appears like they are rotating a 3D model I rendered out in Maya. Really all they are doing is moving the mouse on the x axis which causes the movie clip to play backwards or forwards.

The code that I got from this site works like a dream! I even have made it so that as they click a next button that it goes to another almost identical movie clip and it will start from the same frame as the previous movie clip left off from. I'm rather proud of myself at the moment

However - on the second almost identical movie clip (mc_2) it has some labels on the images. And what I really want to do is, on mouse press for the labels to disappear and when the viewer has finished scrubing through the time line with mouse drag and releases the mouse, that the labels reappear!

Very much like this here : http://bmc.erin.utoronto.ca/~enid/interactivethyroidectomy/

 

So I worked out this code which works perfectly in a little test project I did. I put this code on a button called it my_btn and then made a label and changed it into a movie clip called my_mc, and it all worked perfect

 

on (press) {

_root.my_mc._visible = false;

}

on (release) {

_root.my_mc._visible = true;

}

 

But what I really need to do is for my previous movieclip, mc_2, to use the code above. However, if I add it anywhere amoungst my previous actionscript coding in the layer mc_2, then the viewer can no longer scrub through the time line anymore. Clearly this code above is affected my previous code. which is:

 

stop();

mc_2.stop();

var startX:Number;

var startFrame:Number;

var changeDistance:Number;

var travelDistance:Number;

mc_2.onPress = pressHandler;

mc_2.onRelease = releaseHandler;

mc_2.onReleaseOutside = releaseHandler;

function pressHandler():Void {

startX = mc_2._xmouse;

startFrame = mc_2._currentframe;

this.onMouseMove = moveHandler;

}

function releaseHandler():Void {

this.onMouseMove = null;

}

function moveHandler():Void {

changeDistance = mc_2._xmouse - startX;

travelDistance = startFrame + changeDistance;

if (travelDistance > mc_2._totalframes) {

mc_2.gotoAndStop(travelDistance % mc_2._totalframes);

} else if (travelDistance < 0) {

mc_2.gotoAndStop(mc_2._totalframes + (travelDistance % mc_2._totalframes));

} else {

mc_2.gotoAndStop(travelDistance);

}

 

}

 

Just so I'm ultra clear about the various layers etc

On scene 1 i have four layers

Actions, buttons, movie clips and background

In frame two it has the actionscript listed above, and then mc_2

Inside mc_2 are 100 frames of a 360 degree view images of a shoulder rendered from Maya

in the layer above the images I have the labels - one of which ive converted into a movieclip called my_mc for the purpose of this post.

 

So what i need to do is to add somewhere into the actionscript for the mc_2 that together with all the mouse presses, and releases for it to also make a specific mc (my_mc) invisible when the mouse is pressed, and to re appear when mouse is released.

I hope that makes sence.

 

Thank you very much for your help in advance.

Cat

 
Replies
  • Currently Being Moderated
    Jun 15, 2012 4:34 AM   in reply to CSulzmann

    As best I can tell from your deascription, you need to put the two lines of code into your pressHandler and releaseHandler functions.

     

    function pressHandler():Void {

       startX = mc_2._xmouse;

       startFrame = mc_2._currentframe;

       this.onMouseMove = moveHandler;

       my_mc._visible = false;

    }

     

    function releaseHandler():Void {

       this.onMouseMove = null;

       my_mc._visible = true;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 15, 2012 5:21 AM   in reply to CSulzmann

    If you want to target something inside mc_2, then just target mc_2 as part of the path...

     

    mc_2.my_mc._visible = false;

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 15, 2012 8:18 AM   in reply to CSulzmann

    You're welcome

     
    |
    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