Download presentation
Presentation is loading. Please wait.
Published byPenelope Irish Modified over 10 years ago
1
Sound, Video & XML (image gallery) Flash ActionScript Introduction to Thomas Lövgren thomas.lovgren@humlab.umu.se
2
Sound • loadSound(): Dynamic loading //create a sound object var bg_sound:Sound = new Sound(); bg_sound.loadSound("bgSound.mp3", true); //load, streaming = true bg_sound.start(); trace(”backgroundsound on!"); //output //looping background sound bg_sound.onSoundComplete = function(){ bg_sound.start()} • attachSound(): Get sound from library effect_sound.attachSound("effect_sound"); //linking in library effect_sound.start(); trace(“sound effect on!"); //output Ex
3
Video (1/2) • Flash Video (.flv): Dynamic loading Streaming: ex. with Flash Media Server Progressive downloading: Short clips (ex. YouTube) • Two methods: 1) Video component with skin (automatic) 2) Actionscriptbased video (more options) – loading through a video object • Flash Video can be created and modified by: Sorenson Squeeze Flash 8 / Flash CS3 (File/Import/Import Video ) • Check settings: size/resolution, framerate, encoding, sound etc.
4
Video (2/2) • Actionscriptbased video • Create a video object: Right-click in Library and choose: ”New Video” click Video (Actionscript – controlled) • Drag the symbol and place it on stage, name it to my_video //video object on stage var my_video:Video; //create a NetConnection object var my_nc = new NetConnection(); my_nc.connect(null); //open connection //netStream object for videostream var my_ns = new NetStream(my_nc); my_ns.setBufferTime(5); //buffer 5 sec, then play! my_ns.seek(0); //start at (time = 0) //add the stream object my_video.attachVideo(my_ns); //play current video clip my_ns.play("kickbackCD.flv"); Ex
5
XML • Similar function with a database (only read access) • Often used in combination with Flash • XML works like a tabel/list for holding data • Using XML for (Dynamic) loading of data (ex. Sound, images, video) • A technique for reducing the filesize of the application • Easy to update
6
The XML structure • The XML file imgData = this.firstChild.childNodes;
7
XML (1/2) • Build the ”XML structure” in a texteditor, ex: • Save as myFile.xml (encoding UTF-8)
8
XML (2/2) • Load data into Flash through a XML object var my_xml = new XML(); my_xml.ignoreWhite = true; my_xml.load("gallery/imageData.xml"); var image:Number = 0; my_xml.onLoad = function(status) { if (status) { imgData = this.firstChild.childNodes; loadMovie(imgData[image].attributes.path, "mc"); display_txt.text = imgData[image].attributes.info; image_txt.text = "Bild " + (image + Number(1)) + " / " + imgData.length; delete my_xml; } else { display_txt.text = "Data cannot be loaded!"; }}; Ex
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.