-
The G5 SP
stopDrag()
I have
code:
if(_parent._currentframe>74){
if( _parent._ymouse > 40 && _parent._ymouse < 271 && _parent._xmouse > 25 && _parent._xmouse < 260){
startDrag(_parent.arrows, true);
Mouse.hide();
}else{
_parent.arrows.stopDrag()
_parent.arrows.ease(144,75,6);
Mouse.show();
}
}
}
This is not where my problem is...
i have a scroll bar over to the right and the drag on the bar will not work if there is a drag in this code....
I dont really understand, cause I have a direct path for the stopDrag(), but it is still causeing the scroll bars drag not to work.....
That is my problem.....
HELP !
-
The G5 SP
Basically, I need to know how to make sure that the drag can work for the arrows, but when it shut off it can work for the scroll bar.
-
I am not sure I understad exactly what problem you are having. But I'd suggest you use
Code:
_parent.arrows.startDrag(true);
That is, use movieclip methods for start and stop drag. Don't use global function to start the drag, and movieclip method to stop it.
This may or may not solve the problem. If it doesn't, you might want to post a simplified .fla illustrating the problem.
Unless otherwise specified, all code goes in Frame 1 of main timeline. FlashGizmo.com
-
The G5 SP
I tried that too.....no good.
I now have
code:
_parent.arrows._x=_parent._xmouse _parent.arrows._y=_parent._ymouse
in stead of startDrag
This is giving a weird result.
Is there a good way to do this?
-
If I understand what you're trying to do, you want a movie clip called "arrows" to follow the mouse, but only when the mouse is in a certain area.
Here's how I would do that:
Make a movie clip with instance name "dragArea." Give it a visible shape (you can make it invisible if you don't want to see it).
Put both "dragArea" and "arrows" in _level0.
On Frame 1 of the main timeline, put code something like this code:
code:
_global.followMouse = function() {
this._x = this._parent._xmouse;
this._y = this._parent._ymouse;
updateAfterEvent();
}
dragArea.onRollOver = function() {
arrows.onMouseMove = _global.followMouse;
}
dragArea.onRollOut = dragArea.onDragOut = function() {
arrows.onMouseMove = null;
}
This will not interfere with anything that goes on when the mouse is outside of dragArea.
Unless otherwise specified, all code goes in Frame 1 of main timeline. FlashGizmo.com
-
The G5 SP
Only one problem with that.
In that same area, a scrolling PIC MC thing moves when you roll into the area, the pics are buttons, so if a on rollover event is called, then the buttons wont work.
and what does the update part do?
Last edited by N_R_D; 11-22-2004 at 01:47 PM.
-
so you can use a hitTest() on the drag area:
if (this.hitTest(dragArea))//actions
gparis
-
The G5 SP
So the hit test works like a button rollover with out actually being a button rollover?
How cool !
-
The G5 SP
So the hit test works like a button rollover with out actually being a button rollover?
How cool !
But how can I do it where it sees what the mouse location is over the hitarea?
And what does the update part of the other code do?
-
updateAfterEvent(); is better with mouseMove events. The animation gets smoother.
Now the hitTest() ensures your mouse is over the Movieclip dragArea. (you can check in the AS dictionnary for more info on that method)
gparis
-
The G5 SP
It is better than what, delete?
-
let's say, 'best used with'
gparis
-
The G5 SP
Cool man cool...
I have an issue now.
For some reason, the cursor that is being dragged, does not stay locked on the mouse.
It will not go all the way to the bottom of the dragArea.
I have
code:
//--on The main Time line
MovieClip.prototype.followMouse = function()
{
arrows._x=_root._xmouse
arrows._y=_root._ymouse
updateAfterEvent();
}
//--on a MC that controlls the whole thing
if(_parent.dragArea.hitTest( _root._xmouse, _root._ymouse, true)){
followMouse()
Mouse.hide();
-
You have no event to loop the action? I see the updateAfterEvent() but that method is supposed to work in conjonction with a mouseMove event. Or you're only showing a partial code?
edit. Ok I will assume your post was cut (as your actions have syntax errors if finished like that)
You meant this?:
code: onClipEvent (mouseMove) {
if (_parent.dragArea.hitTest(_root._xmouse, _root._ymouse, true)) {
followMouse();
Mouse.hide();
} else {
Mouse.show();
}
}
gparis
Last edited by gparis; 11-22-2004 at 03:44 PM.
-
The G5 SP
It was a partial code, but it is ok now, I got it.....
One more question.
on a prototype, just to clarify, it still is pathed from the time line right...
if I have a button
_root -> MC1 -> MC2 -> Button
and I had a prototpye on the main time line called by the button.
Does the path act like the code is on the button or the main time line.
And is it possible to have the path change
so if there is no path does it assume that the path starts on the main time line, and if there is, like "this" does it make the path where the prototype was called?
I am just curious, I really dig prototypes, and want to make sure i am using them to the fullest.
-
Prototypes are just new methods added to the MovieClip class. If you enjoy them, I would assume you know this site:
http://proto.layer51.com/l.aspx?p=1
Usually relative targets are used (this, _parent etc..) and parameters : function(param1,param2,ect)
so you can use and re-use the prototype for any movieclip nested or not, and so the function can adapt to its position in your architecture.
I actually made a little prototype based on your idea, that takes in consideration the fact that you may want the object to stay 'inside the drag Area. It works with the parameters as the bounds of the area (l;left, r:right,u:up and d:down), and sets them into an array.
Here it is:
code: MovieClip.prototype.dragMe = function(l,r,u,d) {
this.bounds = {left:l+(this._width/2), right:r-(this._width/2), up:u+(this._height/2), down:d-(this._height/2)};
this.onMouseDown = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.onEnterFrame = function() {
this._x=_root._xmouse;
this._y=_root._ymouse;
if (this._x<=this.bounds.left) {
this._x = this.bounds.left;
} else if (this._x>=this.bounds.right) {
this._x = this.bounds.right;
}
if (this._y<=this.bounds.up) {
this._y = this.bounds.up;
} else if (this._y>=this.bounds.down) {
this._y = this.bounds.down;
}
};
}
};
this.onMouseUp = function() {
this.onEnterFrame = null;
};
};
//call with:
this.arrows.dragMe(20,320,20,320);
enjoy
gparis
-
The G5 SP
whoa !
How cool man !
Thanks GParis !
-
The G5 SP
Ok so...
if I have
code:
MovieClip.prototype.followMouse = function()
{
arrows._x=_xmouse
arrows._y=_ymouse
updateAfterEvent();
}
on a Mc, that is on the main time line.
and "arrows" is also on the main time line.
why wouldnt it have to be
code:
MovieClip.prototype.followMouse = function()
{
_parent.arrows._x=_parent._xmouse
_parent.arrows._y=_parent._ymouse
updateAfterEvent();
}
-
it doesn't have to be. Unless you want to re-use the function for other MCs. And i doubt it, as the only action is clearly directed to the mc arrows.
I would change it to give it more usability to:
MovieClip.prototype.followMouse = function(clip)
{
clip._x=_xmouse
clip._y=_ymouse
updateAfterEvent();
}
the updateAfterEvent(); suggested this function has to be called on a mouseMove event. Really it is very restricted for a prototype! ;-)
You would then call it like:
followMouse(arrows);
or
followMouse(someOtherClip);
gparis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|