1 / 17

April 9 th – Jeff Galak (CMU)

Programming Behavioral Experiments in Flash Session 3 of 3 Advanced Topics if Flash (Sounds, Videos, and Real Time Ratings). April 9 th – Jeff Galak (CMU). Agenda for the Week. Session 1: Thursday, April 8 th (10-12pm): Intro to Web Programming, PhP, and Flash

astrid
Download Presentation

April 9 th – Jeff Galak (CMU)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Behavioral Experiments in FlashSession 3 of 3Advanced Topics if Flash (Sounds, Videos, and Real Time Ratings) April 9th – Jeff Galak (CMU)

  2. Agenda for the Week • Session 1: Thursday, April 8th (10-12pm): Intro to Web Programming, PhP, and Flash • Session 2: Thursday, April 8th (2-4pm): Building Your First Flash Experiment • Session 3: Friday, April 9th (10-12pm): Advanced Topics if Flash (Sounds, Videos, and Real Time Ratings) Session 3 - 04/09/2010

  3. Agenda for Today • How to play sounds • How to collect real time ratings • How to play videos • How to convert videos to Flash format • How to “rip” videos from YouTube Session 3 - 04/09/2010

  4. Working with Sound Files • Import sound file to library • File->Import->Import to Library • Within the library, create a “linkage” • Right click on sound file -> Linkage • Check “Export for Actionscipt” • Give your file a name • Ok • Now your file is ready to be accessed via ActionScript Session 3 - 04/09/2010

  5. Sound File + Actionscript • Define a “sound variable” • var currentsound:Sound = new Sound (); • Created a variable called “currentsound” • Attach a sound file to the new variable • currentsound.attachSound("sample"); • Attached the sound file “sample” to “currentsound” • Play the file • currentsound.start(0,1); • Plays the sound file associated with “currentsound” • The first argument “0” tells it to start at the begninning of the song • The second argument “1” tells is the number of times to play the sound (once, in this case) Session 3 - 04/09/2010

  6. Other Things to Remember with Sound Files • You can stop your sound file with the stop() command: • currentsound.stop(); • You can change the volume with the volume command (0 to 100): • currentsound.setVolume(50); • You can have the program do something (e.g. go to the next frame) when the sound is done playing: currentsound.onSoundComplete = function() { nextFrame(); } Session 3 - 04/09/2010

  7. Collecting In-Experience (Online) Ratings • Two ways to do this: • Stop people every X seconds and collect a measure • Have a slider-scale that continuously records a value • We will focus on the latter. Session 3 - 04/09/2010

  8. Online Scale Set up (With a Song) Scale Session 3 - 04/09/2010

  9. Online Scale Code Code for song Code for slider scale Tells flash to run the function “collectdata” every 3 seconds When this function is run, it simply stores the value of the scale Session 3 - 04/09/2010

  10. Things to Remember with Online Scales • You can change the frequency of the data collection by changing the number in the myTimer line. Time is in milliseconds. • Make sure to add the clearInterval command when you leave the frame • In this case, when the sound stops playing Session 3 - 04/09/2010

  11. Working with Videos • Videos need to be in .flv (flash video) format. • You can convert them using flash. • File -> Import -> Import Video • This takes a long time but works well. • You can use 3rd party software for conversion • Allok Video to FLV Converter • http://www.alloksoft.com/flv_converter.htm • Works much faster, but sometimes the converted file doesn’t work. No clue why. Session 3 - 04/09/2010

  12. Ripping Video from YouTube • http://www.savevid.com/ • Simply copy+paste the URL from youtube into the box on savevid.com • Make sure the file extension is .flv • Done. Session 3 - 04/09/2010

  13. Editing FLV Files • Adobe Air + RichFLV • Adobe Air: http://www.adobe.com/products/air/ • RichFLV: http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1355018 • Install Air first. • RichFLV lets you edit FLV files quickly. Session 3 - 04/09/2010

  14. Flash and Videos • Create a video placeholder with the “my_video” object in the library. • Name it something: my_video • Make sure that the video file is somewhere on the web (even while testing). Session 3 - 04/09/2010

  15. Actionscript and Videos This is the only line you really care about This block of code is optional. It allows you to skip the video by hitting CTRL+A Session 3 - 04/09/2010

  16. What About Online Measures and Videos? Just add the scale and the myTimer code: myTimer = setInterval(collectdata,3000); iteration=1; function collectdata() //function that stores the data { ratio=Math.round(((Slider.dragger._x-(Slider.dragger._width/2))/(Slider.line._width))*sliderMaximum); storedata("soundrating_"+iteration,ratio); iteration++; } Session 3 - 04/09/2010

  17. That’s It! • Go forth and collect data! • Spread the gospel of Flash. • And most importantly, have a great weekend. Session 3 - 04/09/2010

More Related