17 Replies Latest reply on Sep 3, 2008 2:00 PM by kglad

    onLoad??

    mr.nazarko
      hello -

      ive managed to create a loop that loads some xml and images,
      but im struggling with creating an 'onLoad' type event for this line of code --- R1item.image_holder.loadMovie(R2photoURL[j]);

      so when then the R2photoURL[j] is finally loaded an event will occur.

      could someone point me in the right direction
      what should i be using?

      thanks,
      anton.
        • 1. Re: onLoad??
          kglad Adobe Community Professional & MVP
          the movieclip onLoad() method only executes for movieclips that are in your library and placed on-stage in the authoring environment.

          it does not execute when a file is loaded into a target movieclip.

          either use the onLoadInit() method of the moviecliploader class'es listener object or create a loop and check the getBytesLoaded() and getBytesTotal() methods of the target movieclip.
          • 2. Re: onLoad??
            mr.nazarko Level 1
            hello --- thanks!

            ive been trying to implement the onLoadInit using the help files -
            see attached code:

            but im obviusly doing something wrong.
            any suggestions?

            thank you,
            anton.
            • 3. Re: onLoad??
              kglad Adobe Community Professional & MVP
              you need to use a moviecliploader instance if you want to use methods of its listener (like onLoadStart, onLoadComplete and onLoadInit).

              check the flash help files for how to use the moviecliploader.
              • 4. Re: onLoad??
                mr.nazarko Level 1
                thanks!
                works perfectly!
                • 5. Re: onLoad??
                  kglad Adobe Community Professional & MVP
                  you're welcome.
                  • 6. Re: onLoad??
                    mr.nazarko Level 1
                    hello --
                    although the onLoadInit is working fine - i have run into another problem.

                    the mclListener is called during a loop,
                    by the time all images are loaded the mcLoader and mclListener.onLoadComplete will only effect the last movie loaded.

                    im trying to set up a mclListener that will work with every cycle --
                    var mclListener[j]:Object = new Object();

                    but it doesnt work.

                    do you have any advice?
                    thanks again - i really appreciate the help.









                    • 7. Re: onLoad??
                      kglad Adobe Community Professional & MVP
                      var mclListener:Object = new Object();

                      var mcLoader:MovieClipLoader = new MovieClipLoader();
                      mcLoader.addListener(mclListener);

                      should be outside your while-loop.
                      • 8. Re: onLoad??
                        mr.nazarko Level 1
                        Hello —
                        i have tried you suggestions without luck,
                        the mclListener.onLoadStart, onLoadComplete ect will only affect the last movie loaded into the movieClipLoader.

                        I think i have to create a new instance of the movieClipLoader for each pass in the with loop - but not sure how.

                        the website can be viewed here
                        http://www.antonnazarko.com/butterV2/random_tween_2.html

                        do you have any more advice?

                        • 9. Re: onLoad??
                          kglad Adobe Community Professional & MVP
                          remove your listeners (onLoadStart and onLoadComplete and onLoadInit) from your while-loop, too.
                          • 10. Re: onLoad??
                            mr.nazarko Level 1
                            Hello -
                            ive been struggling with this all week trying to find a solution.
                            i followed your instructions - but unfortunately i the mclListener will only effect the last mcLoaded loaded.

                            do you have another suggestion?

                            thank you,
                            anton,





                            • 11. Re: onLoad??
                              kglad Adobe Community Professional & MVP
                              well, what is it you expect them to do?

                              they execute for each item loaded. but when the first onLoadComplete executes R1item is going to reference

                              _root.contentSpace.row1["row1_holder","row1_holder" + (R2.length-1)]

                              because the while loop completes execution before the first load even starts.

                              to remedy, use a relative path from the target movieclip (R1item.image.holder) to R1item. ie,

                              target._parent._parent.
                              • 12. Re: onLoad??
                                mr.nazarko Level 1
                                thanks --
                                although im a bit lost.
                                i understand what your saying but not sure how to implement.

                                where do i use the relative path?
                                on the mcLoader.loadClip((R2photoURL[j]),R1item.image_holder); ?

                                or the

                                mclListener.onLoadComplete = function(target_mc:MovieClip) {
                                R1item._alpha = 50
                                trace ("complete");
                                };

                                im sorry-
                                could you give an example?



                                • 13. Re: onLoad??
                                  kglad Adobe Community Professional & MVP
                                  mclListener.onLoadInit = function(target_mc:MovieClip) {
                                  target_mc._parent._parent._alpha = 50;
                                  trace ("oninit");
                                  };
                                  • 14. Re: onLoad??
                                    mr.nazarko Level 1
                                    thank you so much kglad -
                                    i truly appreciate all your help.

                                    am i right that
                                    "target_mc._parent._parent._alpha = 50" targets the entire "row1" ?

                                    im trying to target each instance of R1item cycled through the while loop.
                                    something like this

                                    mclListener.onLoadInit = function(target_mc:MovieClip) {
                                    R1item.loader._alpha = 0;
                                    trace ("oninit");
                                    };
                                    • 15. Re: onLoad??
                                      kglad Adobe Community Professional & MVP
                                      yes, that alpha change affects row1. if you want to affect R1item, use

                                      target_mc._parent._alpha = 50;

                                      in the onLoadInit().
                                      • 16. Re: onLoad??
                                        mr.nazarko Level 1
                                        thank you!!!!!
                                        • 17. Re: onLoad??
                                          kglad Adobe Community Professional & MVP
                                          you're welcome.