# (FMX) AS-Sound?

**URL:** <https://forum.kirupa.com/t/fmx-as-sound/63314>\
**Category:** Uncategorized\
**Created:** [September 5, 2004, 8:54am UTC](https://forum.kirupa.com/t/fmx-as-sound/63314 "2004-09-05T08:54:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashy22](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@flashy22](https://forum.kirupa.com/u/flashy22)\
**Post date:** [September 5, 2004, 8:54am UTC](https://forum.kirupa.com/t/fmx-as-sound/63314/1 "2004-09-05T08:54:00Z")

</div>

Hey all, im having a bit of trouble with something,  
ok well, if you look at the attached file, there are 2 circles(movie clips), they have an AS code on them :

onClipEvent (enterFrame) {  
if (this.hitTest(\_root.\_xmouse,\_root.\_ymouse,true)) {  
this.\_x = int(Math.random()\*550);  
this.\_y = int(Math.random()\*400);  
}  
}

Now, i wanted to put a sound on the rollover, so when it ran away, it would make a noise, so i put an invisible button on the top in each movie-clip.  
and put a sound on the over state, but, this makes the MC’s not run away!  
So i thought that i could add a on (rollOver), but i dont know the code to load a sound from the library, any help appreciated,  
Thanks,  
Ben (flashy22)

---

<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:** [September 5, 2004, 8:56am UTC](https://forum.kirupa.com/t/fmx-as-sound/63314/2 "2004-09-05T08:56:03Z")

</div>

Sorry!  
forgot to add file!  
Ben (flashy22)

---

<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:** [September 5, 2004, 10:29am UTC](https://forum.kirupa.com/t/fmx-as-sound/63314/3 "2004-09-05T10:29:15Z")

</div>

O…k…  
No-one knows???  
help! please!

---

<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:** [September 5, 2004, 4:19pm UTC](https://forum.kirupa.com/t/fmx-as-sound/63314/4 "2004-09-05T16:19:32Z")

</div>

You could do something like this:

onClipEvent(load) {  
zip=new Sound(this);  
zip.attachSound(“zip01”);  
// zip01 is the linkage identifier of an mp3 in the library.  
}  
//  
onClipEvent (enterFrame) {  
if (this.hitTest(\_root.\_xmouse,\_root.\_ymouse,true)) {  
zip.start();  
this.\_x = int(Math.random()\*550);  
this.\_y = int(Math.random()\*400);  
}  
}

Here’s you fla back with this code in it.

[http://www.aspirin99.com/flash/chase.fla](http://www.aspirin99.com/flash/chase.fla)

---

<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:** [September 6, 2004, 11:12am UTC](https://forum.kirupa.com/t/fmx-as-sound/63314/5 "2004-09-06T11:12:12Z")

</div>

Hey KennyB,

Thanks alot for the help, i would never have thought to use a hit-test,  
Thanks again!  
Ben (flashy22)
