PDA

View Full Version : 'Fmx'...ClipEvents and On handlers



janice
February 4th, 2003, 06:32 PM
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

SteveD
February 5th, 2003, 07:15 AM
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

pom
February 5th, 2003, 11:53 AM
Since you're working with MX, you can put button handlers as well on the clip. No problem :)

Guig0
February 5th, 2003, 11:58 AM
but you canīt put clip handlers and button handlers together. am i right pom?

h88
February 5th, 2003, 12:25 PM
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.

Guig0
February 5th, 2003, 01:28 PM
i didnīt mean that there is no way you can do such thing, and did you read the word...


together ??


:P

and.. functions are not normal handlers ;)
but thanks for the code anyways =)

lostinbeta
February 5th, 2003, 02:33 PM
h88 was using Dynamic Event Handlers ;) Which are technically functions, but are also handlers :)

And h88, you can also do...


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

h88
February 5th, 2003, 03:44 PM
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?

lostinbeta
February 5th, 2003, 03:51 PM
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.

h88
February 5th, 2003, 03:56 PM
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.

lostinbeta
February 5th, 2003, 04:08 PM
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)

h88
February 5th, 2003, 04:20 PM
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:

lostinbeta
February 5th, 2003, 04:23 PM
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 ;)

janice
February 5th, 2003, 06:43 PM
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

kode
February 5th, 2003, 07:35 PM
hey janice ..

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

lostinbeta
February 5th, 2003, 10:21 PM
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.

pom
February 6th, 2003, 03:31 AM
Originally posted by lostinbeta

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
onClipEvent(enterFrame){
// blabla
}
on (press){
// bloblo
}and I believe you can. Test, anybody?

pom
February 6th, 2003, 03:32 AM
h88, Lost >> Stop spamming! :trout: :trout:

lostinbeta
February 6th, 2003, 03:32 AM
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.

Guig0
February 6th, 2003, 07:29 AM
iīm not a mac user, and have FMX. :-\

janice
February 6th, 2003, 07:48 AM
sorry about that....this one should work ok.

kode
February 6th, 2003, 08:00 AM
i see your problem ..

you're exporting your swf as flash 5
mouse events in movie clips are not supported in flash 5

export it as flash 6 and you shouldn't have any probs :)

Guig0
February 6th, 2003, 08:10 AM
Originally posted by ilyaslamasse
There's no point declaring the onPress DEH ( :beam: ) in an enterFrame, Lost :) I think that guig0 wanted to know if you can do
onClipEvent(enterFrame){
// blabla
}
on (press){
// bloblo
}and I believe you can. Test, anybody?
Youīre right and wrong (-:

yep, that was my question. and i tested and it dindīt work :-\

pom
February 6th, 2003, 08:14 AM
Ya sure? I'm surprised. :phil: I'll check that tonight.

kode
February 6th, 2003, 08:17 AM
what if i say that it works for me ?? :sleep:

Guig0
February 6th, 2003, 08:20 AM
no, i was wrong. it works!

i never did something like that, so when i came to this thread it got me thinking, i tried and didnīt worked, but must have been a syntax error :-\

kode
February 6th, 2003, 08:24 AM
lol :P i knew you did something wrong !! ;)

Guig0
February 6th, 2003, 08:29 AM
janice: i still donīt get what you want to do.


you want to use the button N.1 to trigger some script? to load a movie? what??

kode
February 6th, 2003, 08:40 AM
if she wants to load a movie or something like that with it ..
i assume she wants to use onPress and/or onRelease handlers in the mc ...

that's why i told her to export the swf as flash 6


am i wrong ?? :crazy:
[ hmmm .. you got me thinking guigo :sleep: ]

Guig0
February 6th, 2003, 08:44 AM
doesn know how to put that code on the button:


on (press){
loadMovieNum ("movie.swf", 1);
}


it must be something more, kax :-\

kode
February 6th, 2003, 08:47 AM
i must be wrong then :+) :P

janice
February 6th, 2003, 09:41 AM
thanks very much...it was a publishing thing.
i feel very silly to have overlooked that, but it seemed to give people food for thought.

thanks again.....i'm sure i'll be back with another problem soon, hopefully not as foolish as the last one.

cheers

Guig0
February 6th, 2003, 09:46 AM
=)

kode
February 6th, 2003, 09:52 AM
haha .. i was right after all :)