17 Replies Latest reply on Dec 4, 2007 3:37 AM by kansloos

    detect if mc is filled or empty

    kansloos
      Hi Folks,

      Does anybody know if it is possible (in fcs3) to detect /determine if a mc is filled or not?
      I have already determined the _x & the &y

      this is something I tried but did not work.

      if(mc._width==0)

      Could somebody help me out?

      Thnx
      BIEG
        • 1. Re: detect if mc is filled or empty
          Greg Dove Level 4
          Do you mean to detect if a movie has loaded?

          The old way to check this using loadMovie was via a loop to check getBytesLoaded() vs getBytesTotal()

          A better way is to use the MovieClipLoader class and when the onLoadInit handler of its listener is executed, you know your movieclip has loaded completely and can be manipulated with actionscript.
          There are some examples in this forum. You should do a search for MovieClipLoader in this forum and take a look through the threads for examples.
          You probably will be able to find tutorials with google as well just type moviecliploader tutorial in google and see what you get.
          • 2. Re: detect if mc is filled or empty
            kansloos Level 1
            thnx for the reply.

            i think i need to elborate a bit more:
            i have made 8 mc's.
            These i fill with a jpg from my array.
            when i click on my next button i 'activate ' a counter and all the mc 's are once more filled with a jpg.
            There are 9 jpgs and after the last jpg has been put in the mc it obviously is empty: i can see there's nothing in there.
            I want to detect when it is empty so I can fill it again.
            so (if mc_8 = noLongerFilled > put Img_1 in mc_8.

            Does that help?

            BIEG
            • 3. detect if mc is filled or empty
              Greg Dove Level 4
              Sorry, I don't understand what you're doing.

              1. You load (external) jpgs into your 8 movie clips. (the jpg urls are held in an array)

              2. clicking a button increments a counter (maybe that's what you mean?) and the movieclips get new jpegs? or do they rotate position?

              If you're trying to rotate positions, then the best way to do it would be to grab the bitmapData from each clip and swap them. But that's a little more complicated. What I think you're doing is loading from index 1 in your array.
              You can use the same code each time to load your images... just change the array.

              if your array is called kleuren

              the instead of using your counter , do this:

              kleuren.unshift(kleuren.pop());

              this puts the last element into the first position in your array. Now if you do the same loadMovie loop it will load in the different sequence.
              • 4. Re: detect if mc is filled or empty
                kansloos Level 1
                mmm. i tried but it didnt do what i wanted. I have indeed 9 mcs. fixed on stage.

                i have an array with 9 words and an array with 9 images.
                on click the images and the words should move one to the left as if you flip through a book. when i have refilled the 9 images for the last time (when mc_img7 is filled with the last item from the array and mc_Img8 is actually empty because the array is then empty) it should load again, starting with the first mc_Img that is no longer filled with an item from the 'origingal' arry.

                sorry for being vague: it is a bit difficult to correctly put into words how and what.

                BIEG
                • 5. Re: detect if mc is filled or empty
                  Greg Dove Level 4
                  I'm sorry but I'm afraid I still don't understand what you're trying to do.

                  Someone else might... perhaps its just me.

                  Sometimes its easier if you post a link to a test site where you can show what's currently happening and then describe it in a way that people can understand what's wrong by checking the test site.
                  • 6. detect if mc is filled or empty
                    kansloos Level 1



                    you're righrt

                    mustnt forget that ;)
                    • 7. Re: detect if mc is filled or empty
                      Greg Dove Level 4
                      I checked a couple of times over the past couple of hours but your link is giving a 404 - not found.
                      • 8. Re: detect if mc is filled or empty
                        Rothrock Level 5
                        GWD, no it isn't just you!

                        kansloos, I'm sure this might be a language problem, but this sentence doesn't make any sense, "There are 9 jpgs and after the last jpg has been put in the mc it obviously is empty: i can see there's nothing in there." Usually when you have put something into something the something is now full, not empty. Well maybe not full, but certainly not empty.

                        If you can see there is nothing there, where is the thing you put into it?

                        Are you trying to say that when you reach the end of the array you would like to start over? In that case all you do is compare the length of the array and if it is too big (or small depending) then you start over.
                        • 9. Re: detect if mc is filled or empty
                          kansloos Level 1
                          sorry for the confusion .
                          i will upload the file tonight / this evening./

                          i meant that 9 jpgs are being loaded in 9 mcs .
                          when cklicked they all shift one position. the nr 8 will be empty after one click.


                          any better?

                          BIEG
                          • 10. Re: detect if mc is filled or empty
                            Rothrock Level 5
                            Ah, that makes sense now. So you want number one to wrap and come back to what was number 9? Like this:

                            1, 2, 3, 4, 5, 6, 7, 8, 9
                            2, 3, 4, 5, 6, 7, 8, 9, 1
                            3, 4, 5, 6, 7, 8, 9, 1, 2

                            and so on?
                            • 11. detect if mc is filled or empty
                              kansloos Level 1
                              you rock!

                              excactly right.
                              (but only 8 numbers instead of nine... ;)
                              • 12. Re: detect if mc is filled or empty
                                Greg Dove Level 4
                                I got it backwards earlier then.

                                instead of
                                kleuren.unshift(kleuren.pop());

                                it should be:
                                kleuren.push(kleuren.shift());

                                to have that order reflected in your array each time.
                                • 13. Re: detect if mc is filled or empty
                                  kansloos Level 1
                                  sorry for the confusion but now
                                  http://www.bieg.nl/trial/index.html

                                  does work.
                                  • 14. Re: detect if mc is filled or empty
                                    Greg Dove Level 4

                                    With you navigation left and right buttons, it doesn't really make sense to be reloading each of the clips into new targets each time. You're better off repositioning and/or resizing the clips.

                                    You can use your array to store references to the clips in.

                                    if you store references to your loaded clips in
                                    kleuren

                                    (let's say your clip instances are called kleuren1, kleuren2 etc - and no, I have no idea what kleuren means).

                                    your kleuren array starts with

                                    [kleuren1, kleuren2, kleuren3 ] ...etc up to 8

                                    one of your buttons should do this to the kleuren array:

                                    kleuren.unshift(kleuren.pop());
                                    this makes:
                                    [kleuren1,kleuren2,kleuren3]
                                    become:
                                    [kleuren3,kleuren1,kleuren2]

                                    the other should do the opposite:
                                    kleuren.push(kleuren.shift());
                                    this makes:
                                    [kleuren1,kleuren2,kleuren3]
                                    become:
                                    [kleuren2,kleuren3,kleuren1]


                                    so that those two lines can handle cycling through the 8 clips one way or the other, simply by rotating the sequence in the array.
                                    And after that each button handler should call a function that cycles through the array and sets the _x, _y , _xscale and _yscale properties for each member of the kleuren array, e.g. updateKleurenDisplay() for example.

                                    [If I understand what you want to do correctly]

                                    quick example (not what you want, just a simple example)

                                    function updateKleurenDisplay(){
                                    for (var i=0;i<kleuren.length;i++) {
                                    kleuren[ i ]._x=40+i*50;
                                    }
                                    }


                                    • 15. Re: detect if mc is filled or empty
                                      kansloos Level 1
                                      hi gwd //


                                      thnx again for responding.

                                      it would indeed be the very thing i am after ;)
                                      • 16. Re: detect if mc is filled or empty
                                        Greg Dove Level 4
                                        :-) great!
                                        So did you get it working? (I checked the link and it wasn't changed)
                                        • 17. Re: detect if mc is filled or empty
                                          kansloos Level 1
                                          i have now a trial_1 and a trIal_2 where 2 has a doorbladeren.as .

                                          thought it would be so much more practical then me doing my best explainging my purpose ;)

                                          lemme know what you think of it