18 Replies Latest reply on Apr 14, 2007 12:32 AM by Greg Dove

    Resizing imported swf files...

    ApatheticAnonymous
      I have a movie clip that I want to import a swf file into, but the swf is larger than the movie clip's area. I tried using a resizing code for importing images that I found, but it makes the swf very small. Is there a way to control the size of the imported swf?
        • 1. Re: Resizing imported swf files...
          kglad Adobe Community Professional & MVP
          just load into an empty movieclip. then your swf won't be resized.
          • 2. Re: Resizing imported swf files...
            ApatheticAnonymous Level 1
            But I WANT it to resize to fit within the movie clip. Would dynamically creating a movie clip help?
            • 3. Re: Resizing imported swf files...
              kglad Adobe Community Professional & MVP
              if you dynamically create a movieclip, it will be empty. so, that should work well.

              using an empty movieclip to start, makes it easy to resize AFTER loading is complete. ie, you should use preloader code or the onLoadInit() method of the moviecliploader class' listener.
              • 4. Re: Resizing imported swf files...
                Greg Dove Level 4
                I did this recently where I had a backdrop clip that I wanted to serve as a 'screen' for jpgs I loaded in. I wanted them to resize to the full extent of the background clip and maintain their aspect ratio. The backdrop clip could have different dimensions at different points in time as well... anyhow this should work with swfs same as jpegs.

                So I'll explain it in my context as I don't know exactly yours (sorry this might sound a bit complicated because of that).

                #1 If your holderclip is called imageHolder and it contains a single clip inside at location 0,0 called imageBackdrop
                #2 You create an emptyMovieClip inside imageHolder and use it to load your swf into using a Loader with a listener
                #3 you have some code similar to this in your onLoadInit event for the Loader (onLoadInit lets you initialise things like size location etc before it displays)

                If you can do something like that then I think you should be on the right track for what I think you want to do.
                • 5. Re: Resizing imported swf files...
                  Greg Dove Level 4
                  And when I said 'Loader' it should be MovieClipLoader as per kglad's post.
                  • 6. Re: Resizing imported swf files...
                    Greg Dove Level 4
                    oh and kglad or anyone else: if you've got a way to improve my code, please let me know. I didn't try using _xscale or _yscale...maybe it could be done easier that way.
                    • 7. Re: Resizing imported swf files...
                      ApatheticAnonymous Level 1
                      Thank you for the contribution. I'm just going to have to try and make sense of it as it pertains to my file.
                      • 8. Re: Resizing imported swf files...
                        Greg Dove Level 4
                        Sorry, like I said its from a context that I'm familiar with and so yes you need to "translate" to yours. If its not easy or helpful feel free to post some code snippets so we can explain things in your context.
                        • 9. Re: Resizing imported swf files...
                          ApatheticAnonymous Level 1
                          Oh yes, I understand. I'm not as proficient in ActionScript as I'd like to be. I'll try to explain my situation a little better.

                          I have a rectangular movie clip centered in the middle of the screen that I want to load an external swf file into. This external swf file is saved from an Illustrator document, so it's larger than the rectangular movie clip that it will be imported into. Now, I've somewhat solved my problem by saving the Illustrator file as an swf that is the perfect size for the movie clip, but this isn't ideal as it causes more work to be done to the Illustrator file.

                          The external swf is named 'view' and I named the rectangular movie clip 'loader'. I've never created a multi-layered movie clip like your explained to, so it's a bit confusing for me. Hopefully you can help clarify.
                          • 10. Resizing imported swf files...
                            Greg Dove Level 4
                            Maybe something like this should work, based on what you said.

                            My code was a little more complicated because my equivalent of the loader clip changed size and shape sometimes and I had to accommodate that.

                            There's also another gotcha with this...its easier if the content inside your loader clip has its top left corner at 0,0. Otherwise you need to set target_mc's _x and _y properties in the onLoadInit area where I've indicated also.

                            To help understand the target_mc is just a reference to the view clip inside 'loader' that is passed to the onLoadInit listener function after the swf has loaded.
                            • 11. Re: Resizing imported swf files...
                              Greg Dove Level 4
                              Forgot: you should change the numbers 118 and 218 to whatever makes sense for the size of your loader clip
                              • 12. Re: Resizing imported swf files...
                                Greg Dove Level 4
                                Sorry just re-read your post... for your loader clip, do you want the rectangle that's inside it to serve as the background for your view clip, or do you just want to replace it's contents (the rectangle) completely (and keep it to the same size)? The code I posted was to keep the rectangle and have your view swf appear on top of it.
                                • 13. Re: Resizing imported swf files...
                                  ApatheticAnonymous Level 1
                                  Originally I wanted to replace the clip entirely; I don't need a background for it. But that will work. Thank you so much. I'm going to try it out right now.
                                  • 14. Resizing imported swf files...
                                    ApatheticAnonymous Level 1
                                    Okay, I tried the code but it didn't work. What within it do I have to change to fit my situation? I tried changing the instances of "target_mc" to "view", which is the movie clip that is created, but I'm not sure if that's what I need to do.
                                    • 15. Re: Resizing imported swf files...
                                      ApatheticAnonymous Level 1
                                      Many posts today. But success! Instead of modifying the width and height of the imported clip, I scaled the x and y axes by 60%, which I had figured out before.

                                      I wouldn't have been able to without your help, GWD. Thanks!
                                      • 16. Re: Resizing imported swf files...
                                        Greg Dove Level 4
                                        Sorry, I just caught up on this...pleased to see it works. If its always going to be the same size then you should be able to use fixed scaling - the 60%

                                        FYI in my example earlier I was using the other 'background' clip inside the main to 'measure' against, because I was loading clips (images actually) of different sizes and aspect ratios (portrait or landscape) onto a background that could be a different size or aspect ratio (portrait or landscape).

                                        I'm sorry if I made it sound more complicated originally than it was in the end, my example was a little more complicated because of what I just explained and therefore the required scaling could change. And I don't code things perfectly I can assure you. Maybe my code would be easier also using scaling instead of width and height as well... I didn't try that.
                                        • 17. Re: Resizing imported swf files...
                                          ApatheticAnonymous Level 1
                                          Regardless, you solved my problem.
                                          • 18. Re: Resizing imported swf files...
                                            Greg Dove Level 4
                                            I just had a blinding flash after responding to a question in another post.

                                            You can use the Loader component. Just set its .scaleContent property to true. It's a lot easier. Even so, you (and I, as well) have learnt something in understanding how to do this 'manually'. You might be happy with what you have already... if so that's fine, but maybe keep the Loader component in mind for this on future occasions.