Using Flashvars to load external mp3 files

I am trying to find a very good step by step tutorial on using "Flashvars" to load external mp3 files, I have been searching on google and the many I have found fall short in some way or another. From what I have been able to gather, I have tried using the code in red (commented out), which works, and modify it to use "Flashvars". The code that works, the mp3 file is hard coded, but my goal is to use "Flashvars" which I am attempting to do in the code following the code in red. I am also including the html code. Any help will be greatly appreciated.
Thanks,
David
var soundReq:URLRequest = new URLRequest("mardi_gras2.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
    sound.play();
var soundReq:URLRequest = new URLRequest(root.loaderInfo.parameters.audio);
var sound:Sound = new Sound();
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
    sound.play();
HTML CODE
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="mySoundvars" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="allowFullScreen" value="false" />
    <param name="movie" value="mySoundvars.swf" />
   <param name="FlashVars" value="audio=mardi_gras2.mp3" />
    <param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />    <embed src="mySoundvars.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="mySoundvars" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" FlashVars="audio=mardi_gras2.mp3" />

Ok waterlovinguy,
I went back to my original code, and I got things to work... I think my whole issue was with the HTML CODE. So I decided to use the "SWFObject generator". I had never used it before, frankly I had never heard of it until I started my searches on "Flashvars".
Thank you very much for all your assistance, PEACE,
David
Final Codes below
var my_var:String = new String();
my_var = root.loaderInfo.parameters.myflashvar;
myText.text = my_var;
var soundReq:URLRequest = new URLRequest(root.loaderInfo.parameters.audio);
var sound:Sound = new Sound();
var soundControl:SoundChannel = new SoundChannel;
sound.load(soundReq);
play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
function playSound(event:MouseEvent):void
    SoundMixer.stopAll();
    soundControl = sound.play();
function stopSound(event:MouseEvent):void
    soundControl.stop();
HTML Code
                <!>>
                <!<![endif]>
                    http://www.adobe.com/go/getflashplayer
                    </a>
                <!>>
                </object>
                <!<![endif]>
            </object

Similar Messages

  • Trouble with loading external mp3 files

    I apologize for the length of the post. I hope this is clear
    of what I am trying to explain.
    My problem deals with getting "undefined" when I press a
    button to load an external mp3 files. The following is what my XML
    childNode looks like:
    <option phonetic="Soundless, or A" name="aleph"
    cursive="alephCursive.swf" block="alephBlock.swf"
    audio="char1.mp3"/>
    Every attribute loads the way I've programmed them, except
    for the last one "audio".
    The following is what my actionscript looks like loading in
    these attributes:
    Everything is happening inside the onLoad event for my XML
    file.
    var xmlContent = this.firstChild.firstChild;
    audioContent = new Array();
    for (var i = 0;
    i<this.firstChild.firstChild.childNodes.length; i++) {
    nextEntry = xmlContent.childNodes
    audioContent = [nextEntry.attributes.phonetic,
    nextEntry.attributes.name, nextEntry.attributes.cursive,
    extEntry.attributes.block, nextEntry.attributes.audio];
    The code above simply adds each attribute to the audioContent
    array. Each element traces out correctly.
    The following code is how I am using these attributes:
    for (var i = 0; i<audioLength; i++) {
    audioContainer.attachMovie("container4", "audioItem"+i, i);
    // Create a shortcut reference to the present movie clip
    thisClip = audioContainer["audioItem"+i];
    thisClip.myTxt1.htmlText = audioContent[0];
    thisClip.myTxt2.htmlText = audioContent
    [1];
    thisClip.cursive_mc =
    loadThis(assetPath+audioContent[2], thisClip.cursive_mc);
    thisClip.block_mc = loadThis(assetPath+audioContent
    [3], thisClip.block_mc);
    thisClip.speaker_mc.attachMovie("speaker", "speaker_mc",
    this.getNextHighestDepth());
    thisClip.speaker_mc.speaker_mc.onRollOver = function() {
    this.nextFrame();
    thisClip.speaker_mc.speaker_mc.onRollOut = function() {
    this.prevFrame();
    thisClip.speaker_mc.speaker_mc.onRelease = function() {
    mySnd.loadSound(audioPath+audioContent[4],true);
    Loading the text works inside the htmlText. Using a function
    loadThis to load external swf files works corerctly and even
    attaching a linked movieclip from my library called "speaker" works
    correctly.
    The problem comes from pressing the speaker movieclip that
    the output traces "undefined" instead of the external mp3 file.
    I appreciate any help. Thanks.

    As Ned said the problem might be with the file structure on the server. Other problems may be with spelling. You computer may not be case sensitive to the names of the .swf files that you are loading, but your server might. So, on your computer when you are testing, second.swf is the same as Second.swf, or even second.SWF. But, on the server each of these variations is seen as a different file. Another problem is that when you are loading files from the same computer in testing, those files are close and so they load very quickly from your computer. When the files have to travel from the server, there will likely be a measurable period of time before the file is ready to be shown. This is particularly problematic with video that is embedded into an .swf. The whole file will need to be downloaded and uncompressed before it is available to play. If you stream the video as an external file, you can shorten the wait considerably.

  • Media files prevent Flash from fully loading external XML file

    Im trying to debug a flash widget we created, and it loads
    fine on the 20 odd computers we tested on EXCEPT for one computer
    where, the application doesn't load an external XML file that calls
    for 3 small mp3 files and a FLV file to load as well.
    In a debugger, we noticed that when it tried to load these
    mp3 files it was getting a Forbidden access message. The FLV just
    prevents the FLV player from showing up at all (not even the skin).
    Can anyone figure out why, that it would work over all the
    other computers and NOT the one? On that person's computer, we
    tried it in IE, Firefox, even Chrome and the application doesn't
    load. We even cleared the cache, did a hard refresh and still
    nothing.
    However, the other computers work just fine.
    ALL the computers have the latest Flash software installed.
    What could cause this problem?

    Actually what worked was removing 'xmldoc' from the php script. So $data =$GLOBALS["HTTP_RAW_POST_DATA"]; instead of $data = xmldoc($GLOBALS["HTTP_RAW_POST_DATA"]);
    Couldn't find anything about 'xmldoc'. Is it used for anything in php?
    Anyway, the loading error went away, but then I got into problems with getting the return echoed values back. The textfield stayed empty even when saving the data.txt file worked.
    I then placed the <stuff> tags between <root> tags and then flash got the sentences between the <stuff> tags back. Why does Flash need the returned xml output to be between <root> tags for it to see the content between the <stuff> tags? So why do I need to use echo("<root><stuff>Server unable to create file.</stuff></root>"); instead of cho("<stuff>Server unable to create file.</stuff>");?

  • Loading external .swf files issue...

    Hi,
    I'm working on a simple example of loading external swf files with some ActionScript.
    I've placed an instance of List Component and gave it an instance name of loadList. Using Component Inspector, I assigned data for 4 external files as below:
    Next, I've added a UILoader component (instance name - loadWindow). The code that is supposed to load the content into UILoader is this:
    loadList.addEventListener(Event.CHANGE, selectItem);
    function selectItem(e:Event):void
        loadWindow.source = e.target.selectedItem.data;
    When I run it in a FlashPlayer, it only loads the first 2 swf files....  (I checked the files and all files are fine).
    I hope to get some light on the issue so any help will be appreciated.

    Try tracing e.target.selectedItem.data to make sure it's what you expect.
    Also, have you tried using the load() method instead of the source property?

  • External MP3 files not working

    Hi,
    I have attached code straight out of the help file for using
    External MP3 files. It works perfect when I use their HelpExample
    sound MP3 file. However when I simply change the code to point to a
    working MP3 sound file in my LocalHost folder it executes but I
    only get a Blip sound.
    If I just double click on the sound file it sounds ok. and I
    have been successful in using these MP3 files embedded in Flash 8.0
    fla file
    Do the external MP3 files have to be on some special server?
    I am using this code with Flash 8.0
    Thanks,
    hugh

    The most likely reason for this failure is that since your SWF is now embedded into another SWF (the Captivate project) the paths to the AS files need to be altered in Flash to allow for this.
    You need to investigate how this would be done in AS code if your Flash SWF was a symbol inside another Flash SWF.

  • When I tried to load some mp3 files on to my samsung brightside I looked under card memory and my songs were there but when I clicked on my music it said no memory available remove files and I have an 8 gb micro sd card in and there is nothing else on it

    When I tried to load some mp3 files on to my samsung brightside I looked under card memory and my songs were there but when I clicked on my music it said no memory available remove files and I have an 8 gb micro sd card in and there is nothing else on it

    Whew.... got it to work after days of trying to figure.
    Got answer here:  http://forums.macrumors.com/showthread.php?t=1450821 from zblaze.
    Wiped phone completely, restored as NEW iphone through itunes.  Checked 'Sync all Music'.
    After that happens you can restore from backup.

  • Can you load external jpg files

    Is there a way to load external .jpg files on the fly or do
    they have to reside in the swf file?

    Hi Persons,
    macrofireball is correct as always, but I'll just add a
    thought to this thread because I suspect "rfull" isn't actually
    asking what he/she
    appears to be asking.
    No photo can ever be displayed "by itself". That is, image
    files are always "opened" in some sort of vehicle. It might be an
    image editor, or it might be a document like a *.DOC or a *.HTM ...
    but
    something must "contain" the image.
    So you can access a photo at any time you wish by putting it
    on a web page, then linking to the web page (for instance). Is
    something like that what you really had in mind?
    Have a good 'un folks!
    .

  • How use TestStand to load a txt file ?

    How to use TestStand to load a text file ?

    Hi,
    You will have to write a code module, in one of the supported languages, such LabVIEW, C, to do this function.
    You could also use the PropertyLoader to load a variable or a step property, but the file has to be formatted in a certain way. The Reference Manual page D-6 will explain this.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Pb loading external mp3 sound file

    Hello,
    I use the following code to load and then play an external
    mp3 sound file called "loop.mp3"
    var son:Sound=new Sound(this);
    son.loadSound("loop.mp3",false);
    son.onLoad=function(success) {
    if (success) {
    this.start(0,999);
    When I test my code while being under author environment by
    using CTRL+ENTER Key, the sound is playing properly but when
    launching the swf file alone, the sound is not playing. Why?

    ritpas wrote:
    > Hello,
    >
    > I use the following code to load and then play an
    external mp3 sound file
    > called "loop.mp3"
    > var son:Sound=new Sound(this);
    > son.loadSound("loop.mp3",false);
    > son.onLoad=function(success) {
    > if (success) {
    > this.start(0,999);
    > }
    > }
    >
    > When I test my code while being under author environment
    by using CTRL+ENTER
    > Key, the sound is playing properly but when launching
    the swf file alone, the
    > sound is not playing. Why?
    when you say "launching the swf file alone", what do you mean
    on destkop ? within browser ?
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • How Do I Use an External MP3 file Without Embedding it? (AS2)

    I am using Adobe Flash CS6 with ActionScript 2.0.
    I have compiled my project, and due the collection of embedded mp3 files (background music) I am using on various locations, my published swf file is over 12MB.
    To reduce the size, I placed all the mp3 fiels in the same folder as the swf file and removed all reference to them from the project.
    I then added this code to frame #1
    import flash.events.Event;
    import flash.media.Sound;
    import flash.net.URLRequest;
    var CreditsMusic:URLRequest = new URLRequest("NineWalkers.mp3");
    var s:Sound = new Sound(CreditsMusic);
    CreditsMusic.setVolume(50);
    CreditsMusic.start(0,1);
    Obviously, this is not working (I would not be posting here if it was).
    What am I doing wrong?

    I haven't look into the help documents (you can), but I see you mixing up AS2 and AS3 code, along with treating a URLRequest (AS3) as if it is a Sound object....
         CreditsMusic.setVolume(50);
         CreditsMusic.start(0,1);
    If you want to work with the Sound class in AS2 open the help documents and see what properties and methods are available for the Sound class and work things out from there.  If you search Google using "AS2 Sound loadSound" you might get some good info as well.

  • External MP3 files causing long delays (using MediaPlayBack component)

    I've got 5 MP3 files that I am calling (on click) to be
    played. They're large - about 15MB each. The Flash movie is
    intended to be distributed on a CD. However, when I launch the
    movie (Flash Pro with Slides) it takes a long time (30-200 seconds)
    before the first screen will show. Sometimes Flash displays the
    "actionscript is taking a long time..." message. When I remove the
    slides that play the MP3 there is no slowness. Also, when the MP3s
    cannot be found the movie has no delays.
    I converted the slides back to a timeline-based movie. This
    eliminated the up-front delay, but now the delay appears when I
    click on the button to play the MP3.
    Any ideas?

    I noticed that streaming is not working from CD... Instead
    all the file is loaded first, and that's why you've got
    delays...

  • Load external audio file in array?

    Hello.
    I have figured out how to load an external video file - and I can play an imported audio file, but I can't seem to use either method to load an external audio file into an array. (doh)
    Here is my audio code:
    var tour_audio:Array = [tour1, tour2]; 
    var my_num:Number= Math.floor(Math.random()*2);
    var ChosenSound = tour_audio[my_num];
    var playing:Sound = new ChosenSound();
    playing.play();
    Here is my video code:
    var my_videos:Array=new Array ("link1.mp4", " link2.mp4", " link3.mp4", " link4.mp4");
    var randomIndex = Math.floor(Math.random()*my_videos.length);
    my_player.source = my_videos[randomIndex];
    I tried "var tour_audio:Array = ["link1.mp3", "link2.np3"];  - but that did not work.
    ty

    // the array is from your code, the array will hold the references to the two sound files
    var tour_audio:Array = new Array();
    // then you need to create two instances of the sound class to hold the sound files that you load in
    var soundClip1:Sound=new Sound();
    var soundClip2:Sound=new Sound();
    // then you need a sound channel to play the sound files
    var sndChannel:SoundChannel=new SoundChannel();
    // this is your randomizer code
    var my_num:Number= Math.floor(Math.random()*2);
    // now you load each of the sound files into your sound class instances using URLRequest
    soundClip1.load(new URLRequest("tour1.mp3"));
    soundClip2.load(new URLRequest("tour2.mp3"));
    // to find out when the files have finished loading, you need to add an event listener to each of the sound classes
    // these event listeners will fire the functions onComplete1 and onComplete2 when each sound file has finished loading
    soundClip1.addEventListener(Event.COMPLETE,onComplete1,false,0,true);
    soundClip2.addEventListener(Event.COMPLETE,onComplete2,false,0,true);
    // this is the function for the first sound loader listener, it will add the sound class instance to your array once the sound has loaded
    function onComplete1(evt:Event):void {
        tour_audio.push(soundClip1);
    // this function does the same job for the second sound file
    function onComplete2(evt:Event):void {
        tour_audio.push(soundClip2);
      // call this function to play the chosen sound file
      // it could be called from the onComplete2 function above
    function playRandomSound():void {
              var ChosenSound = tour_audio[my_num];
              sndChannel = ChosenSound.play();
    I've added comments to the code itself that should help to explain what's going on. Yes, AS3 is just jam packed with intimidating stuff. As you use it, it will start to make some sense.

  • Loading external swf file in a new window

    Hi,
    I've got a few .swf files with video tutorials I've created using Captivate 4.
    I wanted to link them so I've created a main screen with menu with buttons in Flash.
    I've added AS to load the external swf files but they load in the same window. How can I load these .swf files in seperate window so that you could get back to the main window after you've finished watching?
    Here's my code:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        myLoader.load(myURL);
        addChild(myLoader);
    I'm also attaching screenshot with menu in flash

    I've deleted the line and now the code lookes like that:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        addChild(myLoader);
    Unfortunately, it doesn't load the .swf file when you click on the button...

  • Loading external htm file to display in TextArea

    Hi,
    I'm trying to think how I can load an external HTML file ad
    display the page in a TextArea and assign an external css file to
    style the text.
    Would appreciate any advice and sample code.
    Alex

    lexy,
    Are you trying to just use HTML text for a single text area,
    or are you trying to load an entire web page? If you are just
    looking to load some text, you can create an
    <mx:HTTPService> and point it to your .html file. Then
    you have to drill down to the section you are looking for ie..
    htmlVar.HTML.Body.div.tr.td.etc. Unless you are creating the
    file from scratch, in which case you can just make is an HTML
    formatted flat file with a single header like:
    <body> this is the <b>TEXT</b> I wanted to
    <i>display</i> </body>
    and then just load that. In any case, load that into an
    Object and then assign, the
    htmlText property of your textArea the Object variable and
    you should be set (be that the case).
    If you are looking to load a webpage in a container, check
    out this link:
    http://raghunathraoflexing.blogspot.com/2006/12/flex-i-frame.html

  • Loading external (PDF)file into BLOB colum in the table.  Need urgent help.

    Hi All,
    I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioning to use PL/SQL procedure to do so. Since I have not done anything like this before. So, my question is what is the simple approach needed to upload PDF files into a table(there is only one table containing BLOB column in my database). In addition, the LOBs can not be query-able, I wanted to list the contents of the LOBs column to make sure that I did successfully upload data into the database. How can I do that?. I do need your help. Please direct me step by step how to do so. Your help is greatly appreciated.
    Regards,
    Trang

    Once the PDF file is inserted in the PDM table, i am not able to read the PDF data from the below code, This code converts the binary data into the Character data i.e BLOB data into the CLOB, but still the data is not proper which is getting inserted PDF is proprietary format of Adobe. And you cant just read it from pl/sql. You need Adobe software installed in your client machine to view it.
    Here is an example of how to do it.
    [url http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006] Display PDF Stored in Database from ASKTOM 

Maybe you are looking for

  • Unable to create EM repository in 10g RAC - 2 nodes (Windows)

    Hi, I am trying to configure Enterprise Manager via command prompt since it failed while creating the database through DBCA. I have a two node cluster running oracle 10g (10.2.0.2) on Windows 2003 x64. I could get something in metalink related to emc

  • IO 4 update made 3G phone very slow

    After updating to the new software my 3G phone has been very slow. Typing text messages it does not keep up with the typing and every word is messed up. Loading of any app is very slow. I have tried restarting the phone and it does nothing. It is cle

  • Unable to view payload in HTTP to RFC Scenario

    Hi, I have done HTTP to RFC Scenario. It's working fine. I know that for synchronous message the payload will be deleted (for save memory) after execution. But i want to see the payload of  request and response messages. I am unable to. Please sugges

  • Resume from Standby not by opening the cover

    Hello, I'm using Arch with KDE4. Standby really works fine with my Dell XPS1530 but it wakes up as soon as I open the cover. I would like to resume by clicking the power button. (If I'm not using the battery but the power plug I have to use the butto

  • Repeat a specific number of times

    I have 6 frames on my movie timeline. Each frame has a movie about 200 - 300 frames. I want each movie to repeat a specific number of times before it goes to the next frame on the main movie time line. How can I do this