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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

implementation. (In Example 1-20 you can see how an interface structure is programmed<br />

to the interface instead of an implementation.)<br />

Example 1-36. DoBusiness.as<br />

package<br />

{<br />

import flash.display.Sprite;<br />

}<br />

public class DoBusiness extends Sprite<br />

{<br />

public function DoBusiness( )<br />

{<br />

//TV<br />

var tv:Plasma=new Plasma( );<br />

trace(tv.productDescribe( ));<br />

trace(tv.productPrice(855));<br />

tv.productDisplay("plasma.flv");<br />

tv.x=160;<br />

tv.y=110;<br />

addChild(tv);<br />

}<br />

}<br />

//MP3<br />

var mp3:MP3Player=new MP3Player( );<br />

trace(mp3.productDescribe( ));<br />

trace(mp3.productPrice(245));<br />

mp3.productDisplay("bongo.mp3");<br />

//Computers<br />

var <strong>com</strong>puters:Computers=new Computers( );<br />

trace(<strong>com</strong>puters.productDescribe( ));<br />

trace(<strong>com</strong>puters.productPrice(1200));<br />

<strong>com</strong>puters.productDisplay("whizbang.gif");<br />

addChild(<strong>com</strong>puters);<br />

You will need an FLV file, an MP3 file, and a GIF file for this application. Name the<br />

FLV file plasma.flv, the MP3 file bongo.mp3, and the GIF file whizbang.gif. The contents<br />

are unimportant but the names and file types are important.<br />

Open a new Flash document, save it in the same folder with the rest of the application,<br />

and type in DoBusiness in the Document class window. When you test it, the<br />

Output window shows the following:<br />

42 inch TV with Plasma screen<br />

$855<br />

MP3Player with 1 Terabyte of Memory<br />

$245<br />

New 10 gHz processor, 30 gigabyte RAM, includes 32 inch flat screen monitor<br />

$1200<br />

Polymorphism | 41

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

Saved successfully!

Ooh no, something went wrong!