1 / 8

Sound, Video & XML (image gallery)

Introduction to. Flash ActionScript. Sound, Video & XML (image gallery). Thomas Lövgren thomas.lovgren@humlab.umu.se. Ex. Sound. loadSound(): Dynamic loading //create a sound object var bg_sound:Sound = new Sound(); bg_sound.loadSound("bgSound.mp3", true); //load, streaming = true

tasya
Download Presentation

Sound, Video & XML (image gallery)

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. Introduction to Flash ActionScript Sound, Video & XML (image gallery) Thomas Lövgren thomas.lovgren@humlab.umu.se

  2. Ex 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

  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. Ex 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 tomy_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");

  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: <?xml version="1.0" encoding="UTF-8"?> <images> <image info=”Maldiverna" path="gallery/image01.jpg"></image> </images> • Save as myFile.xml (encoding UTF-8)

  8. Ex XML (2/2) • Load data intoFlashthrough 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; deletemy_xml; } else { display_txt.text = "Data cannot be loaded!"; } };

More Related