# Play sound only after first rollover

**URL:** <https://forum.kirupa.com/t/play-sound-only-after-first-rollover/35441>\
**Category:** Uncategorized\
**Created:** [November 14, 2003, 1:45am UTC](https://forum.kirupa.com/t/play-sound-only-after-first-rollover/35441 "2003-11-14T01:45:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ranoka](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ranoka/32/265_2.png) [@Ranoka](https://forum.kirupa.com/u/Ranoka)\
**Post date:** [November 14, 2003, 1:45am UTC](https://forum.kirupa.com/t/play-sound-only-after-first-rollover/35441/1 "2003-11-14T01:45:21Z")

</div>

I can’t figure out what is wrong with my code. I’m trying to get it so that if the user moves the cursor over a movieclip that it plays a sound. But I don’t the sound to be played the next time they roll over the movieclip.

This is the code I’m tried making myself, I put it on the movieclip instance…

[AS]onClipEvent(load){  
PlayOnce= true;  
}  
on(rollOver){  
if (PlayOnce=true){  
ZolagSound = new Sound(this);  
ZolagSound.attachSound(“zolag”);  
ZolagSound.start();  
}  
}  
on(rollOut){  
PlayOnce=false;  
}[/AS]

What the code does right now, is plays the sound regardless of whether it’s been played before.

Any help, and an explanation of why my code isn’t working would be great!

I’m using flash MX at home, but need the code to work on Flash 5 at uni.

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 14, 2003, 1:59am UTC](https://forum.kirupa.com/t/play-sound-only-after-first-rollover/35441/2 "2003-11-14T01:59:15Z")

</div>

```auto
onClipEvent (load) {
	PlayOnce = true;
}
on (rollOver) {
	if (PlayOnce == true) {
		ZolagSound = new Sound(this);
		ZolagSound.attachSound("zolag");
		ZolagSound.start();
		PlayOnce = false;
	}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 14, 2003, 2:28am UTC](https://forum.kirupa.com/t/play-sound-only-after-first-rollover/35441/3 "2003-11-14T02:28:38Z")

</div>

thanks claudio 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 14, 2003, 2:31am UTC](https://forum.kirupa.com/t/play-sound-only-after-first-rollover/35441/4 "2003-11-14T02:31:42Z")

</div>

welcome 🙂
