# 'Fmx'...ClipEvents and On handlers

**URL:** <https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808>\
**Category:** flash\
**Created:** [February 4, 2003, 11:32pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808 "2003-02-04T23:32:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![janice](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@janice](https://forum.kirupa.com/u/janice)\
**Post date:** [February 4, 2003, 11:32pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/1 "2003-02-04T23:32:35Z")

</div>

hello,  
i have recently downloaded some tutorials and example FLA’s on elasticity (which is actually far too advanced for my current understanding of AS), however, with one of the fla’s i would like to add an On handler in the current code, but can’t figure out how to do it.  
below is the code attached to the MC on the main stage, which in turn contains a button.  
a frame action on the main timeline defines the variables ‘frenata’ and ‘velocita’…

onClipEvent (load) {  
org\_x = this.\_x;  
org\_y = this.\_y;  
newX = \_x;  
newY = \_y  
}  
onClipEvent (enterFrame) {  
Xspeed = ((\_x-newX)/\_root.velocita+Xspeed)/\_root.frenata;  
\_x -= Xspeed;  
Yspeed = ((\_y-newY)/\_root.velocita+Yspeed)/\_root.frenata;  
\_y -= Yspeed;  
if (velocita\<2) {  
velocita=2;  
}  
if (frenata\<1) {  
frenata=1;  
}  
\_root.menu6.newX = (this.\_x)+20;  
\_root.menu6.newY = (this.\_y)-45;  
}

is it possible to add some more script to this that would activate another movie clip??

thank you in anticipation.  
janice

---

<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:** [February 5, 2003, 12:15pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/2 "2003-02-05T12:15:29Z")

</div>

Hi janice,  
Yes it is possible to do as you want, it just depends when you want to activate another mc as to where you put the code.  
For example, if you wanted to activate an mc dependant on the \_x pos of \_root.menu6 - you could include anothe if statement

if you could be a bit more explicit as to what you are trying to achieve, I can probably help you more.

Do you have a test fla. you can post ?

Cheers

SteveD

---

<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:** [February 5, 2003, 4:53pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/3 "2003-02-05T16:53:23Z")

</div>

Since you’re working with MX, you can put button handlers as well on the clip. No problem 🙂

---

<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:** [February 5, 2003, 4:58pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/4 "2003-02-05T16:58:05Z")

</div>

but you can´t put _clip handlers_ and _button handlers_ together. am i right pom?

---

<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:** [February 5, 2003, 5:25pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/5 "2003-02-05T17:25:49Z")

</div>

> but you can´t put clip handlers and button handlers together. am i right pom?

myMovie.onEnterFrame = function(){  
this.\_x+=5  
\_root.myButton.onRelease = function(){  
trace(“myButton Called”);  
}  
};

Insert this into your first frame actions.

Sorry, but am afraid your abit outdated. 😉 j/k

PS. It can’t be done in Flash 5 tho.

---

<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:** [February 5, 2003, 6:28pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/6 "2003-02-05T18:28:15Z")

</div>

i didn´t mean that there is no way you can do such thing, and did you read the word…

[SIZE=4] **together** [/SIZE] ??

😛

and… functions are not normal handlers 😉  
but thanks for the code anyways =)

---

<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:** [February 5, 2003, 7:33pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/7 "2003-02-05T19:33:18Z")

</div>

h88 was using Dynamic Event Handlers 😉 Which are technically functions, but are also handlers 🙂

And h88, you can also do…

```php
onClipEvent (enterFrame) {
	_root.instanceName.onPress = function() {
		//do this
	};
}

```

Where you don’t have to use Dynamic Event Handlers for both handlers, but only the ones contained within the onClipEvent handler (or on handler)

But I am sure you knew that Mr. FlashCoderGeniusGuy

---

<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:** [February 5, 2003, 8:44pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/8 "2003-02-05T20:44:35Z")

</div>

> Where you don’t have to use Dynamic Event Handlers for both handlers, but only the ones contained within the onClipEvent handler (or on handler)

Of course we can! But why are you still using onClipEvent handlers?

---

<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:** [February 5, 2003, 8:51pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/9 "2003-02-05T20:51:20Z")

</div>

Who said I still do (although I do sometimes depending on the situation) 😉

Just stating that you can do that and you don’t have to use Dynamic Event Handlers (which I will refer to as DEH) to have a DEH inside a handler.

---

<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:** [February 5, 2003, 8:56pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/10 "2003-02-05T20:56:25Z")

</div>

> Just stating that you can do that and you don’t have to use Dynamic Event Handlers (which I will refer to as DEH) to have a DEH inside a handler.

I got what your trying to say lost.

> But I am sure you knew that Mr. FlashCoderGeniusGuy

I knew what you meant here, lol.

---

<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:** [February 5, 2003, 9:08pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/11 "2003-02-05T21:08:40Z")

</div>

LOL… just stating the truths 😉 🙂

You taught me loadVars… now I love it … genius lol.

Man… thats ashame… I didn’t know loadVars…

(for me thats ashame)

---

<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:** [February 5, 2003, 9:20pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/12 "2003-02-05T21:20:55Z")

</div>

> \*Originally posted by lostinbeta \*  
> **IMr. FlashCoderGeniusGuy**

I actually thought you were stating me as quoted in a negative manner. Anyways, I never thought i taught you Loadvars lost. :bandit:

---

<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:** [February 5, 2003, 9:23pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/13 "2003-02-05T21:23:01Z")

</div>

No, I meant it in a good way…lol. You are a great scripter, especially server-side from what I see.

And yeah, you taught me loadVars and onLoad stuff. Not directly, but from reading your posts I thouroughly understood it and got it working in an instant. I use it all the time now.

loadVariables and loadVariablesNum?? What are they?? LOL 😉

---

<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:** [February 5, 2003, 11:43pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/14 "2003-02-05T23:43:27Z")

</div>

hello,  
thanks for the replies…it seems to have caused quite a conversion.  
anyway, i have attached the actual fla to see if anyone can come up with a solution. i have tried the suggestions that have already been made, but i haven’t had any luck in getting them to work.

i’m sure it will make a bit more sense when you see the fla.  
in the meantime i will continue to find a solution.

thanks again, and look forward to hearing any comments

cheers

---

<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:** [February 6, 2003, 12:35am UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/15 "2003-02-06T00:35:50Z")

</div>

hey janice …

i got this **unexpected file format** error when i try to open your file :-\

---

<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:** [February 6, 2003, 3:21am UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/16 "2003-02-06T03:21:48Z")

</div>

Yes, I recieved that error as well. Try putting it in a .zip file and uploading it. It worked last time someone had a file that did that.

---

<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:** [February 6, 2003, 8:31am UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/17 "2003-02-06T08:31:53Z")

</div>

> \*Originally posted by lostinbeta \*  
> \*\*

```php
onClipEvent (enterFrame) {
	_root.instanceName.onPress = function() {
		//do this
	};
}

```

\*\*  
There’s no point declaring the onPress DEH ( :beam: ) in an enterFrame, Lost 🙂 I think that guig0 wanted to know if you can do

```auto
onClipEvent(enterFrame){
  // blabla
}
on (press){
  // bloblo
}

```

and I believe you can. Test, anybody?

---

<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:** [February 6, 2003, 8:32am UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/18 "2003-02-06T08:32:38Z")

</div>

h88, Lost \>\> Stop spamming! :trout: :trout:

---

<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:** [February 6, 2003, 8:32am UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/19 "2003-02-06T08:32:53Z")

</div>

LOL, I know there is no point to that Ilyas… I blurted out a button handler as fast as I could because I was in a rush, the whole code made no sense anyway, it was just to show something.

And yes, that does work too Ilyas.

---

<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:** [February 6, 2003, 12:29pm UTC](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808/20 "2003-02-06T12:29:38Z")

</div>

i´m not a mac user, and have FMX. :-\

[Next page](https://forum.kirupa.com/t/fmx-clipevents-and-on-handlers/12808.md?page=2)
