Son's First Flash

Out of context: Reply #32

  • Started
  • Last post
  • 39 Responses
  • PonyBoy0

    Enter response:

    take the sound constructor out of the on(release)...

    ... are you importing the full track into flash then exporting it as an swf w/embedded music... and just 'attaching' a sound via your library?

    I have a much better suggestion for you. :) It's using what you're doing there - but you should probably set the object up on the timeline somewhere - but not IN the script for the button...
    ... just use your button to call the sound object.

    instead of using attachSound, may i suggest using loadSound
    and just stream your mp3 as apposed to building a fat swf (so there's no need to import your music into flash at all - let actionscript grab the mp3 and stream it)...

    check this page for reference on flash's sound object:
    http://www.adobe.com/support/fla…

    to set up a sound object that uses an external mp3 - set up your object the same as you did using 'attachSound'.

    this should work:

    my_sound = new Sound();
    my_sound.loadSound("song1.mp3", true);

    then - you can use a simple boolean function to start and stop the sound.

    first create your boolean variable (booean means it can only be 'true' or'false')...

    onOff = true;

    then... put the following on your button:

    on (release){
    if (onOff){
    my_sound.start();
    }else{
    my_sound.stop();
    }
    }

    that's it. The 'true' in the attachSound above means that 'streaming' will occur. If you put 'false' - then the entire file has to download to someone's computer before it'll start to play.

View thread