Download presentation
Presentation is loading. Please wait.
Published byPriscilla Cole Modified over 9 years ago
1
Programming Behavioral Experiments in Flash Session 3 of 3 Advanced Topics if Flash (Sounds, Videos, and Real Time Ratings) January 30, 2009 – Jeff Galak (NYU)
2
Session 1 - 01/30/2009 2 Agenda for the Week Session 1: Thursday, January 29 th (2-4pm): Intro to Web Programming, PhP, and Flash Session 2: Friday, January 30 th (10-12pm): Building Your First Flash Experiment Session 3: Friday, January 30 th (3-5pm): Advanced Topics if Flash (Sounds, Videos, and Real Time Ratings)
3
Session 1 - 01/30/2009 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
4
Session 1 - 01/30/2009 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
5
Session 1 - 01/30/2009 5 Sound File + Actionscript 1.Define a “sound variable” –var currentsound:Sound = new Sound (); Created a variable called “currentsound” 2.Attach a sound file to the new variable –currentsound.attachSound("sample"); Attached the sound file “sample” to “currentsound” 3.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)
6
Session 1 - 01/30/2009 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(); }
7
Session 1 - 01/30/2009 7 Collecting In-Experience (Online) Ratings Two ways to do this: 1.Stop people every X seconds and collect a measure 2.Have a slider-scale that continuously records a value We will focus on the latter.
8
Session 1 - 01/30/2009 8 Online Scale Set up (With a Song) Scale
9
Session 1 - 01/30/2009 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
10
Session 1 - 01/30/2009 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
11
Session 1 - 01/30/2009 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 3 rd 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.
12
Session 1 - 01/30/2009 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.
13
Session 1 - 01/30/2009 13 Editing FLV Files Adobe Air + RichFLV –Adobe Air: http://www.adobe.com/products/air/ –RichFLV: http://www.adobe.com/cfusion/exchange/inde x.cfm?event=extensionDetail&loc=en_us&exti d=1355018 Install Air first. RichFLV lets you edit FLV files quickly.
14
Session 1 - 01/30/2009 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).
15
Session 1 - 01/30/2009 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
16
Session 1 - 01/30/2009 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++; }
17
Session 1 - 01/30/2009 17 That’s It! Go forth and collect data! Spread the gospel of Flash. And most importantly, have a great weekend.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.