Forum Topic: AS3: Quality

(2,169 views • 12 replies)

This topic is 1 page long.

<< < > >>
None

LesPaulPlayer

Reply To Post Reply & Quote

Posted at: 5/6/07 03:26 PM

LesPaulPlayer DARK LEVEL 12

Sign-Up: 05/18/06

Posts: 673

Ah Ese Tres: Main

// In this tutorial, I am going to explain how to toggle quality using AS3
// Its very simple. What you need to do is access a property of stage. and set it
// to be equal to a property of StageQuality
stage.quality = StageQuality.HIGH
stage.quality = StageQuality.MEDIUM
stage.quality = StageQuality.LOW
// alternatively
stage.quality = "high"
stage.quality = "medium"
stage.quality = "low"
// easy, yes, and fairly obvious is you understand the difference between AS2 and
// AS3.


None

hashbrown

Reply To Post Reply & Quote

Posted at: 5/9/07 12:19 AM

hashbrown LIGHT LEVEL 16

Sign-Up: 07/07/05

Posts: 3,080

sorry to bump, but can you tell us about automatically changing the quality due to the fps and laggnes, that would be much more helpful

FREE MMO RPG! PLAY NOW!
"The Elven Prophecy" is the copyright and trademark of Runewaker Entertainment

BBS Signature

None

Madferit

Reply To Post Reply & Quote

Posted at: 5/20/07 08:35 PM

Madferit FAB LEVEL 10

Sign-Up: 07/29/05

Posts: 3,332

I haven't tried this but if you do an if statement to check if the stage.frameRate is low, then set the quality.


None

reality-monkey

Reply To Post Reply & Quote

Posted at: 5/20/07 10:08 PM

reality-monkey EVIL LEVEL 12

Sign-Up: 01/19/06

Posts: 2,132

and is there a way to set frames to change quality on there own?


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 5/21/07 02:03 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,385

On their own what? Add code to change the quality in the frames.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

Kuoke

Reply To Post Reply & Quote

Posted at: 5/21/07 04:18 AM

Kuoke DARK LEVEL 23

Sign-Up: 05/25/06

Posts: 2,508

I think he means the AS3 equivilant of the AS2:
_quality = "autohigh"

BBS Signature

None

AAF

Reply To Post Reply & Quote

Posted at: 2/8/08 05:55 PM

AAF NEUTRAL LEVEL 09

Sign-Up: 06/14/06

Posts: 538

and do u need to add buttons or something? or do u just put this on a frame

.


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 2/9/08 04:38 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,385

This merely explains the usage of the property, you need to implement it on your own. Can you please make the effort of doing as much yourself?

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

Paranoia

Reply To Post Reply & Quote

Posted at: 2/9/08 06:28 AM

Paranoia DARK LEVEL 34

Sign-Up: 04/22/05

Posts: 9,697

I take it this was posted before code tags :P

Anyway, I'll just elaborate since this isn't enough of an addition to warrant its own tutorial. If you want that old favourite of a quality toggle button, here's one way of doing it:

var qual:uint = 2;

// add your own event listener for the toggle event
// for a specific key press, you'll need to add a line or two of code in the function to find the key
// e.g. if(ev.keyCode == blah){

function toggleEvent(ev:* = null):void{
  qual = (qual + 1) % 3;
  if(qual == 0){
    stage.quality = StageQuality.LOW;
  }
  else if(qual == 1){
    stage.quality = StageQuality.MEDIUM;
  }
  else{
    stage.quality = StageQuality.HIGH;
  };
  //  you can use case, switch and break for this if you prefer.  I'm not clear on which is faster,
  //  but for an occasionally called event like this the difference will be negligible anyway
};
BBS Signature

None

coolroy

Reply To Post Reply & Quote

Posted at: 2/9/08 06:45 AM

coolroy LIGHT LEVEL 07

Sign-Up: 11/19/04

Posts: 131

At 5/9/07 12:19 AM, hashbrown wrote: sorry to bump, but can you tell us about automatically changing the quality due to the fps and laggnes, that would be much more helpful

I tried it too, to auto toggle quailty due to lag but each time it auto toggles takes about a sec or two and it's not worth it compared to the lag, it looks even more laggy when it toggles each sec (from experience, just let the people toggle for themselves, I can give you the code if you'd like but I don't recommend...).


None

freechips1

Reply To Post Reply & Quote

Posted at: 2/9/08 05:02 PM

freechips1 LIGHT LEVEL 07

Sign-Up: 10/28/05

Posts: 366

Would this work to auto toggle the quality?

stage.quality = StageQuality.MEDIUM;

var sfr:Number = stage.frameRate;
var buffer:Number = 5;

stage.addEventListener(Event.ENTER_FRAME,quality);

function quality(event:Event):void {
	if (stage.frameRate <= sfr - buffer) {
		stage.quality = StageQuality.LOW;
	}
        if ((stage.frameRate > sfr - buffer) && (stage.frameRate < sfr + buffer)) {
		stage.quality = StageQuality.MEDIUM;
	}
	if (stage.frameRate >= sfr + buffer) {
		stage.quality = StageQuality.HIGH;
	}
	if (stage.frameRate >= sfr + buffer * 1.5) {
		stage.quality = StageQuality.BEST;
	}
}

Seems kind of long-winded though...

Graagh? || Ich habe ein gros Hosenschlange

BBS Signature

None

D4rkm3ch

Reply To Post Reply & Quote

Posted at: 10/14/09 01:52 PM

D4rkm3ch LIGHT LEVEL 02

Sign-Up: 03/04/09

Posts: 1

//Default quality is Best and for this file its frame rate is 24. You can chose any numbers you want below
//When framerate is less than or equal to 14 make quality LOW
//When framerate is in between 15 and 19 INCLUDING 15 and 19 make quality MEDIUM
//When framerate is in between 20 and 23 INCLUDING 20 and 23 make quality HIGH
//If the framerate isn't under the above criteria (max frame rate) make quality BEST

var sfr:Number=stage.frameRate;

stage.quality=StageQuality.BEST;

stage.addEventListener(Event.ENTER_FRAME , quality);
function quality(event:Event):void {
trace(stage.quality);
if (stage.frameRate<=sfr-10) {
stage.quality=StageQuality.LOW;
} else if ((stage.frameRate>=sfr-9)&&(stage.frameR ate<=sfr-5)) {
stage.quality=StageQuality.MEDIUM;
} else if ((stage.frameRate>=sfr-4)&&(stage.frameR ate<=sfr-1)) {
stage.quality=StageQuality.HIGH;
} else {
stage.quality=StageQuality.BEST;
}
}

Voltaire - I do not agree with what you have to say, but I'll defend to the death your right to say it.


None

henke37

Reply To Post Reply & Quote

Posted at: 10/15/09 01:29 AM

henke37 NEUTRAL LEVEL 23

Sign-Up: 09/10/04

Posts: 3,607

stage.frameRate is not changed by the player. It is the set goal framerate. Unless you assign to it, it's a constant. So yeah, nice work guys. Nice work indeed.

Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.


All times are Eastern Standard Time (GMT -5) | Current Time: 08:21 AM

<< Back

This topic is 1 page long.

<< < > >>
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!