Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call a movie clip function in another movie clip

Status
Not open for further replies.

ashstampede

Programmer
Aug 30, 2004
104
GB
I have some functions on my action layer for movie clip, in a second movie clip i attach the first movie clip via.
Code:
    this.attachMovie("firstClip","newClipname",1);
this works fine and the clip shows up when its attached.

but when i try to call the function for the clip it doesn't work, nothing happens.
i call the function like this, like i would in any OOP language
Code:
    newClipname.function1();
but that doesn't work ,I searched the internet for a while and found somthing about
prototype. so i went back and made my methods in my first movie clip like so.
Code:
MovieClip.prototype.function = function(fields){
        //I do stuff
};

when i tested it after this still no difference, how do you call functions from other movieclips?
 
nothing wrong with the syntax newclip.function() in general

your research on prototypes has led you astray

your problem may be that the frames containing the functions must have been played and exist on the timeline at the time the function is called in order for the functions to be available

its really a much better idea to keep all functions in frame 1 of the main movie and just refer to them there
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top