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.

Example 8-19. ChangeHandler.as (continued)<br />

battleUpdate[i].wordWrap=true;<br />

battleUpdate[i].multiline=true;<br />

battleUpdate[i].border=true;<br />

battleUpdate[i].textColor=0xffffee;<br />

scoreFormat=new TextFormat( );<br />

scoreFormat.leftMargin=7;<br />

scoreFormat.rightMargin=7;<br />

getFont (warrior[i].nomDeGuerre);<br />

battleUpdate[i].borderColor=outputColor;<br />

battleUpdate[i].defaultTextFormat=scoreFormat;<br />

battleUpdate[i].text=warrior[i].nomDeGuerre+<br />

":\n"+warrior[i].passOn( );<br />

}<br />

}<br />

//Get the font<br />

private function getFont (creature:String):void<br />

{<br />

switch (creature)<br />

{<br />

case "Earth Fighter" :<br />

outputColor=0xff0000;<br />

scoreFormat.font="Verdana";<br />

break;<br />

case "Android Beam Base" :<br />

outputColor=0x00ff00;<br />

scoreFormat.font="Comic Sans MS";<br />

break;<br />

case "Alien Menace" :<br />

outputColor=0x0000ff;<br />

scoreFormat.font="Arial Black";<br />

break;<br />

}<br />

}<br />

//Get the movie clips from the Library<br />

private function getParts ( ):void<br />

{<br />

//Earthling<br />

earthlingMC=new Earthling( );<br />

addChild (earthlingMC);<br />

earthlingMC.x=60,<br />

earthlingMC.y=120;<br />

missile=new Missile( );<br />

addChild (missile);<br />

missile.x=earthlingMC.x+25;<br />

missile.y=earthlingMC.y+35;<br />

earthlingMC.addEventListener (MouseEvent.CLICK,fireMissile);<br />

earthlingMC.addEventListener<br />

(Event.ENTER_FRAME,earthlingHit);<br />

//Android<br />

Dynamically Changing States | 313

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

Saved successfully!

Ooh no, something went wrong!