Errata

ActionScript 3.0 Design Patterns

Errata for ActionScript 3.0 Design Patterns

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 3
chapter 3 - singleton - (errata submission part 2 - the fix)

Fix for the submission re: Section 3.2.1 - singleton error: PublicClass.as

Line 18, close the brace "}", effectively removing the 'constructor' functionality - but
this code as printed has an error - not enough closing braces. This fixes that.

Anonymous   
Printed Page 8
First paragraph

it says :

"4. Select Insert -> New Symbol from the menu bar to open the Convert to Symbol Dialog
box."

No such thing exsist. Insert -> New Symbol creates a new Symbol.

To convert to symbol : Modify -> Convert to Symbol.

{9 on Safari} chapter 1.9. Favor Composition - 3rd paragraph;
Composition includes a reference to another class in a class definition. Example 1-45
shows how a class is set up to use composition. The line

The correct is: ... "Example 1-43" shows how ...

Anonymous   
Printed Page 10
2nd paragraph

"You can no longer attach a class to a movie clip as was the case in previous versions."

This is not correct. In the example in this section, you could create a class named
FireRocket which would automatically be associated with that movie clip (as long as the
class file was placed in the fla's classpath).

Anonymous   
Printed Page 16
in Example 1-5

the public function "NoEncap" should include a call to the function showDogTalk() or the text doesn't display.

Great book so far!

Brian Speight  Dec 15, 2008 
Printed Page 16
Example 1-5

Disregard my previous submission - I went down a different path from where the book was going. I should have read for another half page :-(
It works as written...

Brian Speight  Dec 15, 2008 
Printed Page 19
figure 1-5. Objects signature

figure 1-5 appears to show a function signature. The caption and surrounding text refer
to objects' signatures. Also, the text above figure 1-5 on page 19, reads: "An object's
signature is it's operation name, parameters, and return data type". I don't think
objects have return data types in this language. It looks to me like the word "object"
was used where "function" would have made sense, a few times on this page.

Anonymous   
Printed Page 38-39
Example 1-33. file Plasma.as in 1.6. Polymorphism chapter

This is not a error at all but any other people can have the same troubles i did.

I got some problems testing the exercise "1.6.2. Implementing Polymorphism with
Interfaces" I have used my own FLV catched on the web file to test the app and i got the
Follow error on the file "Plasma.as".

Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was
unable to invoke callback onMetaData. error=ReferenceError: Error #1069: Property
onMetaData not found on flash.net.NetStream and there is no default value.
at Plasma/productDisplay() at DoBusiness$iinit()

By reference in Adobe documents, AsyncErrorEvent is Dispatched when an exception is
thrown asynchronously, from native asynchronous code. This event is dispatched when a
server calls a method on the client that is not defined.

This happened because my FLV file on test embedded properties inside it and the Plash
Player 9 has dispatched the event onMetaData but that event was not defined on the class
Plasma.as.

To avoid this problem I sugest use one clear FLV or change the code a bit as follow:

private var nc:NetConnection;
private var flvFile:String;

public function productDisplay(flv:String):void
{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS,onStatus); //play when onStatus.info is
filled
nc.connect(null);
}
/*Dispatched when a NetConnection object is reporting its
status or error condition, in this case connection success.*/
private function onStatus(e:NetStatusEvent):void
{
if (e.info.code == "NetConnection.Connect.Success")
{
ns=new NetStream(nc);

/* To implement this event cannot use the addEventListener here
look in Adobe documents to find another valid way extending the class
I have used this way here to be simple on the solution */
var obj:Object = new Object();
obj.onMetaData = onMetaDataEvent;
ns.client = objMeta;

ns.play(flvFile);
vid= new Video();
vid.attachNetStream(ns);
addChild(vid);
}
}
/*Dispatched when Flash Player receives descriptive
information embedded in the FLV file being played.*/
private function onMetaDataEvent(obj:Object):void
{
trace("properties found in FLV");
for (var str:String in obj)
{
trace(str+":"+ obj[str]);
}
}

Another way to solve this is extends the class NetStream and use that on the Plasma.as:

//Plasma.as

private var nc:NetConnection;
private var flvFile:String;

public function productDisplay(flv:String):void
{
flvFile = flv;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS,onStatus);
nc.connect(null);
}
/*Dispatched when a NetConnection object is reporting its
status or error condition, in this case connection success.*/
private function onStatus(e:NetStatusEvent):void
{
if (e.info.code == "NetConnection.Connect.Success")
{
ns=new NetStreamCustom(nc); //using our subclass 'NetStreamCustom'

ns.play(flvFile);
vid= new Video();
vid.attachNetStream(ns);
addChild(vid);
}
}

Later write a subclass to extend the NetStream class:

//NetStreamCustom.as

package
{
import flash.net.NetStream;
import flash.net.NetConnection;

public class NetStreamCustom extends NetStream
{
public function NetStreamCustom(nc:NetConnection):void
{
super(nc);
}
/*Dispatched when Flash Player receives descriptive
information embedded in the FLV file being played.*/
public function onMetaData(obj:Object):void
{
trace("properties found in FLV");
for (var str:String in obj)
{
trace(str+":"+ obj[str]);
}
}
}
}

Anonymous   
Printed Page 60
2nd paragraph

"(or the client for that manner)" should most likely be changed to read "(or the client
for that matter)"

Anonymous   
Printed Page 67
bottom

The code example shows incorrect capitalisation, suggesting that FactoryMethod is a
class.

The code example should look like:
operation()
{
..
product = factoryMethod();
..
}

Anonymous   
Printed Page 72
First paragraph under "Clients" heading

"The document class Main is the client ... In Example 2-7, the document class calls a
static method called run() in the static Test class to run some tests."

No static method is called from within the example.
No Test class exists in the example.

I assume a second class called Test is meant to be shown in the Main.as file, in example
2-7?

Anonymous   
Printed Page 73
First paragraph under "Hiding the Product Classes" heading

"Add the following statements to the Test class"

No Test class exists in the example.

Anonymous   
Printed Page 75
Figure 2-6

the box named LowVolPrintCenter shows a method
named factoryMethod() but in the text on following pages the class
LowVolPrintCenter defines createPrintjob() method instead.

Anonymous  Sep 11, 2009 
Printed Page 79
Example 2-15

This example is both a member of the printcenters package and also imports the printcenters package. It seems the import is unnecessary.

Dave Kanter  Feb 21, 2011 
Printed Page 80
Example 2-16

The trace statement should read, "to color inkjet printer", not "to color LASER
printer" (emphasis mine) as it does currently.

Anonymous   
Printed Page 83
Figure 2-7

In the diagram there's a duplicate of the classes InkjetPrintJob and ColorInkjetPrintJob
where WorkgroupPrintJob and ColorLaserPrintJob should be.

Anonymous   
Printed Page 83
Figure 2-7

The two classes listed in the box at lower left of figure 2-7 are InkjetPrintjob and ColorInkjetPrintjob. It seems to me that these should be WorkgroupPrintjob and ColorLaserPrintjob, as mentioned in the text just above this diagram.

Dave Kanter  Feb 21, 2011 
Printed Page 83
Figure 2-7

The class in the upper left corner of this diagram is labeled "Printjob" when it should be labeled "PrintCenter."

Dave Kanter  Feb 23, 2011 
Printed Page 85
3rd paragraph, bottom of page

Under the heading Product Classes: Shape Widgets it reads "Unlike in previous examples,
we define ShapeWidget as an abstract interface" it should read "... we define
ShapeWidget as an abstract class".

Anonymous   
Printed Page 104

The entire singleton pattern section, starting with Example 3-2. PublicClass.as, shows
code outside the package - but if you follow this code - and compile, you will get:

Error: 1114: The public attribute can only be used inside a package.

Anonymous   
Printed Page 105
Example 3-3. Using a private class in a public class constructor

Missing if() statement inside getInstance().

Should have been:
public static function getInstance():PublicClass
{
if(PublicClass.instance == null)
{
PublicClass.instance=new PublicClass (new PrivateClass());
}
return PublicClass.instance;
}

instead of:
public static function getInstance():PublicClass
{
PublicClass.instance=new PublicClass (new PrivateClass());
}
return PublicClass.instance;
}

Note from the Author or Editor:
Example 3-3 is only showing how to generate a "private class" in ActionScript 3.0. Example 3-4 shows how this can be done with a Singleton and does require a conditional statement which it provides.

Thanks for taking the time to help out, though.
Bill Sanders

Anonymous  Feb 18, 2010 
Printed Page 111
Example 3.9

The Singleton example doesn't work! I was able to create a new instance of the class:

try this:

package
{
public class Singleton
{
private var _msg:String;
private static var _instance:Singleton;

public function Singleton(pvt:PrivateClass)
{
}

public static function getInstance():Singleton
{
if(Singleton._instance == null)
{
Singleton._instance = new Singleton(new PrivateClass());
trace('Singleton instantiated');
}
return Singleton._instance;
}

//Get and set methods
public function getMsg():String
{
return _msg;
}
public function setMsg(alert:String):void
{
_msg = alert;
}

}
}
class PrivateClass{

public function PrivateClass()
{
trace('Private class called');
}
}

/* ******/

var firstSingleton:Singleton = Singleton.getInstance();
firstSingleton.setMsg('Singleton instance: firstSingleton');
var secondSingleton:Singleton = Singleton.getInstance();
secondSingleton.setMsg('Singleton instance: secondSingleton');
var thirdSingleton:Singleton = new Singleton(null);
thirdSingleton.setMsg('Singleton instance: thirdSingleton');

trace(firstSingleton.getMsg());
trace(secondSingleton.getMsg());
trace(thirdSingleton.getMsg());
trace(secondSingleton.getMsg());

and you get this results:

Private class called
Singleton instantiated
Singleton instance: secondSingleton
Singleton instance: secondSingleton
Singleton instance: thirdSingleton
Singleton instance: secondSingleton

The last two results prove that the class is not a Singleton

slimbuddah  May 15, 2009 
PDF Page 114-115
Last sentence on p 114 and Italic text at top of p 115

The class in Example 3-11 is referred to as AlertText.as but it should be AlertTest.as. The class name inside the example is AlertTest, and the sample code for the book is also named AlertTest.as

Kevo Thomson  Jul 29, 2009 
Printed Page 114
Last line of last paragraph.

Should be:
file AlertTest.as and save it in the same folder as Alert.as.

Instead of:
file AlertText.as and save it in the same folder as Alert.as.

Anonymous  Feb 22, 2010 
Printed Page 115
Top of the page

Should be:
Example 3-11. AlertTest.as

Instead of:
Example 3-11. AlertText.as

Anonymous  Feb 22, 2010 
Printed Page 115
Last paragraph

This paragraph, the example, and the 1st paragraph of page 116 suggests that import statements using a wild card actually import unnecessary classes into the compiled application. This is not the case.

creacog  Jul 06, 2010 
Printed Page 118
script Tuner.as getInstance method

code says:
Tuner._instance = new Tuner(new PrivateClass );
should read:
Tuner._instance = new Tuner(new PrivateClass());

Anonymous   
Printed Page 168
Example 4-44

The name of the class is given as "HeatedSeat.as", when it should be plural
"HeatedSeats.as" as shown by the name of the class two lines down: public class
HeatedSeats....

Anonymous   
Printed Page 198
1st paragraph, 4th line

Should have been:
allows the method to access the superclass property, text, directly.

Instead of:
allows the method to access the superclass property, listText, directly.

Anonymous  Feb 27, 2010 
Printed Page 213
top

var leaf5:Component = root.getChild(3);
var leaf5Parent:composite = l5.getParent();

Doesn't work

var leaf5:Component = root.getChild(2).getChild(3);
var leaf5Parent:Composite = leaf5.getParent();
leaf5Parent.operation(); //call Operation on parent

Works, please include call code.

Keno  Jan 21, 2010 
Printed Page 227
Bottom of code - function onKeyPress()

The completed program will not work - the head of the rattlesnake is not connected to
its body. After the BodySegments have been created and the Main class has been revised,
the authors neglected to state that one must return to the onKeyPress() function
(previously written out for the first draft of the Main class) and add the following:

snake.update();

after the swtich conditional. I would think line 54 would be a good place for it.

Anonymous   
Printed Page 253
Bottom on the page (3/4 down) in line 14 of the code example

Code currently reads:

invoker.setCommand(conCommand)
conCommand.execute() //execute command

I believe the code should be:

invoker.setCommand(conCommand)
invoker.executeCommand() // execute command

Anonymous   
Printed Page 263 ? 278
Pages 263 ? 278

I have recently purchased 3 copies of "ActionScript 3.0 Design Patterns and
to my shock I was disappointed to see so many errors with the book:



- Pages 263 ? 278 have bits and pieces chopped/repeated at the end and at
the start of the page, the content doesn't flow from one page to another.
- In the MVC Pattern chapter, on page 440 the code was not complete:



Public function RootNodeView (aModel:IModel,



There are a few more instances of these in this chapter.



Hopefully in the next release these errors will be fixed, design patterns
are already quite hard to learn, not to mention missing code and contents.

Regards,
--
Andrew Lay

Anonymous  Aug 27, 2008 
Printed Page 263-277
Content from page 263 to 277 is either missing or duplicated

This was already reported. But do to the seriousness and magnitude of the problem, I am compelled to submit an additional advisory:
Content from page 263 to 277 is either missing or duplicated.

Mr. Sanders and Mr. Cumaranatunge have done such a magnificent job in writing this book. It's unfortunate for the printout to turn out this way.

Anonymous  Mar 15, 2010 
Printed Page 264
Example 7-19

A large portion of the example code is clearly missing including the constructor method and the whole setCommand method. A similar error occurs in example 7-20. It's as if the printing somehow got shifted. The problem seems to be in relation to type carrying over from one page to the next.

here is how my examle 7-19 reads

Page 264----------------------------------
package
{
import flash.events.*;
import flash.display.Stage;

class InvokerKeyboard
{
var commandList:Array;
var keyList:Array;
-----------------------------------------

Page 265----------------------------------
{
this.keyList.push(keycode);
this.commandList.push(c);
}

private function onKeyPress(event:KeyboardEvent)
{
for(var i:int = 0; i < keyList.length; i++)
{
if(keyList[i] === event.keyCode)
{
this.commandList[i].execute();
break;
}
}
}
}
}





Anonymous  Nov 10, 2008 
Printed Page 322
Bottom of page - last three calculations

The equation is supposed to display the division sign, but instead shows the ascii
equivalent &#247;

Anonymous   
Printed Page 402
Heading--lower/middle of page

Currently reads "Minimalist Abstract State Pattern"

Should read "Minimalist Abstract Strategy Pattern"

Anonymous   
Printed Page 411
example11-7 clown.as

Unless I am missing a point in the composition idea, I think there is a typo in the last
function (bolded) "setSkit" which should set the skit property. I'd imagine one would
want to use the skit type for the typing of the passed parameter addskit /* instead of
(addskit:Tricks)*/ as well as setting the skit property to the addskit parameter instead
of setting the trick property /* tricks = addSkit; */. While I believe this code would
compile, calling setSkit and passing an instance of Skit would could throw an error, or
simply set the trick for that clown instead of the skit. /* the setSkit method is not
called in example 11-20, pg.413 */

Anonymous   
Printed Page 435
Example 12-5 line 20

target.addEventListener(KeyboardEvent.KEY_DOWN,

The last parameter and closing parentheses are missing.

Anonymous   
Printed Page 435
code block

I may be wrong, but it seems that the second call to addEventListener in the public function of the View.as class file is missing its 2nd argument.

It reads: target.addEventListener(KeyboardEvent.KEY_DOWN,

where it should read: target.addEventListener(KeyboardEvent.KEY_DOWN, someFunction);

Jonathan Feagle  Mar 17, 2010 
Printed Page 437
Example 12-7. ComponentView.as

Line 8 of ComponentView.as: There is an extra left curly bracket after "public class ComponentView extends Sprite". It should be removed.

Anonymous   
PDF Page 437
ComponentView.as

in the constructor of ComponentView, why the type of model and controller are "Object"? I think it should be IModel and IKeyboardInputHandler.

Anonymous  Aug 22, 2014 
Printed Page 439
In Figure 12-2

Figure 12-2 has two "view" classes in the diagram below the "RootNodeView" class. The
second class is labeled "ACIICharLeafView". This should be "ASCIICharLeafView".

Anonymous   
Printed Page 440
Example 12-9

In the constructor there are two parameters missing: aController:IKeyboardInputHandler,
target:Stage) and on line 14 there's the second parameter missing for the
target.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPress)

Anonymous   
Printed Page 440
Example 12-9

the constructor for RootNodeView is missing other arguments and closing parenthesis.

Anonymous  Aug 08, 2009 
Printed Page 463
Missing code after line 22 in the example

The complete code for the 12-28 Man.as example should be:

package {

import flash.display.*;
import flash.events.*;
import flash.geom.*;

/**
* Main Class
* @ purpose: Document class for movie
*/
public class Main extends Sprite {

public function Main() {

var carModel:ICar = new CarModel();
carModel.setLoc(new Point(200,200));
carModel.setColor(0x0000FF); // blue

var carController:IKeyboardInputHandler = new RHController(carModel);

// keyboard input view (composite)
var kbInputView:CompositeView = new KeyboardInputView(carModel, carController, this.stage);

// direction gaugue view (component)
var dash:ComponentView = new DirectionGaugeView(carModel);
kbInputView.add(dash); // add car view to keyboard input view as child component
dash.x = dash.y = 20;
addChild(dash);

// GPS view (component)
var gps:ComponentView = new GPSView(carModel, this.stage);
kbInputView.add(gps); // add gps view to keyboard input view as child component
gps.x = 10;
gps.y = 75;
addChild(gps);

// car view (component)
var car:ComponentView = new CarView(carModel);
kbInputView.add(car); // add car view to keyboard input view as child component
addChild(car);

// register keyboard input view to recieve notifications from the car model
carModel.addEventListener(Event.CHANGE, kbInputView.update);

}
}
}

Chandima Cumaranatunge
Chandima Cumaranatunge
 
Apr 26, 2009