Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Scaling down the size of an SWF even more

Explorer ,
Jul 05, 2018 Jul 05, 2018

I'm remaking an interactive animation from 10 years ago for Deviantart.com, but at one point they inserted an unpleasantly small size limit that no longer accepts drawings/animations bigger than 30 MB, which is a torture. The animation I'm remaking has character bios and a jukebox section with a few relevant songs. The bio pages have background music as well, so that's alot of music everywhere.

I work with Flash CS6, project size is 1000x625 px and set for Actionscript 2 and Flash Player 9.

The original from 10 years ago was 36 MB; it had lazy coding and manually repeated frames without the use of the "movie clip" or "graphic" ability.

The remake was 63 MB at first; and included better use of symbols and added more than double the songs it once had to the jukebox.

Since this was no where near being 30 MB, I applied some standard tricks like changing all the song's settings in the library itself to 80 kbps, some Photoshop backgrounds you would hardly see anyway to 50% quality, and of course keeping the publish settings to something similar. At this point I managed to lower everything to 43 MB, but I don't want to touch the quality further.
I don't have that many imported images I can downscale, except for the jukebox' main page, which shouldn't be touched too much since the drawing is the page, and I fear going lower than 80 kbps for the audio is going to negatively affect it and not even eat those last 13 MB's. I don't wish to change the pixel width, either, this project size is just perfect.

Any opinions on my worries or is there something else can I try?

eds2.jpgeds1.jpg

575
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 05, 2018 Jul 05, 2018

No problem!

The SWF has now only ~2 MB!

The solution is to use a very handful component called MediaPlayback.

You just set the URL for the song, set to auto play and done! Doesn't matter where the file is being hosted.

Then you put this component in each keyframe with the corresponding URL as if you were setting the song in the timeline.

Notice that I decompiled your SWF to run the test. Feel free to work from my FLA or simply copy the components layer to your file.

Also notice that I'm hosting the so

...
Translate
Community Expert ,
Jul 05, 2018 Jul 05, 2018

Hi.

Your project seems pretty cool.

I think it's better for you to host the mp3 files somewhere else and play them at runtime instead of including them in the FLA.

What do you think?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

I've never done that before.

When leaving out the argument of getting a smaller file size, is this method as good as directly including sounds? What hosting sites should I link to, something like Mediafire?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2018 Jul 05, 2018

No problem. I show you how.

Yeah. It is as good. The only thing you'll have to check if DeviantArt allows access from external sources. I guess it shouldn't be a problem though.

Notice in my examples I'm getting the sounds from various sources: YouTube assets library, Google Drive, my own website and even from the local file system.

You can choose whatever works best for you.

Just please make sure to check if you can use direct links to Google Drive assets (I used a online direct link generator to get direct access to the mp3 instead of using that default link type that Google Drive provides) as I'm using here. Because this example is just for learning purposes and I don't know if it is allowed to real cases usage.

Also, you cannot put your MP3 in the YouTube library. I'm using a YT song here just to showcase the possibilites.

You can totally ignore the SoundPlayer code if you wish. Only use the SoundPlayer.as file to play your sounds as in the example below.

FLA download:

animate_cc_as3_play_online_sounds.zip - Google Drive​

AS3 code:

FLA:

import flash.events.MouseEvent;

var bgmList:Vector.<String> = new <String>

[

     "https://www.youtube.com/audiolibrary_download?f=m&vid=af6b6c82fcfa686f",

     "https://drive.google.com/uc?export=download&id=1vSBKNCT87z78yfkJIb9JvoTaAV5PPv2V",

     "bgm/Stuff.mp3",

     "https://joaocesar.000webhostapp.com/adobe/Gas_Pedal.mp3"

];

function mouseHandler(e:MouseEvent):void

{

     if (e.type == MouseEvent.CLICK)

     {

          if (e.target)

               SoundPlayer.playSound(bgmList[uint(e.target.name.replace("button", ""))], "bgm");

     }

}

button0.addEventListener(MouseEvent.CLICK, mouseHandler);

button1.addEventListener(MouseEvent.CLICK, mouseHandler);

button2.addEventListener(MouseEvent.CLICK, mouseHandler);

SoundPlayer.playSound(bgmList[3], "bgm");

SoundPlayer.as:

package

{

     import flash.display.MovieClip;

     import flash.display.SimpleButton;

     import flash.events.MouseEvent;

     import flash.media.Sound;

     import flash.media.SoundChannel;

     import flash.media.SoundTransform;

     import flash.net.URLRequest;

     import flash.utils.setTimeout;

     public class SoundPlayer

     {

          public static var bgmChannel:SoundChannel = new SoundChannel();

          public static var sfxChannel:SoundChannel = new SoundChannel();

          public static function playSound(path:String, channelType:String, volume:Number = 1, start:Number = 0, loops:int = 0):void

          {

               var sound:Sound = new Sound();

               var sTransform:SoundTransform = new SoundTransform();

               sound.load(new URLRequest(path));

               if (channelType == "bgm")

               {

                    bgmChannel.stop();

                    bgmChannel = sound.play(start, loops);

                    sTransform.volume = volume;

                    bgmChannel.soundTransform = sTransform;

               }

               else if (channelType == "sfx")

               {

                    sfxChannel.stop();

                    sfxChannel = sound.play(start, loops);

                    sTransform.volume = volume;

                    sfxChannel.soundTransform = sTransform;

               }

          }

     }

}

I hope this helps.

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

Thank you, buddy, but looking at this, I'm now worried. I'm working with Actionscript 2 and the hundreds of buttons in my project are all set to that.
Is this going to be alot of work for me?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2018 Jul 05, 2018

I do recommend you to switch to AS3 because AS2 is not even supported by Animate CC and it's way harder to find AS2 resources these days. Not to say the difference in power, performance, versatility, and so on.

Is there something else to do in the SWF besides seeing the characters bios and listening to the jukebox songs?

If not, I may be able to suggest a code structure for you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

But I'm not working with Animate, I still have Flash CS6. I don't have the motivation to redo all the coding after already redoing them once.

I've never worked with Actionscript 3 before, it always felt like alot of effort and not as obvious as 2. I need to start a new project in which I can teach myself how it works first, but that's not going to be this project. I've already spent a tremendous time on it, I wish for simpler tricks.

In my original post I gave the link to my old animation. Everything in there is what's going to be in here, just prettier, I guess.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

A quick update inbetween:
I've shortened the tracks on the character pages that were longer than a minute, and managed to get the size down to 39 MB. Still not there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

A quick update inbetween:
Still cutting in music and managed to get the size down to 36 MB. There's almost nothing to cut in anymore.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

At this point there's only one thing I can do to just get below the 30 MB limit, which is lower the sound quality to 64 kbps. But do not want..

I can't change the Actionscript for this, I just don't have the patience.

Is worsening the quality my only other option?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2018 Jul 05, 2018
LATEST

No problem!

The SWF has now only ~2 MB!

The solution is to use a very handful component called MediaPlayback.

You just set the URL for the song, set to auto play and done! Doesn't matter where the file is being hosted.

Then you put this component in each keyframe with the corresponding URL as if you were setting the song in the timeline.

Notice that I decompiled your SWF to run the test. Feel free to work from my FLA or simply copy the components layer to your file.

Also notice that I'm hosting the songs in my server. You should host them with a server that belongs to you.

Another thing is that I put all components with all the links in the first frame in the hope it somehow preloads the songs and the start delay can be smaller.

FLA download:

eds_highschool_flash_by_vampiremeerkat_decompiled.zip - Google Drive

Online preview:

https://joaocesar.000webhostapp.com/adobe/deviantart/eds_highschool_flash_by_vampiremeerkat_decompil...

I hope this helps.

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines