Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > BOOK: Beginning ActionScript 2.0
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ActionScript 2.0
This is the forum to discuss the Wrox book Beginning ActionScript 2.0 by Nathan Derksen, Jeff Berg; ISBN: 9780764577680
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ActionScript 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 12th, 2007, 03:05 AM
Registered User
Join Date: Jan 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch4. Ex 3. Follow your own instructions, hello

The task for Ch.4, ex.3, says to "Modify the convertToButton() function so that it also works with rollover and rollout events." This would mean that new AS should:
a) call the 'testButton' function
b) call a function like 'buttonClickHandler' that would trace the cursor event, ie., rollOver and rollOut, in this case.

Your solution to your own question leaves out the second part altogether. You DID however add a releaseOutside function that was nice touch.

So the correct solution to the original task would be (colors to your liking):

function drawRectangle(targetMC:MovieClip, rectWidth:Number, rectHeight:Number, bgColor:Number):Void {
    targetMC.moveTo(0, 0);
    targetMC.lineStyle(1, 0x000000);
    targetMC.beginFill(bgColor, 100);
    targetMC.lineTo(rectWidth, 0);
    targetMC.lineTo(rectWidth, rectHeight);
    targetMC.lineTo(0, rectHeight);
    targetMC.lineTo(0, 0);
function rollOutHandler():Void {
    trace("Button rolled over");
function buttonClickHandler():Void {
    trace("Button Pressed");
function convertToButton(targetMC:MovieClip, callbackFunction:Function, rollOutFunction):Void {
    drawRectangle(targetMC, 100, 30, 0x333333);
    targetMC.onRollOver = function() {
        drawRectangle(this, 100, 30, 0x225511);
    targetMC.onPress = function() {
        drawRectangle(this, 100, 30, 0x3333CC);
    targetMC.onRelease = function() {
        drawRectangle(this, 100, 30, 0x333399);
    targetMC.onReleaseOutside = function() {
        drawRectangle(this, 100, 30, 0x333399);
    targetMC.onRollOut = function() {
        drawRectangle(this, 100, 30, 0x228866);
this.createEmptyMovieClip("testButton", 1);
convertToButton(testButton, buttonClickHandler, rollOutHandler);

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 Unable to follow instructions GarethHowell BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 4 July 9th, 2008 03:49 AM
Ch4 Problem daivos03 JSP Basics 9 January 30th, 2006 01:57 AM
Problems in Ch3 and Ch4 Maram BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 August 4th, 2005 09:28 AM

All times are GMT -4. The time now is 12:00 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.