View Full Version : Using a movie as a button
JediNemesis
06-26-2002, 05:31 AM
I have a row of movie clips that I want to use as buttons. All I want them to do is tell to open another scene in the same movie file. I've tried the simple
on (release) {gotoAndStop ("Scene Name", Frame Number);}
Any help would be most appreciated.
Thank you,
Will
Jesse
06-26-2002, 06:12 AM
You have to change the behaviour of the clip from being an MC to a button. If you really want to keep them as MCs for some reason I would consider using invsible buttons placed over the top of them.
Esquared
06-26-2002, 06:21 AM
The code you specified is correct, however on handlers only apply to button instances, not movie clips.
In order to get around this, you must create a button somewhere. Where you place the button depends largely upon what your movie clips are doing.
If the movie clips are small animations contained in a relatively compact area, you can simply create a new symbol on the stage that covers your movie clip, convert it to a button, set its alpha level to 0 so it is invisible, and then place your script on this hidden button.
On the other hand, if your movie clip involves more complex tweens and such, or appears to move around the stage, you could place the button inside the movie clip itself. You could then either use the invisible button technique here, or convert part of the movie clip itself to a button. Keep in mind however that the latter method will only work if you convert a single tweened object to a button, or an object with no tweens at all.
Let me know if this solves your problem. Otherwise we can try to be clever in some other manner. Good Luck!
JediNemesis
06-26-2002, 07:45 PM
Well, thank you guys for your help, but it didn't quite do it. I forgot to mention that I'm already using the onMouseOver & onMouseOut commands to start and stop the clips when the user brings the mouse over the button. I don't know if this matters, but anyway, when I make the top layer in the movie clip a clear button and apply the script:
on (release) {
_root.gotoAndStop ("Scene", 1)
}
it doesn't work. If I just put clear buttons in the main movie over the movie clips, the onMouseOver/Out commands stop working.
Thanx again,
Will
P.S. You can get a copy of the file I'm working with at
http://www.pctechspec.com/PC TechSpec.zip
http://www.pctechspec.com/PC TechSpec.fla
farafiro
06-27-2002, 05:43 AM
which button u r pointing to??
Also note that u r assignning a buttons action to a MCs
Esquared
06-27-2002, 07:39 AM
OK...
I took a look at your fla and I believe I have solved the problem.
But before I comment on that, I want to make another comment. I don't understand why, but your script seemed to be uneditable to me. By this I mean that I could not seem to make any ADDITIONS to your movie that would show up in an swf file. Removing script clearly affected things, but for instance, I couldn't get a single trace("test") action to return a value ANYWHERE at all. I found this quite odd. Anyway, I simply copied every last frame from your movie into a new movie, and instantly I had traces running all over the place. I don't get it, but somehow it seems the file was corrupted.
That aside, as I mentioned, I think your problem has been dealt with. I simply added a handler to each button. The code is the following:
onClipEvent (mouseDown) { //when the mouse is clicked
if(this.hitTest(_root._xmouse, _root._ymouse, true)) { //if mouse clicks on clip
trace("Computer Repair Button") //remove this of course
_root.gotoAndStop(139); //goto the proper spot*
}
}
The code is as simple as that. Now here's the trick. note the * in the commented code. The frame that this particular button sends the playhead to is (139), NOT ("Computer Repair", 1). These scene titles won't work from within another timeline to my knowledge, but since they are really just splits of the main timeline, _root actaully covers every scene in the movie over some interval of frames. So in this case, the last frame in your intro is 138, and you want to go to the first frame of the next scene, which is therefore 139. For the remaining buttons, since it appears that these scenes will only require one frame each, simply increment by one...
I did actaully edit your file, but it's too large to post here and I have no location to allow you to download it from. If you need/want it (especially if that "corruption" or whatever it was will prevent you from working yours further), e-mail me at eeliason@andrew.cmu.edu and I'll get it to you.
Let me know if I can do anything else to help you out!
Hope it all works for ya!
ScratUAD
06-27-2002, 01:35 PM
if you are simply trying to animate your button... please be aware of the fact that you can add multiple layers and multiple movie clips to each of the four button states...
so when your mouse passes over the button... the movie clip in the "over" state plays...
when your mouse is no where near the button the clip in the first state plays (if you have placed movie clips in those states)
take a look at the buttons in
SonFire InfraNet (http://www.sonfiremartialarts.com/tech)
Esquared
06-27-2002, 07:38 PM
Hey,
Just a note on scratUAD's last post. This teqnique does work well, but after looking at your fla it won't work in QUITE the same way. You see, your current movie clips fade in on rollover AND fade out on rollout. The fade in is possible with the button idea, but when the mouse leaves the button the initial movie clip will instantly play, making a fade out impossible.
Either way, I've made a new fla that I'm able to post. I started with a new file, organized just like you want yours to be, with separate scenes. For the complicated into, I just placed a counter on the stage to count the otherwise empty frames the playhead runs through (to save on my filesize). Then I actaully made the first 4 buttons active in the way you want, sending the movie to different scenes. (The ones over the red bar are active here, but you can easily copy/paste the code)
This should definitely be what you're looking for, but let me know!
JediNemesis
07-01-2002, 05:40 AM
I just want to give a big thanks to Esquared. You helped me out greatly.
Will
farafiro
07-02-2002, 05:24 AM
Originally posted by Esquared
The fade in is possible with the button idea, but when the mouse leaves the button the initial movie clip will instantly play, making a fade out impossible.
What ya mean by that??
Esquared
07-02-2002, 06:49 AM
Hey,
What I mean by saying that a fadeout is not possible is basically this. Using actionscript it is possible to tell a movie clip to play backwards or play some altogether different sequence when the mouse leaves the clip. Using a button this isn't really possible.
You see...a button has 3 states: up, over, down
The mc in the up state will play continuously when the mouse is not on the button, so that's simple enough.
The over state will play when the mouse is over the button. This is where a "fade in" is possible, since the clip placed in this frame may, for instance, begin at alpha level 0 and slowly decrease in transparency. So that works too.
The problem with the "fade out" concept is this. There is no "rollout" state. Once the mouse leaves the button, the up state is immediately returned to. This being the case, there is no real way to prevent a direct cut from one clip to the next.
Now this would be possible with some further scripting if you toss in a few variables here and there within the button frames, but as long as you're scripting anyway, the solution I provided in my previous post is simple enough.
Let me know if you need further clarification, or if you've got a counter-example that proves me wrong (I'd be happy to see that, actually). Good luck.
farafiro
07-02-2002, 06:56 AM
well, without any advanced thinking or any variables u can put the button inside a MC and then make a very simple hitTest statnment to the MC
so if the mouse hits it, the fading in/out starts, and with a little else statment u can do the opposit.
Got me??
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.