6 Replies Latest reply on Apr 24, 2008 1:10 PM by Rothrock

    "nested" EmptyMovieClip loaders

    jl2000 Level 1
      Hi -
      I'm re-using the code below to load in external clips and trigger my little preloading visual (eagleLoader). At the second level (START->STAGE->Splash) when STAGE loads Splash, the loading.txt.text alpha doesn't work. Not a good sign because I was planning on re-using this code many more times, on deeper levels of the project.

      When I re-use this should I keep creating a new "container_mc", or re-target the same one that was created on "STAGE" or use a different name each time? I'm not seeing any difference. (In most cases the new movie will be REPLACING the existing one - but not always.)
      Why would the the dynamic text box "loading_txt" no shift it's alpha to 0?

      TIA some insight.

      JL
        • 1. Re: "nested" EmptyMovieClip loaders
          Rothrock Level 5
          Ah! I see you have already found more issues!

          Sure it is okay to reuse the same container. Some things to consider. When you reload a container the new content instantly replaces the old content. (Well once it is loaded in.) So if you are going to want transitions between the old and the new you might need to have container1 and containter2 and then you could fade or slide in/out the containers. Of course then you also need to keep track of which one you last loaded and which one you should load now. You will also need worry about which one is on top!

          Of course you can't preload very far ahead with only 2 containers. Imagine you had a book with 5 chapters. And chapter 4 had some big stuff in it. Now imagine that chapter 2 took a while for the user to read, but didn't have any big stuff to load. It might be nice to load ahead two (or three) chapters. That way when the user got to 4 it would already be loaded. If they just skipped ahead to chapter 4 they might have to watch a preloader, but if they followed the regular sequence...

          In that case you might want to have a container for each chapter and load them all silently behind the scenes. Just showing them and their progress if the user jumps ahead. Just something to think about.

          I think the problem with the text field is that you are trying to set to properties at the same time! .text and ._alpha are both properties of a text field so you can do the following two things, but not at the same time:

          loading_txt.text="0";
          loading_txt._alpha=0;

          Notice that the first one sets the text property, that is the text characters that are displayed in the textfield, and it takes a string. The second one sets the _alpha property and takes a number.

          Now that brings me to two suggestions. First. If you don't want something to show, set its _visible property to false. Things with an alpha of zero are still there and you might notice that if a text field is selectable and has an alpha of zero you will get the ibeam when your pointer moves across its position. Same thing with movieclips with mouse events. You can still click them if they have an alpha of zero, but not if the _visible=false.

          The next thing is that if you try and fade or rotate text in a dynamic field you will need to have the font embedded or it won't work.

          And the final thing you should know is that you won't see onLoadProgress working when you test publish to a local environment. You will need to actually put the file on a server to see that work.

          You mentioned in your other post that you plan to publish a projector. Well by definition a projector is local so your onLoadProgress won't work in a projector. But we can cross that bridge when we get to it!
          • 2. Re: "nested" EmptyMovieClip loaders
            jl2000 Level 1
            Whew! That's a lot to think of.

            OK - START loaded STAGE in "container_mc" and then STAGE loaded Splash into "container_mc". Splash did not replace STAGE - it just laid on top...real nice. I think I know why - START'S container is different from STAGE's. Is that correct?

            During onLoadProgress (STAGE loading Splash) I have one message in loading_txt.text and onLoadComplete I want it to disappear. When I used loading_txt._visible=false; in the onLoadComplete - the onLoadProgress messge didn't show altogether. When I used "0" - either the first message stayed or it changed to "0".

            HERE'S the catch! The same code works when START loads STAGE!

            I'm being compulsive about onLoadProgress (and MCL in general) now because later on I'm going to need that tool in my bag. I just need to know I can make it (MCL with this eagleLoader) work right everytime - starting from now while it's simple. I can use the Bandw Profiler to slow stuff down enough to tell that everything is working except the loading_txt is not going away as required.

            The next step on this is to make a function out of this so that I dont have to add 50 lines of code to every FLA. (Which is what I did last time.) If I can always use "container_mc", eagleLoader, & loading_txt, - then I'll only have to vary the URL in "my_mcl.loadClip("splash.swf", container_mc);".

            So I appreciate your input on making loading_txt behave but I'm not there yet.

            jl



            • 3. Re: "nested" EmptyMovieClip loaders
              jl2000 Level 1
              NEWS FLASH!
              That line that's supposed to disappear loading_txt doesn't work on the START loading STAGE either! It just gets covered up! The STAGE is a full screen background that stays in place forever.

              Does this help??
              • 4. Re: "nested" EmptyMovieClip loaders
                Rothrock Level 5
                Sorry I'm not following what the problem is. If START creates something called container on its timeline and then loads STAGE into it. And then stage creates something called container on its timeline then the paths from the top is:

                _level0 \\<- START is in here
                _level0.container \\ <-Stage is in here
                _level0.container.container \\ <-Splash is in here

                If you need to figure out where things are being created there are two things that I find helpful. Create your clips like this:

                var curClip:MovieClip=this.createEmptyMovieClip("container",10000);
                trace("Created clip at: "+curClip);

                That will trace out the whole path for the clips you are creating.

                The other is to go up to the debug menu in the test environment and select List Variables and then you can see what flash is keeping track of.

                Generally it would probably be a good idea to combine START and STAGE and then have stage manage all the loading of the other assets or at least at the next level of our outline. By that I mean if you have 5 different topics that stage will load stage should manage the loading of those. But if topic 3 also includes an external video and controls for that video then topic 3 should probably handle the loading of the video, but stage will handle the loading of topic 3.
                • 5. Re: &quot;nested&quot; EmptyMovieClip loaders
                  jl2000 Level 1
                  Rothrock - you just blew my mind!

                  _level0.container.container \\ <-Splash is in here - a revelation!
                  That can't be good.
                  I re-stacked the outline and eliminated STAGE - I think I have it as you suggest. The first thing that loads into START (automatically) is Splash which has 4 user-triggered buttons on it to Eng-FAQ, Eng, Span-FAQ, and Span.
                  START is the constant graphic background and all the other swfs have no background so they float nicely in place.

                  Yes - as you said - Eng will be a complete GUI (floating over START) with space on the side for topics, and the topics have space for the flvs. The same under Span. I'll handle all of that as it comes up.

                  BTW... Here's the old version.. The code inside here is a real mess (I did it so I know). I'm just trying to do it better from the ground up this time.

                  Thanks for the tips. I'll be back.

                  jl


                  • 6. Re: &quot;nested&quot; EmptyMovieClip loaders
                    Rothrock Level 5
                    Okay here is another trick, perhaps, for you. When the user selects the language set some variable like:

                    var curLanguage:String="/SP/"

                    Then have your files all have the same names, but just be in different folder. You can then get the assets by putting together some strings:


                    myMCL.loadClip(path+curLanguage+fileToLoad,"container");

                    Or some such like that. Where path was set to the location of your assets folder, curLanguage was set by the user's choice, and fileToLoad will always be the same -- for example FAQ.swf or fopic.flv.

                    You can combine all kinds of strings to make more complex names. For example you have topic_s1. Generally I find it easier to put things at the beginning or the end. So you could do:

                    SP_Topic_1.swf

                    That way it is easier to keep the Spanish language together and later to do something like:

                    fileName=langPrefix+"_Topic_"+counter+".swf"

                    Personally I also don't use the underscores because they make it harder to type correctly! But that is just my personal preference.

                    Hey I've been doing this a long time and pretty much only learned by doing the "wrong" thing a few times. It is always learn from what you did before and make the next one better. Good luck!