It’s been a while since I have visited this site. I would like to say “HI” to all the Flash Helpers around Now, I’m back again with a few questions about How To’s in Flash
Problem:
I wanted to make an MC that can be dragged only from LEFT to RIGHT with a little ease on it. I was trying to look for some tutorials in this site but unfortunately wasn’t able to find one close to what I had in mind.
there are other parameters to startDrag, that “draws” a box where you can move around the movieclip, check out those, I don’t have flash here at the moment…
Assuming that you have a MC named myMC and that you don’t want it to slide more than 400px or less than 0px on the X (relative to the Stage’s X).
You can add easing and such, and you’ll probably need to change the instance name of the movie clip and whatever bounds you want set, but I think that should help you on your way.
I used a setInterval just because startDrag did not offer enough flexibility. You can change the setInterval interval timing also, if you don’t want to burn CPU power (though it’s not exactly CPU-intensive sliding a MC along the X with a few if-then’s tossed in).
You might also play around with registration points to get the true slide bounds you’re going for.
Hello KENNY, I tried to use your AS. Got weird results. Here, im attaching the file.
Everytime I attempted to drag my MC, it would jump, something like that. I tried to play around with the REGISTRY POINT and yet came up with no solution.
The sliding is very nice for me already. I just want to ask why whenever you click on the MOVIE CLIP, it would jump to the CENTER MC with regards to it’s Registry Point then start to drag. Anyway of fixing this?
Calculate the difference between xmouse and your MC’s X. Then add/subtract from your MC’s X depending on the value of the difference between your MC’s X and xmouse.