View Full Version : Loading a MC at a certain frame?
zmak13
January 1st, 2005, 03:56 PM
Hi,
Can anyone tell me how to load a movie clip in actionscript and then have it start playing at a certain frame. I'm stuck. Thanks a lot.
frozenRage
January 2nd, 2005, 12:40 AM
ok, this is what i think you want from how i interpret the question
ok, right click on the movie clip in the library and select linkage.
check the "export for actionscript" box and type a name for it
place the following code on the main timeline
_root.attachMovie("linkage_identifier","movie_clips_new_name",0)
movie_clips_new_name.gotoAndStop(frame_number)
n.b. the "linkage_identifier" and "movie_clips_new_name" must be within quotes.
add
movie_clips_new_name._x = "whatever x value you want it to be at"
movie_clips_new_name._y = "whatever y value you want it to be at"
to move the clip somewhere on the stage
hope that helps
yamyam21
February 1st, 2005, 10:53 AM
Alrighty,
Have just come across this thread, i'm trying to do the same thing, the code you posted works well, cheers Krusader however can anyone tell me how to get this to work from a on release command, ie from clicking on a button, and also can you do the same with an external swf file.
ta in advance
Yam
Krilnon
February 1st, 2005, 04:39 PM
Are you talking about a symbol of the 'button' type, or an mc that functions as a button?
yamyam21
February 2nd, 2005, 04:09 AM
either please, mc if possible but button if not.
frozenRage
February 2nd, 2005, 04:13 AM
well, do you want it to be able to execute mulitple times or is one click enough? (eg. click once and then the button disappears/is disabled) requires more thought for multiple clicks :D
/edit - i was wrong multi doesn't require more thought, i'm putting my slowness down to being exceedingly sick today :)
/edit - ok, i have no idea wether you stop/play/gotoFrame on an external mc but here's how to load an external mc on a mc or button press:
mc_to_click.onRelease = function() {
_root.createEmptyMovieClip("target_mc", depth_to_load_to);
loadMovie("relative_path_to_external_swf", "target_mc");
target_mc._x = -100;
target_mc._y = -100;
};
/edit - this is how to load a mc from the library
mc_to_click.onRelease = function() {
_root.attachMovie("linkage_identifier","movie_clips_new_name",depth)
movie_clips_new_name.gotoAndStop(frame_number)
movie_clips_new_name._x = "whatever x value you want it to be at"
movie_clips_new_name._y = "whatever y value you want it to be at"
}
/edit - i have to stop editing this post :P
frozenRage
February 2nd, 2005, 04:31 AM
instead of editing my post yet again i decided to add another post:
Hope that helped ;)
yamyam21
February 2nd, 2005, 05:15 AM
magic mate.
don't suppose you know how to get it to do the same for an external movie clip, i can get the movie clip to go to a certain frame from a on release command by using this code:
on(release){
loadmovie("yourmovie.swf", _root.targetclip);
_root.clipposition = "frame20";
}
then in the first frame of the external movie clip
if(_root.clipposition == "frame20"){
gotoAndPlay(20);
} else {
gotoAndPlay(2);
}
this works but i can only use it once, how do i get it so i can set it up so i can do from different buttons, (one button goes to frame 2 then another goes to a different frame but in the same movie clip)
The only reason i want to do this is to cut down on the size of the initial movie.
cheers
yam.
frozenRage
February 2nd, 2005, 06:16 PM
Well, you could probably do it with parameters or something but i don't know enough to be able to tell you how.
you could use your idea but slightly modified
onEnterFrame = function(){
if(_root.button_pushed_var == 1){
if(_root.clipposition == "frame20"){
gotoAndPlay(20);
} else if (_root.clipposition == "frame2"){
gotoAndPlay(2);
}
_root.button_pushed_var = 0
}
}
and on your button put
_root.button_pushed_var = 1
_root.clipposition = "frame20"
to set the switch so that the code in the mc will execute.
its kinda rigged and i have no idea wether this'll work but here's hoping.
nice idea on getting the external mc to change frame. i never thought of doing it that way. so simple yet effective :P
anyway, hope that helped and good luck.
scotty
February 3rd, 2005, 04:09 AM
Maybe this will help
http://www.kirupa.com/forum/showthread.php?t=83422 post #6
scotty(-:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.