PDA

View Full Version : [FMX] Scripted movement



DDD
January 25th, 2003, 05:21 PM
I need a little help.....Okay I have a flash movie the canvas is 440x200. Okay I have a graphic which is 880x200 and is centered vertically and horizantally. So some of the movie is off stage. Now what I am trying to make happen is when the mouse is on the left side of movie the movie will move to the right revealing the rest of the movie which is not shown because it is off stage. Likewise if you mouse over the right side the image will move to the left revealing the off stage content. The catch is I do not want it to go beyond the length of the movie. I have spent way too much time trying to get this one. Could someone help me please. Actionscript is really hard for me....Dont know why:q:

rynoe
January 25th, 2003, 05:54 PM
I'm not sure excatly what you are trying to do but:

this.onMouseMove=funtion(){
picture._x =_xmouse;
}

???

lostinbeta
January 25th, 2003, 06:04 PM
As an add on (make your image a movie clip)

onClipEvent(mouseMove) {
this._x =_xmouse;
if (this._x >= howFarYouWantToGoRight) {
this._x = howFarYouWantToGoRIght;
}
if (this._x <= howFarYouWantToGoLeft) {
this._x = howFarYouWantToGoLeft;
}
}

DDD
January 25th, 2003, 06:44 PM
As an add on (make your image a movie clip)


Do I add your code to Rynoes??

rynoe
January 25th, 2003, 06:47 PM
Use lost's code and change the howFarYouWantToGo to the correct numbers

DDD
January 25th, 2003, 06:50 PM
Oh yeah forgot to mention. I was trying to get it to slide to the appropriate side. As an added bonus I would like for it to slide back in its original place when the mouse is no longer there.

By the way lost your code worked, but I forgot to be more clear on what I was after.

Hey Rynoe you need me to explain in greater detail??

lostinbeta
January 25th, 2003, 06:54 PM
Well if I am thinking correctly and your image takes up the whole stage, there is no way to detect if the mouse is off or not. Even hitTest won't work :-\

I might be overlooking something though.

rynoe
January 25th, 2003, 07:08 PM
onClipEvent(mouseMove) {
position=(_xmouse-440)*-1;
this._x = position;
}

since 880 is exactly twice 440

DDD
January 25th, 2003, 07:18 PM
Okay hhhmmmm.... Basically I need to detect if the mouse is on the left or right side of the movie. Image a vertical line going though the horizantal middle f the movie. If the mouse is on the left side of that line slide the movie to the right, If it is on the right side of the line slide my movie to the left. I can picture what I want to happen but I cannot code it. ANd if the mouse is not in the movie at all return it to the middle of the stage.

Oh yeah thanks for the help thus far... I will give credit to you on this little proj....or whoever helps

lostinbeta
January 25th, 2003, 07:24 PM
But see, that is the thing. The clip takes up the whole stage, so by the time your mouse is off the clip it is out of the movie, so it won't be able to be set to go back to the original spot.


You could probably use hitTest to determine if the _xmouse is within a certain contained area.

rynoe
January 25th, 2003, 07:29 PM
ok

onClipEvent(mouseMove) {
if (_xmouse >300) {
this._x = 0;
}
else if(_xmouse<200){
this._x = 440;
else{
this._x=220;
}
}


200 and 300 are estimates

is this what you are looking for?

lostinbeta
January 25th, 2003, 07:32 PM
I came up with this...


onClipEvent(mouseMove) {
if (_root._xmouse<=90 && _root._xmouse>=540 && _root._ymouse<=390 && _root._ymouse>=10) {
trace("in");
} else {
trace("out");
}
};


The above script assumes your movie is 550x400 and sets up a 10px border around your whole movie. If your mouse is inside that border it will trace "in" and if it is outside that border it will trace "out".

DDD
January 25th, 2003, 07:57 PM
Hey lost and rynoe they both did not work. I think maybe my explanation is not good. I dont know how to explain it better. I can visualize it but I cannot program it.

rynoe
January 25th, 2003, 08:44 PM
I tested this and it works for me... I think it might be messing up because of furum so notepad below

DDD
January 26th, 2003, 12:15 AM
Okay rynoe that worked thanks man. And I actually understand the code. Now I am trying to control the speed at which the movie shifts any ideas?

rynoe
January 26th, 2003, 12:19 AM
I KNEW you were gonna ask me that!!!!
yes I have ideas..........
But lostinbeta really has the bead on that one.
It's a math thing check this (http://hurlburts.com/what.html) for an example.

But I am really glad I could help!

lostinbeta
January 26th, 2003, 12:27 AM
You could use the easing formula...

http://www.kirupa.com/developer/mx/followease.asp


(if I am understanding correctly)

DDD
January 26th, 2003, 12:47 AM
I have come to the realization I suck at AS. I have spent the whole day on this simple thing and cannot get it. I think I am gonna give up on it. I am just not getting it. I really hate to keep leanin on folks for knowledge. If one of you have a .fla I can study that would be cool. (or cut and paste)

DDD
January 26th, 2003, 08:38 PM
bump.....i still need help.....pleez......

kode
January 26th, 2003, 09:33 PM
assuming you're image is inside an mc and the registry point is at the middle of the image:


_root.onEnterFrame = function () {
if (_root._xmouse < 220) {
if (_root.imageInstanceName._x < 400) {
_root.imageInstanceName._x += 2
}
} else if (_root._xmouse > 220) {
if (_root.imageInstanceName._x > 40) {
_root.imageInstanceName._x -= 2
}
}
}


[ EDIT ]
forgot the fla

DDD
January 26th, 2003, 09:46 PM
dude that is great that is what I was looking for. I just have on question. How do I get it so it does not move on load. I dont want it to move till the mouseover activates it? Right now it moves automatically.

Thank You very much.

kode
January 26th, 2003, 09:57 PM
like this??

DDD
January 26th, 2003, 10:31 PM
Yep!!!!!!!........You are the bomb....Thanks man!!!!!!!!!

kode
January 26th, 2003, 10:37 PM
anytime =)

and sorry .. i didn't see your thread before
usually i'm stuck in the flash mx section :-\

lostinbeta
January 26th, 2003, 11:38 PM
Thanks for covering this Kax, I wasn't around much today. I went to a super bowl party.

kode
January 26th, 2003, 11:45 PM
no problem lost (-:

i like to help people besides .. i'm always bored :P

DDD
January 27th, 2003, 12:23 AM
oh hey lost thanks man......you helped me also.....I used your snippet for something else. AS is hella hard for me for some damn reason.

lostinbeta
January 27th, 2003, 12:25 AM
Well as I always say....

In flash there are 3 kinds of people

1) The designers
2) The coders
3) People who can do both

If you fall into category 3, you truly are one of the lucky ones.

DDD
January 27th, 2003, 12:42 AM
I am definitely a 1, but I can do other languages like ASP and XML in my sleep.