Programming games Cannonball due. Drawing & printing example. Acquiring video or sound Homework: Catch up: complete projects (rps, Bo, cb). Start video or audio. Plan your project. Cannonball extension • You may consider adding sound to cannonball for your sound/video project. • Can use – coding or – sound in frame Flash terms • Create .fla and .as files using Flash development environment. This is development time. • Runtime (aka execution time) – Test program using the development environment. This does create a .swf file. – Publish creates .html file and .swf file Development time • Bring instances of movie clip symbols in Library to the Stage. – Give instance names – ActionScript refers to instances by name • Can File/Print – May not do what you want… – I copy and paste code into Word or Dreamweaver Drawing & printing • Adding content, namely a movie clip symbol to Stage at runtime – Various calculations – Use Properties of symbol (right mouse click) to set up: Export for ActionScript • Print during runtime – Can set up to print several pages. My example just prints one page. Demonstrate • Drawing example • Note: this is a ‘stub’ for a bigger application. Features • Create wall symbol. Change settings to Export for ActionScript. • Set up handling for mouse click on board. – One handler for 1st click and another for 2nd click – Use ev.localX and ev.localY to get coordinates. – Use Math.atan2(…) and Point.distance(…) • Use PrintJob Making your own video for Flash playback • • • • • • Shoot video Upload to computer [Edit] Produce .flv Create Flash movie and test Publish Flash movie – Upload .html, .swf, and all the .flv files to the server Initial steps • Shoot (?) video • Upload to computer Producing .flv • Just like images, there are different encodings for videos. – wmv, mov, avi, dv, …. • Adobe Flash CS4 Media Encoder will accept many different types and produce an .flv file (an .flv version of the same video clip) – Can set quality settings • Tradeoff: size (space on server, loading time) versus quality Start queue • Creating the .flv file takes a while…. • You can do more than one encoding at a time. – The name of each file is the same name, with filetype .flv • Use the pre-set settings OR get into more detail – Higher quality means larger files Acquire video • Find website with video (or audio) • go to http://file2hd.com/ – Enter URL of site – Check off agree to terms, filter (movies or audio) – click on get files – be patient – choose from list. Sound Two (at least) methods for incorporating sound into Flash • All coding: create Sound objects, set source of sound, play. Can manipulate volume, pan, etc. using Soundchannel. Also, register and handle events, including when sound has been loaded. • Frame: associate [start of] sound with frame. Acquire sound • Many types of sound. For coding method, need mp3 • Find on-line sound editors. • Need to know location (URL) of sound file(s). Coding method import flash.media.Sound; import flash.net.URLRequest; This file is located in the same folder on my computer. It doesn't have to be. var urlname:String = "missle.mp3"; var requestsf:URLRequest = new URLRequest(urlname); var msound:Sound = new Sound(requestsf); // at appropriate place in the code msound.play(); Frame method • File/Import/Import to Library – Select sound file(s). • Click on appropriate frame in timeline • In property panel, select Sound [file]. – You can select a set effect and/or edit the sound. Cautions • In either method, need to be aware that sound lasts certain amount of time. • Be careful about starting sound again and again (unless that is what you want) Examine source • Sound added to frame – Bo the barking dog – consider for collapsing/exploding target • Code – Play sound as event handler for button click – Play random choice of tune from [short] list. • Note: pause, pan, volume features. These require other objects. Homework • Decide on video or audio – Create or acquire video clip(s) – Create or acquire audio clips. Can use Common Library / sounds. – Keep in mind: this is a short assignment. – You can incorporate sound or video into your final project. • Think about what you want to do for your project – Check with me AND make proposal to blog.
© Copyright 2026 Paperzz