Hi,
I have several different AVIs which I have imported as movieclips.
I want to be able to have some common functions for the different clips which will for example start them playing at the same position.
For example if I have five different car avi movie clips, I would like to have a funciton AnimateDriving() or StopDriving() which I can invoke for each car (maybe from a super class) which executes the same code (eg gotoAndPlay(5)).
I know I can use MovieClip.prototype but this in not really OOP
and most websites i viewed say this is wasteful, as I have many other different (non-car) movieclips.
Can anyone suggest the best way to do this.
Much appreciated.
DumbMonkey.
movieClip.prototype IS OOP. People might complain about it because of its exposure (ALL movieclips gain access to those functions), but in terms of functionality, it does what you need.
From what you’re explaining though it would seem like a waste to go through all the effort of setting up a class, defining inheritance and all that other bull just to call a couple of functions on a couple of clips - especially when they seems to be static in nature (though I could be wrong there).
Heres what I would do. Somethng like…
AnimateDriving = function(frame){
for(var i=0; i<movies.length; i++) movies*.gotoAndPlay(frame);
}
StopDriving = function(){
for(var i=0; i<movies.length; i++) movies*.stop();
}
movies = [movie1_mc, movie2_mc, movie3_mc, movie4_mc, movie5_mc];
and theres your groundwork for playing or stopping all your movies. Technically theres no OOP involved but there doesnt need to be. Youre not assigning any redundant functions and the operations are completed quickly and smoothly… and it much less hassle and typing on your end to set up.