Changing Quality with Actionscript


Those of you who aren't lucky enough to own super-fast computers have certainly not once experienced a computer slow-down while watching a flash movie. When a movie is full of objects and the framerate has been set too high, flash automatically decreases the framerate, which makes the movie less attractive. In such cases, you can right-click on the movie (SWF) and lower its quality in the drop-down menu that will appear.


[ right-click for a drop-down like the one above to appear ]



But what if someone doesn't know how to change quality in the above described way? He's certainly not going to have a good time watching your movie, is he?

Fortunately, there is a nice way to let people set the quality in a more "human" way, for example at the beginning of a Flash movie:

 

 


[ notice how everything changes when you roll over the quality buttons ]

 

 

Here's how you can do this

i. Create a new Flash document.

ii. Set both its width and heigh to 300px.

iii. Draw or put something on the stage — for example, a picture of a landscape.

vi. Draw a circle and press F8 to convert it to a symbol. Make it a button. You can call whatever you like.

[ remember to select Button in Behavior (in Flash 8 it has been changed to Type) ]

 



v. When you're done with it, press once on the button to select it, and then press F9. The ActionScript window will appear before your eyes in which you should copy and paste the following code:

on(rollOver){
_quality = "low"
}

 

[ you can omit "this." ]




Alright, we've got a button that, if rolled over, sets the quality of the movie to "low". The image looks quite bad in this quality, doesn't it? Well, but an animation, if there was one, would be very smooth anyway, even on a ancient computer!


Now it's time to make the medium and high quality buttons:


i. Select the button by clicking once on it and copy it. To do this, you can either:

a) click once on it and, with Alt key hold, drag it somewhere to the left or right - wherever

or

b) click once on it, press Ctrl + C and then press Ctrl + V or Ctrl + V + Shift. The option with Shift will paste your button exactly where it was copied. Very useful, by the way, because you don't loose time looking for things.

ii. Place your copied object to the right of the first button. Then, click once on it and press F9. The only change that you have to do with the code is swapping "low" with "medium" (remember that they have to be in quotation marks!).



iii. Now, copy any of the two buttons and place it even further to the right. Open you ActionScript and change "medium" to "high".

Well, this is it - we're done. If you've never dealt with ActionScript, you will probably not understand the code. Read below then.


Explanation

on(rollOver){


We say what will cause the actions that are between {} marks. In this example, it is the rolling over an object that causes it.

 

 

_quality = "low"


We tell the movie to change its quality to "low".


All in all, I think it is a good idea to place such a "quality changer" if your flash movie is full of heavy scenes. Bear in mind that not everyone might have as good computer as you do! Also, remember that your "quality changer" doesn't have to look as bad as mine. I'm sure you can create a way better one, with some cool buttons and all.

I hope this tutorial has helped at least a bit.

I invite you to have a look at other great tutorials.

Cheers!

 

Average: 4.4 (58 votes)