4 Replies Latest reply on Nov 4, 2007 8:13 AM by clbeech

    basic movie clip loader and load vars question


      I'm a designer who knows only the most basic Action Script, so i'm muddling through a fairly big project and learning as i go. I'm using AS2, mostly, though my version of Flash is CS3 (i just don't know any AS3 at all to know where to begin, so i'm publishing all swfs with AS2).

      The thing that's throwing me off is that all info in the site -- jpeg thumbnails, text labels -- need to be easily changed outside Flash. I need to use MovieClipLoaders and LoadVars to keep all text and jpeg elements as external files. The IT guy at the company i'm doing the site for needs to be able to swap out thumbnails and text info whenever he needs to update the site, and he doesn't know Flash at all.

      So, the first problem is that i am loading multiple jpegs into different containers. i basically have 12 containers in one fla file. I need to keep them in separate containers because they need to animate individually. So here is the code on the first frame:


      var myMCL:MovieClipLoader = new MovieClipLoader();
      myMCL.loadClip("homePage/images/HPthumb1.jpg", "container1");
      myMCL.loadClip("homePage/images/HPthumb2.jpg", "container2");
      myMCL.loadClip("homePage/images/HPthumb3.jpg", "container3");
      myMCL.loadClip("homePage/images/HPthumb4.jpg", "container4");
      myMCL.loadClip("homePage/images/HPthumb5.jpg", "container5");
      myMCL.loadClip("homePage/images/HPthumb6.jpg", "container6");

      myMCL.loadClip("homePage/images/HPvideothumb1.jpg", "containerV1");
      myMCL.loadClip("homePage/images/HPvideothumb2.jpg", "containerV2");
      myMCL.loadClip("homePage/images/HPvideothumb3.jpg", "containerV3");
      myMCL.loadClip("homePage/images/HPvideothumb4.jpg", "containerV4");
      myMCL.loadClip("homePage/images/HPvideothumb5.jpg", "containerV5");
      myMCL.loadClip("homePage/images/HPvideothumb6.jpg", "containerV6");
      function onLoadInit(mc:MovieClip) { trace("content has been loaded into "+mc);



      i just want all the MCs to load on the first frame, even if they're not visible, so i can call on them later in the movie. i also want the playhead to freeze there while everything loads and then move to my "start" label frame once ALL MCs are loaded. i added a listener to do this. BUT it seems the listener works when ANY movie clip is loaded. so it means as each one loads, the playhead goes to "start" over and over again, kind of stuttering.

      Is there a way to use a Listener to listen to when ALL movie clips have finished loading, and only then go to a specific frame?

      My second problem is that I have a text MC that follows the user's mouse. I would like it to load in dynamic text from an external text file. The text needs to change depending on the mouse rollover. There are 6 hit areas (thumbnails), and the text changes while it follows the mouse along the 6 hits.

      so to do this i have the following script on each hit :

      on (rollOver) {
      label1.menuLabel = "LABEL1";

      So here, for example, the menu label, "LABEL1" is for the first thumbnail, and would change to something else when the rollover goes to another thumbnail. Each hit has its own code similar to the above.

      on the scrolling text itself i have the following code:

      onClipEvent (enterFrame) {
      //x movement
      if (mx<_x) {
      else {
      if (mx<_x) {
      else {

      ...so that the text MC follows the user's mouse.

      This works fine, but it doesn't have dynamic text, because the moving text MC has to be a single MC for the effect to work. In other words, I would normally make a sequence of 6 MCs that have LoadVars and dynamic text, but I can't do that in this case. How do I load the text into one MC dynamically so that the text changes with every rollover?

      I would HUGELY appreciate any help!

      thanks very much!

        • 1. Re: basic movie clip loader and load vars question
          clbeech Level 3
          OK, first problem, first :) what you need here is to add a function that determines if everything has been loaded, this would be simplest I think in your case here. But you also have duplications of basically the same names for the loading item so you could use an incrementor to make things easier. So on the first frame set up you code like this:

          PS: I'll work on the second in another post.

          • 2. Re: basic movie clip loader and load vars question
            clbeech Level 3
            OK now for the second problem, I don't really see why you can't use Loadvars and a dynamic textfield in the MC instance. On the first frame of the text MC instance, use LoadVars and bring in the text, iterate it into an array, indexed at 0-5. Then from your onRollOver event (which you may want to put on the timeline) you simply refernce the MC and assign the index of that button to the textField within the MC. So in you MC (the one that follows the mouse) set up the array and the LV, then call from a button(ref 0-5) like so:

            • 3. Re: basic movie clip loader and load vars question
              jungleseed Level 1
              hi clbeech,

              Thanks for taking the time to respond! But I'm too new to really be able to decipher your code well enough to use it.

              I kind of understand what you're doing in the first response -- adding one to each item in my directory. I see you've used my directory names and container naming format... so I just copied and pasted your code into the first frame of my movie. When I tested the movie, nothing happened -- the playhead stayed on the first frame and nothing loaded. Was there any text there that I was supposed to replace?

              As for the second response -- again I'm too new to AS to know how to implement this. How do I create an array on the text MC, how do I index 0-5?

              thanks again.

              • 4. Re: basic movie clip loader and load vars question
                clbeech Level 3
                well let's see, I was doing a little guessing when I wrote that code, and was assuming that you have MC instances on the Stage with the instance names like : container1, container2, ... and that they were on the root level of the Stage and not within another MC, is this correct? (because it seems like a path issue)

                OH WAIT!! maybe not LOL!!, I forgot to include a call to begin the first loop iteration! After the 'nextLoad' function add this line:


                This should actually 'start' the sequence, LOL!!!
                Now for the second problem, go into the MC that you're using for the textfield,
                make an actions layer, and write an array there as below, later you can use LoadVars to bring in the text and propagate the array with it using the onLoad handler, but for now just test using static entries. In the code I'd given above, you see the ' ... the_array[0];' the [ ] are called an 'access operator' and is a reference to an 'index' in an array, by pointing to an index, we can retrieve a value or Object stored there. So in each of your buttons, you would change the index number to the corresponding text for that button, easy as cake ;) also remember that arrays are 'zero-based' which means that the first elements index is always 0, so for five labels the fifth labels array index will be 4, get it?

                So in the MC (I don't know what you've name it) write the following code in frame one (you also only need one frame) and the textField should be on another frame, dynamic field, embed the characters.