ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Decorating with Deadly Sins and Heavenly Virtues | 161

class window in theDual.flaProperties panel, and resave it asMainDual.as. Now


test the movie.


The output for all of the good and evil together is:


||--Judging--||
Dick's soul
|Courage|Openness|Diligence|Prejudice|Dogmatisms|Arrogance
|Indifference|Rage
Total Virture: -38
Jane's soul
|Hope|Compassion|Justice|Malice|Obsfuscation
Total Virture: 10

Because thetrace( )statement subtracts theevil( )method from thegood( )method


total value, any positive results indicate an abundance of good characteristics, and a


negative result shows a plethora of negative traits.


You can “multi-wrap” using the same decorator more than once on the same con-


crete component. (Someone who thinks he can get the month-behind project done


Example 4-36. MainDual.as


package
{
import flash.display.Sprite;
public class MainDual extends Sprite
{
public function MainDual( )
{
trace("||--Judging--||");
var life:Component=new Dick( );
var light:Component=new Jane( );
//Add Good
life=new Courage(life);
light=new Hope(light);
light=new Compassion(light);
life=new Openness(life);
life=new Diligence(life);
light=new Justice(light);
//
Add Evil
light=new Malice(light);
life=new Prejudice(life);
life=new Dogmatisms(life);
life=new Arrogance(life);
life=new Indifference(life);
life=new Rage(life);
light=new Obsfuscation(light);
trace(life.getSoul( )+"\nTotal Virture: "+
(life.good()-life.evil( )));
trace(light.getSoul( )+"\nTotal Virture: "+
(light.good()-light.evil( )));
}
}
}

Free download pdf