Explanation of A Specific Code & Its Application

BWH2 Responded to my thread about reseting a movie clip and he attatched this thread -> http://www.kirupaforum.com/forums/showthread.php?t=62491 to help explain the included code and how it can be used to move an objects y and x coords in a movie. My question is, and this pertains to my thread (Reseting a Movie Clip); How do I modify the code so that when I click on a button it resets the original y coords of a button. I understand his “tutorial” of this but I am struggling to apply this to my problem. Any thoughts?
-shogun8 (the shogunate) :asian:

ok, first off, just post again in that thread and ask for an explanation, don’t make a new thread. you’ll get a lot faster response and it’ll won’t be obnoxious.

my previous example was for a MC using the onClipEvent(enterFrame) which essentially acts like a loop and constantly recalculates the distance between actual y and destination y and act accordingly.

but for a button, we want to use the on(release) function, which does not act like a loop. rather, the on(release) will only calculate the difference once and act once.

so instead, we make a button w/alpha=0 and have it trace the _y of the square mc and move along with it. the button moves along with the mc, because we’re still utilizing the onClipEvent(enterFrame) function of the mc, which acts like a loop.

look at the AS in the attachment. essentially it’s the same file as before, but with the button added and some more comments. i don’t have my button alpha=0 or have the _x of it equal to the square._x, but that’s so you can see it moving along with square.

Okay I understand more of how it works now, and I understand the code as clear as day but I am still stuck on translating your examples into what I am trying to do. I have included a jpg of my project, a basic, deconstructed form of it. The actuall file is larger than the forums will allow me to post. So take a look at the picture and let me know what I can alter in your code to make this work.

ok. this is actually pretty easy if you understand the code. i’ve created a menu almost identical to what you’re doing. so here it is:

in the main timeline, let’s set up 2 variables:
upPosition=downPosition-10; // upPosition is 10 spaces above downPosition[/AS]

AS for work MC:
[AS]onClipEvent (load){
speed = 5;
destinationY = _root.downPosition; // start in downPosition
onClipEvent (enterFrame) {
y = destinationY-_y;
this._y += y/speed;
_parent.buttonwork._y=this._y; // attach work to work MC

work button AS:
work.destinationY=_root.upPosition; // send work MC into upPosition
process.destinationY=_root.downPosition; // send process and other buttons/MC’s into downPosition if they are up. if they’re already down, they stay down.

basically, each button sets a destinationY for each other button/MC as well as itself.

hmm I have hit a bit of a snag, It seems to want to glide upward automatically upon enter and I think this is because I can’t include the “button” code you have included- and I think this is due to the fact that my “buttons” are movie clips through and through. Do you have an email I can send my .fla to you to take a look at? Like I said its too big for the forums (its only 80kb tho). I think I am just putting something somewhere it shouldn’t be.

go ahead and e-mail it. [email protected]

If you check this first, it should be there by now. Anyway like I said I appreciate your help so far. This is a pretty important project for my architecture degree I need to prepare over the summer, so like I said, thanks. The site isn’t complete, and what I sent you is just a broke down version of it. Its just the menu right now, the rest I tore apart to make it more reasonable to send via email

wondering if it works when i put it together the work mc slide away please have a look

hmmm I can’t open your file. Is it mx? I have had this problem with someone else. rename it as something else and try again. I am open to anything right now. thanks

shogun8. i just decided to remake your file b/c having the buttons as mc’s screws things up and it’s messy. this should be fairly easy to understand, i think…

i wasn’t sure how you were doing the enter key thing, so i didn’t include that. but i told you how the AS would change if you did use it. let me know how it goes.

// edit, i forgot the button instance names. re-uploaded correct file a few minutes later.

gupps. unexpected file format. sure you aren’t using mx2004? i can’t remember if that’s the reason that appears.

if you’re not, just try posting your AS changes and such in here and i’ll look at it.

bwh, the acutal, non deconstructed form of my site actually includes a .jpg background image and the menu items are text only. Is there a way I can eliminate the box around the text and just have the text without messing up the effect you achieved without using an mc?

actually, better yet I am going to send you a copy of my main page, and I will show you why I have used mcs for those buttons. I used movie clips for a special effect that occurs when the user clicks on the enter button. I understand what you did with the tru.tma.3 that you sent me, it makes sense after seing it. I guess I am just a visual person. But take a look at my page and see what I mean by the mcs

just go into each mc and delete the 2nd layer, which is the grey background box. the text will still remain and all will work correctly.

as for the mc’s fading in on enter press, i don’t really understand how it works b/c i can’t find the AS for it. but here’s what i would do:

AS in main timeline so the MC’s and vuttons aren’t visible at start:
process._alpha=0; // do the rest of the mc’s like this
buttonworks._visible=false; // do the rest of the buttons like this

then in each MC (AS is the same in each MC):
this._alpha+=1; // make this number higher to speed up fade in

then on enter press (which didn’t work when i just opened flash player, or when i published the file):
process._alpha=1; // go through all of the MC’s
buttonworks._visible=true; // do all the buttons like this

you could put that enter press AS in whatever frame of your photo fade to black you wanted as well. hope that helps.

this fla used bwh2’s AS, but i didn’t use button, n the box around the text has gone. what do u think? :cons:

Alright this one is for both of you guys:
First of all, bwh. Okay now I understand the code that you gave me, but I think its a bit fragmented because I keep getting errros like “you can’t use onenterclip with a button, it has to be an mc”. Where I am putting the code in wrong. The other thing is, I don’t need to do a “hit enter to begin” I know it only works with the internal swf player in flash; so I am going to use a “click to enter”. In that case where to do I insert the onrelease at? With what bits of code? You said:

AS in main timeline so the MC’s and vuttons aren’t visible at start:
process._alpha=0; // do the rest of the mc’s like this
buttonworks._visible=false; // do the rest of the buttons like this
in the main timeline? what frame of what do I put those in? does the works._alpha=0; go to the first frame in the main time line for the mcs. And does the buttonworks._visible go to the first frame for the buttons in the main timeline, OR do you they remain grouped together?
Then you said:
Then in each MC (AS is the same in each MC):

this._alpha+=1; // make this number higher to speed up fade in

What frame of the motion tween do I put it on? The first? Does that carry throughout the clip or just between the first keyframe and the middle-between the tweens?
Then you said this about the on enter. Well Like I said I am not going to use the enter. So what do I use in this code- an onrelease? And where do I put it.
process._alpha=1; // go through all of the MC’s
buttonworks._visible=true; // do all the buttons like this.

Sorry if my questions seem tedious, Iam just a visual learner and have a hard time knowing what goes where in flash since there are so many levels to each layer/mc/button etc.

And as for you 40unregistered, great. I like your idea for my project. If you have an email address I can email my fla to, then I can show you what I am trying to do with that text and a larger transition in the beginning of my page. Maybe you can chip in and provide a second opinion. My fla is too big to post here, its about 120kb.

as it says, onClipEvent events can only be used for MC’s, not buttons. so always put those in buttons.

on(release), on(rollOver), and on(rollOut) apply to buttons. so you select a button, then go to the actions panel to insert the AS. you do not want to actually open up the symbol, just select it.

instead of trying to re-explain the AS, i just made the new fla. so take a look at the AS for the buttons, MC’s, and in the main timeline. i’m not going to be on vacation for a week, so i won’t be around. hopefully that works out for you.

pls send it