A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Music help needed

  1. #1
    Junior Member
    Join Date
    Sep 2001
    Posts
    1

    Post

    I am trying to create a simple music on/off icon in koolmoves. I want the music file to come on on mouse press and off on next mouse press. Seems simple but I just can't get it!
    I have tried with sound file associated with the first frame and none on second frame. Is this corect. If so how do I get it to come back on?

    Thanks in advance.

    Lee

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    I am going to give you partial advice and let others fill in the blanks. The easiest way I can see to do this is by using action scripting on a button. Something like:

    on (release)
    {
    var flag;

    if (playflag)
    {
    .. not sure what to put here
    flag = false;
    }

    if (!playflag)
    {
    .. not sure what to put here
    flag = true;
    }

    playflag = flag;
    }

    this could use if else or return capability.

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    There are actually two ways to do this. The hard way and the easy way. The hard way is this:

    This is how you would do this in Flash 5 http://www.flash5actionscript.com/soundobject.php


    Before your Mouse in a Frame action you will do this:

    soundname= new sound;
    soundname.attachSound("Name of sound in Koolmoves");

    Okay;

    On the Mouse

    On(release)
    {Flag+=1;
    if(flag==1){soundname.start(offset,loop times);
    if(Flag==2){soundname.stop(offset,loop times);
    Flag=0;}}

    Okay Now the Easy way:

    Create a SWF with nothing but your sound in it. export it as sound.swf, and save it to the same directory as your new SWF

    On(release){Flag+=1;
    if(Flag==1){loadMovie("sound.swf","_level1")};
    if(Flag==2){unloadMovie("_level1");StopAllSounds() ;Flag=0}}
    [Edited by johnie on 01-04-2002 at 05:04 PM]

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