Ok, with Mouse.hide(), you don’t need to define that in an onEnterFrame either. Once the mouse is told to hide, it will stay hidden until it is told to show (Mouse.show()). So you can remove the onEnterFrame for that. That is just using up extra CPU usage for no reason.
Ok, and last night I made a mistake, I saw some extra statements in your script that needed to be in the onMouseMove handler.
That would be the “with” code for the bezier and the triangle.
We can create the empty movie clips for them OUTSIDE of the onMouseMove handler because as long as the clips are created int he first place, the code will work, but the clips don’t have to be recreated everytime the mouse moves.
Alright, now for the prototypes.
First lets start with the one that draws your crosshair. That you just have draw a line.
[AS]//create prototype that builds the lines that make the crosshair
//notice the function(x,y) the x and y are parameters
MovieClip.prototype.drawLine = function(x, y) {
this.lineStyle(1, 0x560000, 20);
this.moveTo(0, 0);
//use x, y parameters to say where to line to
this.lineTo(x, y);
};[/AS]
That would be the prototype for the line. You use the parameters x and y to decide where to draw the line to. In your case it would be (0,480) and (640,0) as you had before.
Alright, so how do we use this? Pretty simple, you must first create the clip to use it on, then after the create of the clip we can call the prototype to it.
[AS]_root.createEmptyMovieClip(“vline”, 2).drawLine(0, 480);
_root.createEmptyMovieClip(“hline”, 3).drawLine(640, 0);[/AS]
And that draws your crosshair.
Now to make the prototype for your squares. What we want to achieve in this prototype is the drawing of the square, and then making it draggable. Well you already know how the drawing API works apparently, so I shouldn’t have to explain much in this.
[AS]MovieClip.prototype.buildSquare = function(halfClip, x, y) {
this.lineStyle(1, 0x560000, 100);
this.beginFill(0xFEFEEB, 50);
this.moveTo(-halfClip, -halfClip);
this.lineTo(halfClip, -halfClip);
this.lineTo(halfClip, halfClip);
this.lineTo(-halfClip, halfClip);
this.lineTo(-halfClip, -halfClip);
this.endFill();
this._x = x;
this._y = y;
this.onPress = function() {
this.startDrag();
};
this.onRelease = this.onReleaseOutside=function () {
stopDrag();
};
};[/AS]
halfClip is a parameter that lets you define half of the width of your square, it then takes the halfClip value and builds you a square with a center registration point. Then it moves it to the x and y position according to the x and y parameter. You already know what the onPress, onRelease, and onReleaseOutside do.
We use this code the same way we did with the crosshair. Just make the clip and call the prototype.
[AS]_root.createEmptyMovieClip(“A”, 5).buildSquare(10, 100, 100);
_root.createEmptyMovieClip(“B”, 6).buildSquare(10, 200, 200);
_root.createEmptyMovieClip(“C”, 7).buildSquare(10, 300, 300);[/AS]
This builds 3 clips, which are 3 seperate squares that are 20x20 px (10 is the halfClip, which is half of the width). After the clips are made the are positioned according to the x and y parameters (100,100) for the first clip for example.
Then we create your bezier and triangle clips, you already know how to do that, but I will put it anyway…
[AS]_root.createEmptyMovieClip(“triangle”, 8);
_root.createEmptyMovieClip(“bezier”, 9);[/AS]
And this is now your onMouseMove statement. It updates the vlaues of your textbox, your triangle clip, and your bezier curve.
[AS]_root.onMouseMove = function() {
_root.vline._x = _root._xmouse;
_root.hline._y = _root._ymouse;
_root.val.text = Math.round(_root._xmouse)+","+Math.round(_root._ymouse);
//didn’t create prototype for this because it is used only once
with (_root.triangle) {
clear();
lineStyle(1, 0x560000, 20);
moveTo(_root.A._x, _root.A._y);
lineTo(_root.B._x, _root.B._y);
lineTo(_root.C._x, _root.C._y);
lineTo(_root.A._x, _root.A._y);
}
//didn’t create prototype for this for same reason
with (_root.bezier) {
clear();
lineStyle(1, 0x560000, 20);
moveTo(_root.A._x, _root.A._y);
curveTo(_root.C._x, _root.C._y, _root.B._x, _root.B._y);
}
//since these values are within the onMouseMovie handler
//they will be updated everytime the mouse moves
};[/AS]
The rest of your code can stay the same.