9 Replies Latest reply on Oct 18, 2007 10:57 PM by Newsgroup_User

    fill color in movieclip

    Level 7
      with (myClip) {
      moveTo(0,0);
      lineTo(50,0);
      lineTo(50,100);
      lineTo(0,100);
      lineTo(0,0);
      }

      this creates shape which is empty .
      I want to fill the shape created after i have set a certain parameter to
      true. How to do that with movieclip.
      beginFill not usable since it starts filling just from begining.



        • 1. Re: fill color in movieclip
          Level 7
          >>beginFill not usable since it starts filling just from begining.

          Have you tried it and it's not working for you? beginFill is really the only
          way to fill a shape with the drawing API. Is it that you're wanting to draw
          a shape on screen and only show its outline - and at some later point fill
          it? If so, you'd just need to run the same code over, this time turning on
          fill... You might change your supplied code to something like this:


          with (myClip) {
          if(doFill){
          beginFill(0xFF0000);
          }
          moveTo(0,0);
          lineTo(50,0);
          lineTo(50,100);
          lineTo(0,100);
          lineTo(0,0);
          if(doFill){
          endFill();
          }
          }

          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. fill color in movieclip
            clbeech Level 3
            Here's another thought (crazy though!!!) you could create a BitmapData object to perform the fill. when the condition is triggered try this function, and pass in the instance, and the hex color choice, as in:

            fillClip(myClip, 0xFF0000);

            EDIT: ok, my bad, I forgot a couple of things here, and am changing the code. mainly the 'fill color' value must be a 32 bit ARGB format, as in: 0xFFFF0000. and don't forget to import the BitmapData class, I'm just gonna throw the whole test in there :)

            • 3. Re: fill color in movieclip
              Level 7
              This seems to work in sensce creates a bitmap as looks from code .but the
              problem is.
              My "clip" argument is like _root.mc["subMc"+x] which comes to undefined
              inside function.
              when fill.attachBitmap used places the bitmap on top,left and not where the
              "clip" is.
              What is the issue in it.


              "clbeech" <webforumsuser@macromedia.com> wrote in message
              news:felaoh$k2i$1@forums.macromedia.com...
              > Here's another thought (crazy though!!!) you could create a BitmapData
              > object
              > to perform the fill. when the condition is triggered try this function,
              > and
              > pass in the instance, and the hex color choice, as in:
              >
              > fillClip(myClip, 0xFF0000);
              >
              >
              >
              > function fillClip(clip, paint) {
              > var fill = clip.createEmptyMovieClip('fill', 0);
              > var bmp = new BitmapData(clip._width, clip._height, false, paint);
              > fill.attachBitmap(bmp, 0);
              > bmp.draw();
              > }
              >


              • 4. fill color in movieclip
                clbeech Level 3
                Sorry, man, you must have grabbed that code before I'd made my edit, and I'm afraid I'd 'winged' it on the spot. But then though 'hey I outta test that', then realized there were some better ways to orgainize it. Take another look at the code block above, I'd changed several elements.

                In this system, I decided that it would be better to draw directly into the clip that is being called, and should solve the placement issue, attaching the bmp directly to it.

                Additionally, instead of calling '_root' try: '_level0.mc[ ... ]' I assume then that you have a 'parent' container named 'mc' that 'myClip' is drawn in. Using the access operator should work here as a parameter. But I think I would put the function itself on the main timeline, and make calls to the function from a depth as in:

                _level0.fillClip(_level0.mc[ ... ], 0xFFFF0000);

                also don't forget the 32bit ARGB format.
                • 5. Re: fill color in movieclip
                  Level 7
                  Can u send the exact code please.


                  "clbeech" <webforumsuser@macromedia.com> wrote in message
                  news:feo5eq$525$1@forums.macromedia.com...
                  > Sorry, man, you must have grabbed that code before I'd made my edit, and
                  > I'm
                  > afraid I'd 'winged' it on the spot. But then though 'hey I outta test
                  > that',
                  > then realized there were some better ways to orgainize it. Take another
                  > look
                  > at the code block above, I'd changed several elements.
                  >
                  > In this system, I decided that it would be better to draw directly into
                  > the
                  > clip that is being called, and should solve the placement issue, attaching
                  > the
                  > bmp directly to it.
                  >
                  > Additionally, instead of calling '_root' try: '_level0.mc[ ... ]' I
                  > assume
                  > then that you have a 'parent' container named 'mc' that 'myClip' is drawn
                  > in.
                  > Using the access operator should work here as a parameter. But I think I
                  > would
                  > put the function itself on the main timeline, and make calls to the
                  > function
                  > from a depth as in:
                  >
                  > _level0.fillColor(_level0.mc[ ... ], 0xFFFF0000);
                  >
                  > also don't forget the 32bit ARGB format.
                  >


                  • 6. Re: fill color in movieclip
                    clbeech Level 3
                    OK, here's the code again with variable names as you have, although I don't believe you should use 'x' as the numeric value, since it is an Object keyword property, it still seems to function just fine. If '_root.mc['subMc'+x]' was coming to undefined, it may be that you were calling the function previous to the instance being instatiated on the timeline. make sure you call the 'fillColor' function after the MC has been drawn.
                    • 7. Re: fill color in movieclip
                      Level 7
                      not solving the goal yet.


                      "clbeech" <webforumsuser@macromedia.com> wrote in message
                      news:fevtpu$5q6$1@forums.macromedia.com...
                      > OK, here's the code again with variable names as you have, although I
                      > don't
                      > believe you should use 'x' as the numeric value, since it is an Object
                      > keyword
                      > property, it still seems to function just fine. If '_root.mc['subMc'+x]'
                      > was
                      > coming to undefined, it may be that you were calling the function previous
                      > to
                      > the instance being instatiated on the timeline. make sure you call the
                      > 'fillColor' function after the MC has been drawn.
                      >
                      >
                      > stop();
                      > import flash.display.BitmapData;
                      >
                      > var x = 0;
                      > var mc = this.createEmptyMovieClip('mc', 0);
                      > mc["subMc"+x] = mc.createEmptyMovieClip('subMc'+x, 0);
                      >
                      > mc["subMc"+x].moveTo(0,0);
                      > mc["subMc"+x].lineTo(50,0);
                      > mc["subMc"+x].lineTo(50,100);
                      > mc["subMc"+x].lineTo(0,100);
                      > mc["subMc"+x].lineTo(0,0);
                      > mc["subMc"+x]._x = 40;
                      > mc["subMc"+x]._y = 40;
                      >
                      > //trigger this from you're conditional
                      > fillClip(_root.mc["subMc"+x], '0xFFFF0000');
                      >
                      > function fillClip(clip, paint) {
                      > var bmp = new BitmapData(clip._width, clip._height, false, paint);
                      > clip.attachBitmap(bmp, 0);
                      > bmp.draw();
                      > }
                      >


                      • 8. Re: fill color in movieclip
                        clbeech Level 3
                        hmmm .... it seems to work fine for me in testing, and only fills the MC regardless of it's position on Stage. What's not working for you?
                        • 9. Re: fill color in movieclip
                          Level 7
                          Can you send the fla somewhere.


                          "clbeech" <webforumsuser@macromedia.com> wrote in message
                          news:ff7qj5$pe3$1@forums.macromedia.com...
                          > hmmm .... it seems to work fine for me in testing, and only fills the MC
                          > regardless of it's position on Stage. What's not working for you?