Chapter 6 fixes (CS4 textbook)

If you’re trying to do the final exercise in Chapter 6 of the CS4 textbook, where you make a scrollable text box using ActionScript, there are some adjustments required on the sample file and on the code so that your exercise will work. (Thanks to Valeriya for bringing this to my attention!)

In the sample file “ScrollingAS.fla”, change the instance names of the button graphics on the stage – click on the ‘up’ button and look in the property inspector, it will show an instance name “scrollUp” – change that to “btnScrollUp”. Click on the ‘down’ button and change its instance name from “scrollDown” to “btnScrollDown”. Watch your capitalization please.

Then, for the code… the code given in the textbook doesn’t work properly. Rather than using the code they give you, use the following:

btnScrollUp.addEventListener (MouseEvent.MOUSE_UP, scrollUp);
function scrollUp(evt:Object):void {
	output.scrollV--;
 	updateButtons();
	}

btnScrollDown.addEventListener (MouseEvent.MOUSE_UP, scrollDown);
function scrollDown(evt:Object):void {
	output.scrollV++;
 	updateButtons();
	}

function updateButtons():void {
	if (output.scrollV == 1) {
	btnScrollUp.alpha = 0.5;
	btnScrollUp.enabled = false;
	} else {
		btnScrollUp.alpha = 1;
		btnScrollUp.enabled = true;
		}

if (output.scrollV == output.maxScrollV) {
	btnScrollDown.alpha = 0.5;
	btnScrollDown.enabled = false;
	} else {
		btnScrollDown.alpha = 1;
		btnScrollDown.enabled = true;
		}
	}

updateButtons();

One thought on “Chapter 6 fixes (CS4 textbook)

  1. Pingback: Art 3059, Designing with Computer Animation » Chapter exercises, due March 20

Leave a Reply