View Full Version : actionscript problem
buddymink
11-22-2003, 03:21 AM
is there an actionscript assigned to a button to tell a movie clip to play and then once the last frame of that movie clip is played, go to play another movie clip?
Thanks
subquark
11-22-2003, 03:50 AM
well, you could put an action in the last frame of that first movieclip. so maybe make an empty keyframe at the end of that movieclip and do this:
stop(); //stop this mc so it does not loop
_root.yourSecondMC.gotoAndPlay(); // the path & name of the second mc
buddymink
11-22-2003, 04:15 AM
I forgot to tell you that I'm gonna have a couple buttons that will play the first movie clip first before they play another different movie clips. So let's say i have 3 buttons, buttons 1, 2 and 3 and I have 4 movie clips: MC a,b,c,d.
what I want is to have button 1 to play MC a first then play MC b.
then button 2 will play MC a first then play MC c
button 3 will play MC a first then play MC d.
please help.. thanks
subquark
11-22-2003, 04:33 AM
always in that order?
buttonOne:
on (release) {
_root.mcA.gotoAndPlay(1);
}
last empty keyframe of mcA:
_root.mcB.gotoAndPlay(1);
buttonTwo:
on (release) {
_root.mcB.gotoAndPlay(1);
}
last empty keyframe of mcB:
_root.mcC.gotoAndPlay(1);
buttonThree:
on (release) {
_root.mcC.gotoAndPlay(1);
}
last empty keyframe of mcD:
_root.mcD.gotoAndPlay(1);
buddymink
11-22-2003, 04:50 AM
isn't your script will just tell button 1 to play mc a then mc b, then button 2 plays mc b then mc c, button 3 plays mc c then mc d? that's not what i want. I want each button to play mc a first before they play another movie clips
subquark
11-22-2003, 05:01 AM
sorry, you are correct all the buttons should be:on (release) {
_root.mcA.gotoAndPlay(1);
}
but this means that you have to use a flag or variable or "if" to play the next MC.
To do this I think you have to use MCs as buttons (rather than a button symbol) and that way you can make a function for the "button" that will "see" what button was pressed and then play the appropriate second MC.
so let's see:
one_btn.onRelease = function() {
_root.mcA.gotoAndPlay();
}
no, that's a bogus approach, hold on, I'm gonna summon the CodeBeast, give him a minute . . .
CyanBlue
11-22-2003, 05:50 AM
what I want is to have button 1 to play MC a first then play MC b.
then button 2 will play MC a first then play MC c
button 3 will play MC a first then play MC d.I'd do something like this...// At the very last frame of your movieClip A
_level0[nextMovie].gotoAndPlay(1);
//
//Script for buttons
//
Btn_1.onPress = function ()
{
_level0.nextMovie = "mcB";
_level0.mcA.gotoAndPlay(1);
}
Btn_2.onPress = function ()
{
_level0.nextMovie = "mcC";
_level0.mcA.gotoAndPlay(1);
}
Btn_3.onPress = function ()
{
_level0.nextMovie = "mcD";
_level0.mcA.gotoAndPlay(1);
}The script might not be 100% correct, but you get the idea... ;)
subquark
11-22-2003, 12:33 PM
wow! that is nice! so [nextMovie] is a variable you declared?
buddymink
11-23-2003, 05:26 AM
i've tried it but it still doesn't work... is there something wrong with the script?
CyanBlue
11-23-2003, 07:33 AM
Howdy... ;)
Um... I have lost my crystal ball during the world war II and I haven't got the new one yet...
I cannot see what you have in your file... The script that I had shown you might or might not work depending the path and some other variables you have...
Can you at least make some simple sample and show us what you have in there??? ;)
subquark
11-23-2003, 12:41 PM
Crystal Ball! :eek: Ooops, I trhink that's what I finally gor the ball moving code to work on! Sorry, I don't know where it went!:confused: It was moving to the right at 5 pixels per frame and a frame rate of 18 fps!
Yeah, put a zip of your fla up so we (CyanBlue) can check it out. Looks like his code is good. I bet you have a path problem with it . . .
hahaflasher
11-24-2003, 05:10 AM
buttonOne:
ActionScript:--------------------------------------------------------------------------------on (release) {
_root.mcA.gotoAndPlay(1);
drag = 1
}
--------------------------------------------------------------------------------
buttonTwo:
ActionScript:--------------------------------------------------------------------------------on (release) {
_root.mcA.gotoAndPlay(1);
drag = 2
}
--------------------------------------------------------------------------------
buttonthree:
ActionScript:--------------------------------------------------------------------------------on (release) {
_root.mcA.gotoAndPlay(1);
drag = 3
}
--------------------------------------------------------------------------------
last empty keyframe of mcA:
ActionScript:--------------------------------------------------------------------------------if(drag= 1){
_root.mcB.gotoAndPlay(1);
}
if(drag= 2){
_root.mcC.gotoAndPlay(1);
}
if(drag= 3){
_root.mcD.gotoAndPlay(1);
}
--------------------------------------------------------------------------------
last empty keyframe of mcB, mcC and mcD:
ActionScript:-------------------------------------------------------------------------------- stop()
--------------------------------------------------------------------------------
I am not sure this is 100% correct.
May you have a try?
buddymink
11-25-2003, 01:59 AM
pls see tha fla files attahed
on main section, try to click on crabfolio button. the green box will be scaling down and disappear then the title "bionicrab" will disappear and the crab will go off the stage. Then it will bring you to the crabfolio section. That's what i want each button to do every time the button is clicked. So instead of going directly to the crabfolio section, it'll play "going off the stage animation (if you will)" first.
Thanks
buddy
CyanBlue
11-25-2003, 06:57 AM
Howdy... ;)
Can you make a simple sample that shows where and what your problem is??? There is no point of downloading your whole project just to fix that error in my opinion... :(
subquark
11-25-2003, 10:51 PM
well the code CyanBlue put up will do exactly what you are describing, have you tried it?
make a new fla and some simple symbols like squares and circles and use CyanBlue's code to get it to do the behaviour you want, just keep it simple and then try to make your fla work
subquark
11-25-2003, 10:58 PM
yep, CyanBlue's code works. if I can do it . . .
just make the three buttons and the 4 mcs, name the buttons and mcs as CyanBlue did and voila!
just do something simple with the mcs, like a slow spin or sideways move, be sure to have a stop action in the first frame
I changed his code just a tad:// At the very last frame of your movieClip A
_level0[nextMovie].gotoAndPlay(2);
//
//Script for buttons
//
Btn_1.onPress = function ()
{
_level0.nextMovie = "mcB";
_level0.mcA.gotoAndPlay(2);
}
Btn_2.onPress = function ()
{
_level0.nextMovie = "mcC";
_level0.mcA.gotoAndPlay(2);
}
Btn_3.onPress = function ()
{
_level0.nextMovie = "mcD";
_level0.mcA.gotoAndPlay(2);
}
all I did was have a blank first keyframe so that the mcs were "invisible" . . .
buddymink
11-25-2003, 11:34 PM
It worked!!!!! CyanBlue code works!!! you're right subquark, i got a problem with the path.... Thanks for all of you who replied to my problem...
buddy
subquark
11-26-2003, 08:43 AM
hooray! glad you got it going
it took me about two years to understand paths, I don't know why it was so tough but . . .
when you are done with that site, you should put it on site check!
do good :)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.