A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: AS3/CS3 audio streaming app help

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    2

    AS3/CS3 audio streaming app help

    So, I've got most of it working, check it out at http://figmentmedia.ca/test.html. But I realized when I uploaded it that the loading bar (tan line across the bottom) didn't load with file. I may just have blazingly fast internet, and didn't notice the load.. but I doubt it. This to me seems strange, but might be simple to some of you. Here is my code:
    import flash.media.Sound;
    import flash.media.SoundLoaderContext;
    import flash.net.URLRequest;

    var soundClip:Sound = new Sound(); //declaring variable 'clip'
    var soundReq:URLRequest = new URLRequest("test1.mp3");//declaring var 'req' value is 'test1.mp3'
    var soundContext:SoundLoaderContext = new SoundLoaderContext(8000, true);//declaring variable 'ctx' value is 8 seconds
    var soundControl:SoundChannel = new SoundChannel();//controls the sound (stop/go)
    var soundPosition:int = new int (soundControl.position);
    var soundLength:int = new int (soundClip.length);
    soundClip.load(soundReq, soundContext);//load 'req' with the value of 'ctx' (play at 8 seconds)

    soundClip.addEventListener(Event.COMPLETE, onComplete);
    addEventListener(Event.ENTER_FRAME, onEnterFrame);

    function onComplete(event:Event):void{
    mc_control.btn_play.addEventListener(MouseEvent.CL ICK, playSound);
    mc_control.btn_stop.addEventListener(MouseEvent.CL ICK, stopSound);
    }

    function playSound(event:MouseEvent):void{
    soundControl.stop();
    soundControl = soundClip.play(soundPosition);
    mc_control.swapChildren(mc_control.btn_play, mc_control.btn_stop);
    }

    function stopSound(event:MouseEvent):void{
    soundPosition = soundControl.position;
    soundControl.stop();
    mc_control.swapChildren(mc_control.btn_play, mc_control.btn_stop);
    }
    function onEnterFrame(ev:Event):void{
    trace(soundControl.position/soundClip.length*100)
    mc_position.x = 101+(soundControl.position/soundClip.length*294);//% of song played along a bar 294px long
    mc_loaded.width = 297/(soundClip.bytesLoaded/soundClip.bytesTotal);//% of song loaded along a bar 297px long
    }
    The second last line there, thats the one giving me trouble.
    Any Suggestions would be much appreciated

  2. #2
    Junior Member
    Join Date
    Sep 2008
    Posts
    2
    So, I'm new.. use the other thread. Sorry.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center