0
votes

I need to zip the flash SWF but when I relocated the swf, my sounds and video doesn't show up. I'm using ULRrequest, but what can i use instead? I really need help!!

Code:

import flash.media.Sound;
import flash.net.URLRequest;
var req3:URLRequest = new URLRequest("lady.mp3");
var lady: Sound = new Sound();
lady.load(req3);
3

3 Answers

0
votes

Your code means the sounds have to be in the same location as the SWF. You could always embed the sounds into the FLA so they are all contained, or you could host the sound files somewhere and source them from there instead.

0
votes

If you are using Flash IDE (Flash Proffesional) then to contain your project in 1 file, you need to embed all files inside. To do so, press Ctrl+R and attach your files. Remember to change the way you call the .mp3 file: set AS Linkage in library and

var lady:Sound = new YourASLinkage();
0
votes
  1. Where is sound.play(); call ?

  2. Check the examples in the ActionScript Help Pages http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#includeExamplesSummary

  3. Where is your error handling. What if the path to sound/video file is wrong ?

    package { import flash.display.Sprite; import flash.events.*; import flash.media.Sound; import flash.media.SoundChannel; import flash.net.URLRequest;

    public class SoundExample extends Sprite {
        private var url:String = "MySound.mp3";
        private var song:SoundChannel;
    
        public function SoundExample() {
            var request:URLRequest = new URLRequest(url);
            var soundFactory:Sound = new Sound();
            soundFactory.addEventListener(Event.COMPLETE, completeHandler);
            soundFactory.addEventListener(Event.ID3, id3Handler);
            soundFactory.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            soundFactory.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            soundFactory.load(request);
            song = soundFactory.play();
        }
    
        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }
    
        private function id3Handler(event:Event):void {
            trace("id3Handler: " + event);
        }
    
        private function ioErrorHandler(event:Event):void {
            trace("ioErrorHandler: " + event);
        }
    
        private function progressHandler(event:ProgressEvent):void {
            trace("progressHandler: " + event);
        }
    }
    

    }

    Hope it helps.