A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: newbie with simple sound problem

  1. #1
    Junior Member
    Join Date
    Feb 2004
    Location
    Karlsruhe, Germany
    Posts
    5

    newbie with simple sound problem

    Hello,
    i think there is a loop in my head and i couldn't fix a simple problem.
    I want to start a sound in a movieclip under a simple condition like here:
    //Width = 600
    onClipEvent(load){
    a = 4;
    this._x = -582;
    this._y = 117;
    }
    onClipEvent(enterFrame){
    this._x += a;
    if (this._x > 171)[
    a = 0]
    }
    so if this._x exceeds 171 or != the sound should start.
    I tried a lot, but at all times the sound starts at the beginning of the MC.
    Thank You for helping.
    Best wishes from Germany
    Bansche
    Attached Files Attached Files

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Hmmmmm.....
    I don't see where you load or play the sound. I see you setting a variable called "a" and the train stops incrementing the ._x when it exceeds 171 but that's all. But assuming you have a sound loaded in a sound object like:

    mySound=new Sound()
    mySound.loadSound("train.mp3",false);

    then in you loop you could but

    onClipEvent(enterFrame){
    _root.txt1.text=this._x
    this._x += a;
    if (this._x > 171){
    a = 0
    mySound.play();
    }

    Also I noticed you had
    onClipEvent(enterFrame){
    _root.txt1.text=this._x
    this._x += a;
    if (this._x > 171)[
    a = 0]

    }

    and was surprised it worked with [] instead of {}

    }

  3. #3
    Junior Member
    Join Date
    Feb 2004
    Location
    Karlsruhe, Germany
    Posts
    5

    Thank you very much

    but i tried al lot of things you suggest and i didn't hear sound all the times.
    I think this is caused by less knowledge about AS, specially in terms of -_root and these things.
    I found at least another way:
    in the trainMC i added another frame. Then i added a new MC with a swf including the mp3) inside to this frame.
    At first frame i put a stop
    and the AS is the following:
    onClipEvent(enterFrame){
    _root.txt1.text=this._x
    this._x += a;
    if (this._x > 171){
    a = 0
    nextFrame()};
    }
    At this time my solution fits my problem.
    Sorry for not understanding Your solution, but i am just an (unemployed) truckdriver in Germany, not a computer specialist
    Best wishes from Germany
    Bansche

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Not to worry Bansche, I just didn't see your audio in the file you uploaded so it was a guess on my part.

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