10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

class window in the Dual.fla Properties panel, and resave it as MainDual.as. Now<br />

test the movie.<br />

Example 4-36. MainDual.as<br />

package<br />

{<br />

import flash.display.Sprite;<br />

public class MainDual extends Sprite<br />

{<br />

public function MainDual( )<br />

{<br />

trace("||--Judging--||");<br />

var life:Component=new Dick( );<br />

var light:Component=new Jane( );<br />

//***Add Good<br />

life=new Courage(life);<br />

light=new Hope(light);<br />

light=new Compassion(light);<br />

life=new Openness(life);<br />

life=new Diligence(life);<br />

light=new Justice(light);<br />

//***Add Evil<br />

light=new Malice(light);<br />

life=new Prejudice(life);<br />

life=new Dogmatisms(life);<br />

life=new Arrogance(life);<br />

life=new Indifference(life);<br />

life=new Rage(life);<br />

light=new Obsfuscation(light);<br />

trace(life.getSoul( )+"\nTotal Virture: "+<br />

(life.good()-life.evil( )));<br />

trace(light.getSoul( )+"\nTotal Virture: "+<br />

(light.good()-light.evil( )));<br />

}<br />

}<br />

}<br />

The output for all of the good and evil together is:<br />

||--Judging--||<br />

Dick's soul<br />

|Courage|Openness|Diligence|Prejudice|Dogmatisms|Arrogance<br />

|Indifference|Rage<br />

Total Virture: -38<br />

Jane's soul<br />

|Hope|Compassion|Justice|Malice|Obsfuscation<br />

Total Virture: 10<br />

Because the trace( ) statement subtracts the evil( ) method from the good( ) method<br />

total value, any positive results indicate an abundance of good characteristics, and a<br />

negative result shows a plethora of negative traits.<br />

You can “multi-wrap” using the same decorator more than once on the same concrete<br />

<strong>com</strong>ponent. (Someone who thinks he can get the month-behind project done<br />

Decorating with Deadly Sins and Heavenly Virtues | 161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!