Ive tried this but can seem to get it to work properly and im fed up.
What i want is i have a mc which at this point is stationary, and the mouse pointer which moves around the screen. What i want is for their to be a line drawn between the 2 objects. I want it to rotate according to where the mouse is on the screen and also strech and shrink according to the distance between the 2 objects.
If anyone could maybe provide a fla with some comments in it to help me out i would appretiate it alot.
Sorry, i did this when i saw your post, but never got chance to post it as i'm in the middle of exams
It's not the most efficient/best way of doing it, but it should give you an idea of where to go... no comment tags sorry, but it's pretty self explanatory.
By the way, i did this in MX using the dynamic drawing stuff. Hope you dont want it in flash 5. Possible, sure, but a bit more complicated.
I tried it agian man and it worked so thanks heaps its exactly what i wanted. Havent looked at the code yet but be prepared to answer some questions when i have a look
One more quick question. Dunno if you can help me on this. But ill ask ne way. What i want is that onmouse down move a Ball movie clip from the original movie clip in the direction of the line
I've done a fairly siply example of what (I think) you're looking for. Copy the below code into the original file, not changed anything to it, only added.
Code:
_root.onMouseDown = function()
{
var speed = 5;
// attach & position ball to mc...
var a = _root.attachMovie("ball", "ball", 2);
a._x = _root.mc._x;
a._y = _root.mc._y;
// which direction it goes...
a.x = (_root._xmouse - _root.mc._x)/speed;
a.y = (_root._ymouse - _root.mc._y)/speed;
a.onEnterFrame = function()
{
// move it...
this._x += this.x;
this._y += this.y;
// remove if off screen...
if (this._x > Stage.width || this._x < 0 || this._y < 0 || this._y > Stage.height) {
this.removeMovieClip();
}
};
};
(Hope this comes out nce with the new colour code tags )
All you have to do is make an mc with a linkage name of "ball".
There can be only one ball on the screenat a time with this, clicking again when there's already a ball on the screen will replace it with a new one. Also, the way i've done it maens that the ball will go faster the longer the line, as to indicate the strength, if you like, of the force. IT also doesn't stop to where the mouse was, just keeps going to edge of screen.
well, of course functions are best for multiple use, that's great that you do that. But another thing they're good for is when you want a block of code to run. You don't want the "end screen" codes to run when the movie first plays, so you can put them in a function, and call them when they are needed. Of course, if you've got them all on different frames, then you probably won't need to do that. But i always try to code on a single frame if i can. Mostly for games, so no-one can cheat by clicking play, and going to next frame he he.
restricted line length
well, this was a bit tougher than i first though. So much so, i had to sleep on it. Turned out quite good though i think. There's a fair bit of code changes, so i'll just attach the file again. It's fairly easy to understand if you know a bit of basic of trig.
if (line too long) {
shorten it to the max length;
} else {
don't bother - it's fine!;
}
stuff like that. Trig comes in when you want to shorten it to max length. Change length with variable linelength. That's basically it.
What is it you're using it for anyway? Would like to know. Good luck!
Cause you can just do that with a button instead of a script =)
just oppinion
I can only postulate the probability of performing at a paramount level of perfection praised by the pulchritudinous paragon whose only practice is to preserve such a paradigm.
i think hooligan maybe meant restrict it in the 270 -> 360 quadrant. (9 o'clock to 12 o'clcok only) ???
You would only need to use the "endx = mcx-linelength*Math.cos(angle);" lines (the one's with negative signs) if you wanted to do that, because the "+" ones are for the right hand side of the circle. But yeah, same theory, just another if statement should do it.
Have a go, see what you can do. I'll not post code, you should be able to do this Practicing is the best way to learn. Will still help on anything more if you can't, of course.
I wish i could have helped more but i dont have mx =(
I can only postulate the probability of performing at a paramount level of perfection praised by the pulchritudinous paragon whose only practice is to preserve such a paradigm.