3 Replies Latest reply on Mar 24, 2007 9:36 AM by Greg Dove

    run a actionscript in another movieclip.

    chrisatflash Level 1
      Hello,

      I was wondering if it possible to run a acionscript function in a movieclip.

      On my main timeline i would like to run this function. But this function is on the
      first keyframe of a movieclip that is on the stage.

      I am trying to do some test, but i don't know how i can run it.

      Does anyone know how?
        • 1. Re: run a actionscript in another movieclip.
          Greg Dove Level 4
          Just put the following code in a frame of your main timeline where your movieclip also exists.

          var myfunctionvalue = MovieClipName.functionName(parameters);

          or

          MovieClipName.functionName(parameters) ;

          where MovieClipName is the name of the clip and functionName is the name of the function inside it.

          That should work... if it doesn't then check your names are the correct case etc. Also make sure you don't give the movieclip on stage a name with a space in it or anything unusual like that.
          • 2. Re: run a actionscript in another movieclip.
            chrisatflash Level 1
            Thanks GWD! It seems to work!

            Is it also possible to run a action script on a movieclip in the main time line where
            the function is not at frame 1 (of the movieclip)?

            So if the function of the movieclip is at frame 10 and i would like to run this funtion,
            would it be something like this?

            MovieClipInstanceName.Framenumer.functionname();

            like

            hello.10.howareyou(); ?

            Or is this not possible?
            • 3. run a actionscript in another movieclip.
              Greg Dove Level 4
              I do most of my actionscript on frame 1... but I know you can't do what you're suggesting. If the frame has already "played" then the function should exist, but not if it hasn't got there yet I think.

              Do you want the child clip to go to frame 10 ?... just tell it to:

              MovieClip.gotoAndStop(10);

              In your example it might be

              hello.gotoAndStop(10);
              hello.howareyou();

              But I would be inclined to put all my functions on frame 1 of the hello clip. You can tell it to go to frame 10 and still call that function.