4 Replies Latest reply on Oct 12, 2018 5:40 AM by Ibarim

    Cut out transparent background with AS3

    Ibarim Level 1

      Hey,

      I'm working with Flash Builder (previously Flex). I've got hundreds of vector images in .swc format. Problem is that pics have big transparent background. Like whole object is 400x400 but the drawn content is 50x50. I'm looking for a way to remove this background with AS3 code in Flash Builder. Is there a way to do it? Thare are no instance names in these pics. So I'm looking for a way to cut out only visible content.

      I could cut out content in Flash and create new object without backgrounds, but it's a lot of work for that many objects.

        • 2. Re: Cut out transparent background with AS3
          Colin Holgate MVP & Adobe Community Professional

          If your goal is to reuse some old graphics that you only have inside SWCs, you could rename the SWC to be .zip, uncompress it, then import the SWF into an FLA, to get at the original sized vectors.

          • 3. Re: Cut out transparent background with AS3
            Ibarim Level 1

            I think it's a diffrent kind of problem, I have the original .fla files available.

            I did what you said and didn't work. I imported .swf to .fla inside Animate. But the swf should have hundreds of pics inside and I don't see any of them, just the swf object with empty stage.

             

            Anyway, graphics were made with AI and then imported to Animate. In Animate all pics have invisible mask layer around them. I can see this mask when I go inside the object by double-click. I suppose this invisible mask background was the stage size in AI. Mask is not on the main movieclip but rather every part of main movieclip is a movieclip with mask layer. I'm not a graphic designer so it's hard to explain, I'll attach expample .fla to this message. WeTransfer

            What I need to do is use those images in normal size, without the masks.

            For example in this .fla attached to this message - I have pants with 350px height and 100px width. But because of the masks whole MC is 340 width x 520 height. And I want just simple pants in 100x350px with normal registration point at 0,0.

            So I wonder If I can do this in AS3 by some kind of cutting out only the visible parts of swc object. Or if it's not possible in AS3/Flex, how can I remove this mask in Adobe Animate?

            After removing mask I'd need to put the visible object on 0,0 registration point. Because now the mask makes every object the same big size while content is smaller. Removing masks manually will take lot of time because I have around 1000 pics, every one of them is made of few other mc with masks.

            • 4. Re: Cut out transparent background with AS3
              Ibarim Level 1

              I've found interesting solution in DMTAtlas, but I don't know how to replicate this behaviour.

              When genereting atlas with DMT I save the atlas on hard drive and can see what kind of objects are there. I use command:

               

              dmtBasic.process(false,param,true);

               

              When param is set to 0 the object from .swc rasterizes in normal way - image is surrounded by mask and there is only one image in atlas.

              pic10.png

              But when I set param to 1 (or above) then the mask and image are rasterized separately. Then the atlas has two images: mask and acctual image.

              pic20.png

              (the red background is not a problem, it's just an option in DMT, don't mind that)

              This way I can get the image without the mask, but only in raster format. I need to get it in vector format, but don't know how. I tried to understand what DMT is doing to my object but I can't understand how it works. I know there is something happening in AssetsGroupBuilder class, but that's all I was able to find out.