10 Replies Latest reply on Dec 1, 2008 7:55 AM by kglad

    Problem with draw function

    Maggical Level 1
      Hi there,

      I have a movie clip that I want to apply the draw function to (so I can save an image from it). It all works great, but the problem now comes when inside that movie clip I have another one, with a loaded image, and scaled.

      The draw function let's works perfect, except for the fact that the movie clip that's inside the one I'm making the draw doesn't render scaled, it renders as it is on the library...

      I read something about using a Matrix Transform for it, but can't make it work...

      Any help?

      Thanks,

      Javier
        • 1. Re: Problem with draw function
          kglad Adobe Community Professional & MVP
          if you mean you're using the bitmapdata class'es draw method, everything is rendered untransformed. to render as you view on stage you should create a matrix instance and assign its a,d,tx and ty properties to match your movieclip and use that matrix in your draw() method.
          • 2. Re: Problem with draw function
            Maggical Level 1
            Yeah, I'm using that, but I've tried using a matrix but couldn't make it work.

            This would be the case:

            picture_mc is always at scale 100%
            inside picture_mc I have lens_mc that varies it's scale as the user changes it...

            Once the user hits a button I need to use the draw function to capture that, but it renders picture_mc AND lens_mc at 100%, ignoring the scale on lens_mc...

            Would that be solved if I use the matrix correctly? Could you give me an example of how to do this? I've tried that solution but don't seem to get the answer...

            Thanks a lot,

            Javier
            • 3. Re: Problem with draw function
              kglad Adobe Community Professional & MVP
              yes, that would be solved if you used the matix correctly:

              • 4. Re: Problem with draw function
                Maggical Level 1
                Sadly that code gives me the same result that I had before... I can save the image that's in the movie clip #1, but the movie clip #2 that's inside the #1 and transformed doens't keep it's transformations, it just renders as it is in the library... :S

                Any other option?

                Thanks,

                Javier
                • 5. Re: Problem with draw function
                  kglad Adobe Community Professional & MVP
                  then you're doing something wrong with the code i gave.
                  • 6. Re: Problem with draw function
                    Maggical Level 1
                    I just replaced the "mc" in your code, with the route to the mc #1 in my stage. And to visualize the drawn area, I just save it to a jpg using this:

                    BitmapExporter.saveBitmap(bmp,"my_photo.jpg","fastscan",0,100);

                    From http://www.quasimondo.com/archives/000572.php

                    Am I missing something?
                    • 7. Re: Problem with draw function
                      kglad Adobe Community Professional & MVP
                      you could be missing quite a few things is that were all you were doing.

                      1. you must be importing the flash.display.bitmapdata class, to even start.

                      2. it's not clear you're using the code i supplied correctly and

                      3. it's not clear you're using the bitmapexproter class correctly

                      what not start with something simpler and build your way up? create a fla and see if you can create a scaled bitmap that matches your movieclip?
                      • 8. Re: Problem with draw function
                        Maggical Level 1
                        quote:

                        1. you must be importing the flash.display.bitmapdata class, to even start.


                        I am

                        quote:

                        2. it's not clear you're using the code i supplied correctly and


                        Guess so, I did what I explained above. The only thing I replaced from your code was "mc", I used the name of the movie clip I want to draw instead of that.

                        quote:

                        3. it's not clear you're using the bitmapexproter class correctly


                        Seems to work perfectly.

                        quote:

                        what not start with something simpler and build your way up? create a fla and see if you can create a scaled bitmap that matches your movieclip?


                        I'm on it, I'll let you know how it goes...

                        Thanks,

                        Javier
                        • 9. Re: Problem with draw function
                          Maggical Level 1
                          Well, just test the code alone and it seems to be working, maybe I have some problems due to the routes of things...

                          Thanks a lot, I'll solve it from here...

                          Javier
                          • 10. Re: Problem with draw function
                            kglad Adobe Community Professional & MVP
                            you're welcome.