Forum Topic: AS: Quality Toggling

(4,812 views • 32 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
None

Denvish

Reply To Post Reply & Quote

Posted at: 7/1/05 10:32 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

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

None

Galactic-Shit-Head

Reply To Post Reply & Quote

Posted at: 7/1/05 10:33 AM

Galactic-Shit-Head NEUTRAL LEVEL 03

Sign-Up: 06/30/05

Posts: 201

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


None

Flea-Productions3

Reply To Post Reply & Quote

Posted at: 7/1/05 10:36 AM

Flea-Productions3 EVIL LEVEL 08

Sign-Up: 04/13/05

Posts: 860

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


None

Toast

Reply To Post Reply & Quote

Posted at: 7/1/05 10:39 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,914

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


None

Bipin

Reply To Post Reply & Quote

Posted at: 7/4/05 09:08 PM

Bipin NEUTRAL LEVEL 07

Sign-Up: 01/15/05

Posts: 974

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.


None

Denvish

Reply To Post Reply & Quote

Posted at: 7/9/05 05:40 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

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

None

Chris

Reply To Post Reply & Quote

Posted at: 8/28/05 06:38 PM

Chris LIGHT LEVEL 18

Sign-Up: 09/17/04

Posts: 301

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

devnish, i think soemone ahs stolen your work


None

T-H

Reply To Post Reply & Quote

Posted at: 8/28/05 06:40 PM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

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


None

Inglor

Reply To Post Reply & Quote

Posted at: 8/28/05 06:44 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

that's just nasty :S

I didn't expect him to do that :(

nasty


None

Rantzien

Reply To Post Reply & Quote

Posted at: 8/28/05 06:52 PM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,426

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

None

ApeLord

Reply To Post Reply & Quote

Posted at: 8/29/05 01:46 PM

ApeLord EVIL LEVEL 15

Sign-Up: 12/24/04

Posts: 1,559

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*.


None

fwe

Reply To Post Reply & Quote

Posted at: 10/20/05 06:33 PM

fwe DARK LEVEL 08

Sign-Up: 07/24/03

Posts: 3,361

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


None

Mogly

Reply To Post Reply & Quote

Posted at: 10/20/05 07:40 PM

Mogly LIGHT LEVEL 25

Sign-Up: 09/05/04

Posts: 10,336

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

cheers Denv

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

BBS Signature

None

gorman2001

Reply To Post Reply & Quote

Posted at: 10/20/05 08:49 PM

gorman2001 NEUTRAL LEVEL 14

Sign-Up: 08/18/02

Posts: 1,935

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 :)


None

Denvish

Reply To Post Reply & Quote

Posted at: 10/20/05 08:52 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

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

None

authorblues

Reply To Post Reply & Quote

Posted at: 10/20/05 09:00 PM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

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?

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 10/20/05 09:02 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,038

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

what is depricated anyway


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 10/20/05 09:03 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 10/20/05 08:52 PM, Denvish wrote: 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

But arent commands deprecated becuase there is a much easier command? Like, with tellTarget, why use:

tellTarget(_root.guy){
_x++;
}

When you could just use:

_root.guy._x++;

Theres a reason for deprecated commands.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Denvish

Reply To Post Reply & Quote

Posted at: 10/20/05 09:08 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

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

None

JonBro

Reply To Post Reply & Quote

Posted at: 12/2/05 08:45 PM

JonBro NEUTRAL LEVEL 14

Sign-Up: 07/08/05

Posts: 563

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.


None

authorblues

Reply To Post Reply & Quote

Posted at: 12/2/05 08:50 PM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

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';

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

Snubby

Reply To Post Reply & Quote

Posted at: 7/17/06 12:47 AM

Snubby EVIL LEVEL 20

Sign-Up: 12/04/04

Posts: 3,146

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.


None

cherries

Reply To Post Reply & Quote

Posted at: 7/17/06 01:37 AM

cherries LIGHT LEVEL 18

Sign-Up: 06/07/05

Posts: 4,576

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.


None

suppi

Reply To Post Reply & Quote

Posted at: 2/27/07 04:29 PM

suppi LIGHT LEVEL 07

Sign-Up: 06/29/03

Posts: 119

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.


Angry

Gorilla-Studios

Reply To Post Reply & Quote

Posted at: 2/27/07 05:21 PM

Gorilla-Studios FAB LEVEL 26

Sign-Up: 11/18/05

Posts: 1,697

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

None

pivot11

Reply To Post Reply & Quote

Posted at: 2/27/07 06:16 PM

pivot11 FAB LEVEL 07

Sign-Up: 06/16/06

Posts: 1,124

nicely done.... =D

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

BBS Signature

None

Sinvader

Reply To Post Reply & Quote

Posted at: 8/6/07 03:41 PM

Sinvader EVIL LEVEL 06

Sign-Up: 07/17/07

Posts: 124

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

BBS Signature

Elated

loperz619

Reply To Post Reply & Quote

Posted at: 10/6/07 01:41 AM

loperz619 NEUTRAL LEVEL 11

Sign-Up: 08/13/06

Posts: 401

information...

i is learning lots :D

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

BBS Signature

None

Mtypenguim

Reply To Post Reply & Quote

Posted at: 5/26/08 10:15 PM

Mtypenguim LIGHT LEVEL 14

Sign-Up: 12/02/07

Posts: 759

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

None

nobody404

Reply To Post Reply & Quote

Posted at: 5/26/08 10:30 PM

nobody404 NEUTRAL LEVEL 11

Sign-Up: 04/27/07

Posts: 279

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


All times are Eastern Standard Time (GMT -5) | Current Time: 08:19 PM

<< Back

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!