7 Replies Latest reply on Nov 21, 2012 5:39 PM by mmorse22

    actionscript noob

    mmorse22

      I have a flash movie that i want to load 8 movie clips into in succession. In other words I want the first movie clip to play, then be replaced by the next clip and so on until all 8 have played. How would I do this in actionscript? I know virtually nothing about AS so please be specific.

       

      Thanks much

      -mark

        • 1. Re: actionscript noob
          Ned Murphy Adobe Community Professional & MVP

          Where are these movie clips?

          • 2. Re: actionscript noob
            mmorse22 Level 1

            library

            • 3. Re: actionscript noob
              Ned Murphy Adobe Community Professional & MVP

              I won't be handing you a solution, so you'll have to take what I offer and do some work to try to get something working.  If you have no background in programming, then you might have a bit of trouble getting thru it and should consider hiring someone.

               

              Each movieclip (except maybe the last one) will need to be edited so that when it ends it triggers a call to a function in the main movie to load the next movie.  Since you say you don't use actiuonscript, I'll assume your movieclips run along the timeline, so this call will be added to the last frame.  Since that function will be in the main timeline, you would use either _root or _parent to target the function from inside the movieclips.  As in... _parent.loadNext();

               

              In that main movie function, to load a movie from the library you need to use the attachMovie("linkageID", "clipName", depth) method.  The linkageID is assigned by right clicking the symbol in the library, selecting Properties, selecting the option to Export for Actionscript, and assigning a unique Identifier.  The clipName won't be of much meaning to your goal, so any name will suffice.  If you want to replace a loaded clip with another loaded clip, then you specify it to load into the same depth as the one already loaded.

               

              In the main timeline you will need to have some kind of reference for the linkageID's of the movieclips set in the order they are to be loaded.  An array will do this just fine.  You will need to have a counter that keeps track of which item is supposed be loaded next, which is incremented each time the loading function executes.

               

              So your main timeline code would be something like...

               

              var linkageIDs:Array = new Array("MC1", "MC2", "MC3",....etc);

              var nextMC = 0;

              this.createEmptyMovieClip("mcHolder", this.getNextHighestDepth());

              mcHolder._x = 10; // place it where you want the movieclips to be

              mcHolder._y = 10;

               

              function loadNext(){

                   mcHolder.attachMovie(linkageIDs[nextMC], "anyname", 1);

                   nextMC += 1;

              }

               

              loadNext(); // this is to load the first movie clip

              1 person found this helpful
              • 4. Re: actionscript noob
                mmorse22 Level 1

                Thanks Ned,

                I don¹t know a thing about AS. Wish I did. Let me see if I understand. On

                the last frame of each clip (except the last one), I add

                _parent.loadNext(); Is that All I add or is there more to it? Does anything

                go into the parentheses?

                 

                On the main movie timeline I add:

                var linkageIDs:Array = new Array("MC1", "MC2", "MC3",....etc);

                var nextMC = 0;

                this.createEmptyMovieClip("mcHolder", this.getNextHighestDepth());

                mcHolder._x = 10; // place it where you want the movieclips to be

                mcHolder._y = 10;

                 

                function loadNext(){

                     mcHolder.attachMovie(linkageIDs[nextMC], "anyname", 1);

                     nextMC += 1;

                }

                 

                Would this go on an actions layer in the main timeline? I realize I have to

                change MC1, MC2 etc to my identifier names. Is ³anyname² a name I assign to

                the empty movie clip?

                 

                Any help you can give to help me understand is greatly appreciated. I know I

                could just create all 8 clips and run them concurently on the timeline

                adding enough empty frames to account for the clip that precedes each of the

                following clips but that would be a messy way of doing it.

                --

                Mark Morse

                Marketing Services

                Sanmina-SCI

                20091 Ellipse

                Foothill Ranch, CA 92610

                949-643-7255 ext 2261

                 

                 

                 

                From: Ned Murphy <forums@adobe.com>

                Reply-To: <clearspace-1816444701-78827-2-2529672@mail.forums.adobe.com>

                Date: Tue, 19 Jan 2010 16:59:20 -0700

                To: Mark Morse <mark.morse@sanmina-sci.com>

                Subject: actionscript noob

                 

                I won't be handing you a solution, so you'll have to take what I offer and

                do some work to try to get something working.  If you have no background in

                programming, then you might have a bit of trouble getting thru it and should

                consider hiring someone.

                 

                Each movieclip (except maybe the last one) will need to be edited so that

                when it ends it triggers a call to a function in the main movie to load the

                next movie.  Since you say you don't use actiuonscript, I'll assume your

                movieclips run along the timeline, so this call will be added to the last

                frame.  Since that function will be in the main timeline, you would use

                either _root or _parent to target the function from inside the movieclips. 

                As in... _parent.loadNext();

                 

                In that main movie function, to load a movie from the library you need to

                use the attachMovie("linkageID", "clipName", depth) method.  The

                linkageID is assigned by right clicking the symbol in the library,

                selecting Properties, selecting the option to Export for Actionscript, and

                assigning a unique Identifier.  The clipName won't be of much meaning to

                your goal, so any name will suffice.  If you want to replace a loaded clip

                with another loaded clip, then you specify it to load into the same depth

                as the one already loaded.

                 

                In the main timeline you will need to have some kind of reference for the

                linkageID's of the movieclips set in the order they are to be loaded.  An

                array will do this just fine.  You will need to have a counter that keeps

                track of which item is supposed be loaded next, which is incremented each

                time the loading function executes.

                 

                So your main timeline code would be something like...

                 

                var linkageIDs:Array = new Array("MC1", "MC2", "MC3",....etc);

                var nextMC = 0;

                this.createEmptyMovieClip("mcHolder", this.getNextHighestDepth());

                mcHolder._x = 10; // place it where you want the movieclips to be

                mcHolder._y = 10;

                 

                function loadNext(){

                     mcHolder.attachMovie(linkageIDs[nextMC], "anyname", 1);

                     nextMC += 1;

                }

                • 5. Re: actionscript noob
                  Ned Murphy Adobe Community Professional & MVP

                  I'll attempt my answers via quoting your response...

                   

                  function(){return A.apply(null,[this].concat($A(arguments)))}

                  I don¹t know a thing about AS. Wish I did. Let me see if I understand. On

                  the last frame of each clip (except the last one), I add

                  _parent.loadNext(); Is that All I add or is there more to it? Does anything

                  go into the parentheses?

                   

                  That is all, except you probably also want to add a stop(); command just before that line.  Nothing in the parentheses.

                   

                  On the main movie timeline I add:

                  var linkageIDs:Array = new Array("MC1", "MC2", "MC3",....etc);

                  var nextMC = 0;

                  this.createEmptyMovieClip("mcHolder", this.getNextHighestDepth());

                  mcHolder._x = 10; // place it where you want the movieclips to be

                  mcHolder._y = 10;

                   

                  function loadNext(){

                       mcHolder.attachMovie(linkageIDs[nextMC], "anyname", 1);

                       nextMC += 1;

                  }

                   

                  Would this go on an actions layer in the main timeline? Sure. I realize I have to

                  change MC1, MC2 etc to my identifier names. Is ³anyname² a name I assign to

                  the empty movie clip?  the empty movieclip is named mcHolder.  This will act as

                  the home where you load the movieclips.  "anyname" can stay just as it is

                  shown since you have no use for it - it is the name for each movieclip you load.

                   

                  Any help you can give to help me understand is greatly appreciated. I know I

                  could just create all 8 clips and run them concurently on the timeline

                  adding enough empty frames to account for the clip that precedes each of the

                  following clips but that would be a messy way of doing it.

                   

                  You could load them into 8 consecutive frames, each with a stop() in it, and have

                  each one tell the main timeline to move to the next frame when each finishes...

                  but that's another approach--you might learn more trying what I've offered first.

                  If you're satisfied that your wonderings have been answered, please mark the

                  thread as such.

                   

                  1 person found this helpful
                  • 6. Re: actionscript noob
                    TheEricBraun Level 1

                    Im not very great with actionscript myself. But if u take these movie clips and place them onto the stage where u would like them to appear. You could just mask them when you would like to appear and then when you are finished with them you could add an unloadMovie(this); Actionscript. or if u would like to use them again a this._visible = false;

                     

                    Probably may wanna use neds suggestions. but worst case senario try this or something? :S

                    • 7. Re: actionscript noob
                      mmorse22 Level 1

                      I did what you stated and this is what happens when I test the movie. I get

                      these messages:

                      Syntax error      mcHolder.attachMovie(linkageIDs[nextMC], "anyname", 1);

                      Syntax error      nextMC += 1;

                       

                      Maybe I¹ll try you other approach. Thanks for all you help.

                      --

                      Mark Morse