Be a Supporter!

AS: Quality Toggling

  • 6,081 Views
  • 30 Replies
New Topic Respond to this Topic
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
AS: Quality Toggling Jul. 1st, 2005 @ 10:32 AM Reply

AS: Main

Changing Quality

Short one, to answer a regular question.

When a swf is loaded inside a browser, the quality is set by the HTML embed tags. By default, it's usually set as HIGH. However, if you're releasing a graphicallly-intensive or code-heavy Flash, you may want to allow users with slower computers to switch to a lower quality, to ease some of the weight on their CPU (it's to your benefit too, since if their processor can't handle your Flash, it won't run smoothly and may well glitch or even crash). A lower quality makes it easier for the viewer's computer to keep the framerate constant, while a high quality focuses on the image instead of the playback.

From the Flash's AS Dictionary:
"LOW" Low rendering quality. Graphics are not anti-aliased, bitmaps are not smoothed.
"MEDIUM" Medium rendering quality. Graphics are anti-aliased using a 2 x 2 grid, in pixels, but bitmaps are not smoothed. Suitable for movies that do not contain text.
"HIGH" High rendering quality. Graphics are anti-aliased using a 4 x 4 grid, in pixels, and bitmaps are smoothed if the movie is static. This is the default rendering quality setting used by Flash.
"BEST" Very high rendering quality. Graphics are anti-aliased using a 4 x 4 grid, in pixels, and bitmaps are always smoothed.

The basic commands for setting swf quality are:

_quality = "LOW";
_quality = "MEDIUM";
_quality = "HIGH";
_quality = "BEST";

You can add any one of these actions to a frame if you wish, but generally you'll be better off including a Q button in your movie/game.
These actions will toggle HIGH>MEDIUM>LOW>HIGH etc (BEST is not generally necessary as an option)

on(press){
if(_quality=="HIGH"){_quality="MEDIUM";}
else if(_quality=="MEDIUM"){_quality="LOW";}
else if(_quality=="LOW"){_quality="HIGH";}
}

An alternative version:

on (release){
if(i++>=2){i=0;}
_quality=["HIGH", "MEDIUM", "LOW"][i];
}

If you just wish to switch between HIGH and LOW quality:

on(press){toggleHighQuality();}

If you just wish to switch between HIGH and MEDIUM quality:

on (press) {_quality=_quality=="HIGH" ? "MEDIUM" : "HIGH";}

Flash also has a command which will automatically detect movie framerate and adjust the quality if the framerate drops.
Personally, I don't like this too much, but it's there as an option. Just bung the action on the first frame of your movie.

_root._quality='autohigh';

======================================================

Since a question was asked about this yesterday, I guess it would do no harm to mention this as well:

In terms of setting movie quality/size as you export your swf, the only real control you have is the ability to adjust image and sound compression. To tweak these, go to FILE>PUBLISH SETTINGS>FLASH tab, and play with the JPEG quality slider and the Audio Stream and Audio Event MP3 settings.


- - Flash - Music - Images - -

BBS Signature
Galactic-Shit-Head
Galactic-Shit-Head
  • Member since: Jun. 30, 2005
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to AS: Quality Toggling Jul. 1st, 2005 @ 10:33 AM Reply

He he, another great AS thread! To bad I already knew this. :-(

Flea-Productions3
Flea-Productions3
  • Member since: Apr. 13, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Quality Toggling Jul. 1st, 2005 @ 10:36 AM Reply

Ah yes, Denvish out with some more AS. Nice one!

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Quality Toggling Jul. 1st, 2005 @ 10:39 AM Reply

Wow!I didn't know someone could type more than two paragraphs about quality!


BBS Signature
Bipin
Bipin
  • Member since: Jan. 15, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Quality Toggling Jul. 4th, 2005 @ 09:08 PM Reply

great tut Denvish, i'd just wanna add that it's sometimes a good idea to just manualy set the quality of your movie on the frames you want when you know it's gonna be ghraphical intense or not intense at all.

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Quality Toggling Jul. 9th, 2005 @ 05:40 AM Reply

Add this to the first frame of your movie to allow the Q key to loop through quality settings:

myListener = new Object();
myListener.onKeyDown = function () {
if(Key.getCode() == 81){
if(i++>=2){i=0;}
_quality=["HIGH", "MEDIUM", "LOW"][i];
}
}
Key.addListener(myListener);


- - Flash - Music - Images - -

BBS Signature
Chris
Chris
  • Member since: Sep. 17, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to AS: Quality Toggling Aug. 28th, 2005 @ 06:38 PM Reply

http://forums.xgenst..?p=380085#post380085

devnish, i think soemone ahs stolen your work

T-H
T-H
  • Member since: Jan. 7, 2004
  • Offline.
Forum Stats
Member
Level 40
Blank Slate
Response to AS: Quality Toggling Aug. 28th, 2005 @ 06:40 PM Reply

Yup, indeed a nice copy/paste job there. Could be Denvish himself of course but I somehow doubt it.

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Quality Toggling Aug. 28th, 2005 @ 06:44 PM Reply

that's just nasty :S

I didn't expect him to do that :(

nasty

Rantzien
Rantzien
  • Member since: Jan. 27, 2005
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to AS: Quality Toggling Aug. 28th, 2005 @ 06:52 PM Reply

At 8/28/05 06:40 PM, T-H wrote: Could be Denvish himself of course but I somehow doubt it.

Nope, it's the same guy as the one on NG with the same name. What a loser, and I helped him with AS once.


BBS Signature
fwe
fwe
  • Member since: Jul. 24, 2003
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Quality Toggling Oct. 20th, 2005 @ 06:33 PM Reply

At 8/29/05 01:46 PM, ChronicLord wrote: For fuck sake.

Sorry Denvish, you can blame my brother for that. He has used my account since ive been on holiday. Ive edited the Xgen post so it does say thanks Denvish.

*I will beat my brother today*.

What a fucking noob liar. Okay..


wtfbbqhax

Mogly
Mogly
  • Member since: Sep. 5, 2004
  • Offline.
Forum Stats
Member
Level 25
Animator
Response to AS: Quality Toggling Oct. 20th, 2005 @ 07:40 PM Reply

denvish this is how amazing you are. you took a simple, copy and paste code and turned it into this!

cheers Denv


WEBSITE
BLOG ~ Dont fuck around with my dog. All that I can see I steal. ~
NG FFR ~ Automatic for the people.

BBS Signature
gorman2001
gorman2001
  • Member since: Aug. 18, 2002
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to AS: Quality Toggling Oct. 20th, 2005 @ 08:49 PM Reply

At 7/1/05 10:32 AM, Denvish wrote: on(press){toggleHighQuality();}

nice and easy code, but Macromedia doesn't recommend it, since it's a deprecated method in Flash MX and later.

but i think we'll say fuck Macromedia :)


website :: hugostonge.com
my job :: we+are

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Quality Toggling Oct. 20th, 2005 @ 08:52 PM Reply

At 10/20/05 08:49 PM, gorman2001 wrote: nice and easy code, but Macromedia doesn't recommend it, since it's a deprecated method in Flash MX and later.

but i think we'll say fuck Macromedia :)

deprecated schmeprecated. int is deprecated, and I use it on virtually a daily basis. tellTarget is deprecated, but according to rumours, Tom Fulp used it in Dad'n'Me. If it works, then I see no reason not to use it.
=D


- - Flash - Music - Images - -

BBS Signature
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Quality Toggling Oct. 20th, 2005 @ 09:00 PM Reply

At 10/20/05 08:52 PM, Denvish wrote: int is deprecated...

exactly HOW depreciated is int, because ive always hated Math.round()...

int is so much shorter. so how exactly is it depreciated?

BBS Signature
Glaiel-Gamer
Glaiel-Gamer
  • Member since: Dec. 28, 2004
  • Offline.
Forum Stats
Member
Level 28
Game Developer
Response to AS: Quality Toggling Oct. 20th, 2005 @ 09:02 PM Reply

BTW if your game is mostly bitmaps, use low quality.

what is depricated anyway

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Quality Toggling Oct. 20th, 2005 @ 09:08 PM Reply

At 10/20/05 09:02 PM, Glaiel_Gamer wrote: what is depricated anyway

http://en.wikipedia.org/wiki/Deprecated
In computer software standards and documentation, deprecation is the gradual phasing-out of a software or programming language feature.

At 10/20/05 09:00 PM, authorblues wrote: exactly HOW depreciated is int, because ive always hated Math.round()...
int is so much shorter. so how exactly is it depreciated?

Dunno. Works for me. I rarely use Math. functions except in trig calculations.

At 10/20/05 09:03 PM, SpamBurger wrote: But arent commands deprecated becuase there is a much easier command? Like, with tellTarget, why use:

Habit


- - Flash - Music - Images - -

BBS Signature
JonBro
JonBro
  • Member since: Jul. 8, 2005
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to AS: Quality Toggling Dec. 2nd, 2005 @ 08:45 PM Reply

Hey, Denvish, what about the actionscript used in the "auto" quality button seen in "Pico's Unloaded" and "littleFoot"? I didn't see anything about that in the first post.

Other than that, great tutorial...just wished it had a LITTLE bit less to do with buttons and just FRAMES.


~

authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Quality Toggling Dec. 2nd, 2005 @ 08:50 PM Reply

At 12/2/05 08:45 PM, JonBro wrote: Hey, Denvish, what about the actionscript used in the "auto" quality button seen in "Pico's Unloaded" and "littleFoot"? I didn't see anything about that in the first post.
Other than that, great tutorial...just wished it had a LITTLE bit less to do with buttons and just FRAMES.

its just a _root._quality = "autohigh"
which CAN be found in denvish's first post:

At 7/1/05 10:32 AM, Denvish wrote: _root._quality='autohigh';

BBS Signature
Snubby
Snubby
  • Member since: Dec. 4, 2004
  • Offline.
Forum Stats
Member
Level 21
Game Developer
Response to AS: Quality Toggling Jul. 17th, 2006 @ 12:47 AM Reply

At 7/1/05 10:32 AM, Denvish wrote: _root._quality='autohigh';

shouldn't that be,

_quality = "autohigh";

You don't need the _root, and you need quotations, not what you put.

cherries
cherries
  • Member since: Jun. 7, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to AS: Quality Toggling Jul. 17th, 2006 @ 01:37 AM Reply

At 7/17/06 12:47 AM, Snubby wrote:
At 7/1/05 10:32 AM, Denvish wrote: _root._quality='autohigh';
shouldn't that be,

_quality = "autohigh";

no, either way works.

suppi
suppi
  • Member since: Jun. 29, 2003
  • Offline.
Forum Stats
Member
Level 07
Audiophile
Response to AS: Quality Toggling Feb. 27th, 2007 @ 04:29 PM Reply

very nice i like i like. i really like the autohigh, but i understand why u dont really like it too much- it seems to take a while to decide.

Gorilla-Studios
Gorilla-Studios
  • Member since: Nov. 18, 2005
  • Offline.
Forum Stats
Member
Level 28
Blank Slate
Response to AS: Quality Toggling Feb. 27th, 2007 @ 05:21 PM Reply

There was no need to post in this topic, leave it alone, the last post was in 2006!

Rest In Peace

Gorilla Studios || A game is like sex, its better when its free

BBS Signature
pivot11
pivot11
  • Member since: Jun. 16, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Quality Toggling Feb. 27th, 2007 @ 06:16 PM Reply

nicely done.... =D


Blok' Party, Orbital Khaos, site, MSMstudios, Phrozen Phlame

BBS Signature
Sinvader
Sinvader
  • Member since: Jul. 17, 2007
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Quality Toggling Aug. 6th, 2007 @ 03:41 PM Reply

God dammit, the q press AS gives me errors and doesn't work.


BBS Signature
loperz619
loperz619
  • Member since: Aug. 13, 2006
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Quality Toggling Oct. 6th, 2007 @ 01:41 AM Reply

information...

i is learning lots :D


PM me if you think im cool
5 people think im cool ;_;

BBS Signature
Mtypenguim
Mtypenguim
  • Member since: Dec. 2, 2007
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to AS: Quality Toggling May. 26th, 2008 @ 10:15 PM Reply

yeah, wut a great AS!


To think what one knows is to know. to know is thinking what one thinks. Wait, what?
Funniest Thread Ever

BBS Signature
nobody404
nobody404
  • Member since: Apr. 27, 2007
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Quality Toggling May. 26th, 2008 @ 10:30 PM Reply

D: You bumped a thread that was decaying for half a year

zrb
zrb
  • Member since: Aug. 8, 2006
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Quality Toggling May. 26th, 2008 @ 10:32 PM Reply

D: You bumped a thread that was decaying for half a year

Honestly! Why is this happening alot lately ?


School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature
Stromming
Stromming
  • Member since: Aug. 30, 2008
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to AS: Quality Toggling Feb. 10th, 2009 @ 04:10 AM Reply

I'm using Flash MX and when I try any of these quality codes (as well as others I've found on the internet) it says that this script is going to slow down computer and therefore it refuses to run it.

Any ideas?