Copy link to clipboard
Copied
hello, I'd like to limit the area of my custom cursor only inside the rectangle shown below, is it possible? and how is the code? thank you very much
HI!
Glad that you were able to get it to work! Seems a bit complex!
For kicks and giggles ... you can try this
name_of_MC.onPress = function() {
this.startDrag([lockCenter: True], [left: Number], [top: Number], [right: Number], [bottom: Number]) : Void
};
name_of_MC.onRelease = function() {
this.stopDrag();
};
Maybe this image can help explain how you can put in the numbers in the script above.
Hope that helps!
mark
Copy link to clipboard
Copied
Yes, check this out!
OLDER FORMER POST - QUESTION ANSWERED
Can I confine my cursor to a specific area on my stage?
hope that helps!
mark
Copy link to clipboard
Copied
hello headTrix, thanks for your help, the script you suggest was written in as3, I've tried to write in as2, here are my script:
onClipEvent(mouseMove) {
var topNum:Number=200;
if(_xmouse<topNum)
{
brush.enabled=true;
_root.brush._x = _root._xmouse;
_root.brush._y = _root._ymouse;
trace("oke");
}
else
{
brush.enabled=false;
}
}
the trace showed "oke", but the brush still visible all around the stage. where did I get it wrong? thank you
Copy link to clipboard
Copied
hi there,
its a bit tough to sort through code or to test since I only have Animate CC 2017
but for AS2 check out this start drag function
public startDrag([lockCenter: Boolean], [left: Number], [top: Number], [right: Number], [bottom: Number]) : Void
Parameters
lockCenter: Boolean [optional] - A Boolean value that specifies whether the draggable movie clip is locked to the center of the mouse position (true), or locked to the point where the user first clicked the movie clip (false).
left: Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
top: Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
right: Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
bottom: Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
Hope that helps!
mark
Copy link to clipboard
Copied
So many thanks for your response sir
I explored your suggestion but still can't get how to write the syntax in as2.
Then I tried stating the var like the following script, and it works.
Thanks again for your referral
onClipEvent(enterFrame){
var leftBoundary:Number = 147.95;
var rightBoundary:Number = 1053.6;
var topBoundary:Number = 199.95;
var bottomBoundary:Number = 709.75;
if (_root._xmouse > leftBoundary && _root._ymouse > topBoundary && _root._xmouse < rightBoundary && _root._ymouse < bottomBoundary)
{
this._x = _root._xmouse;
this._y = _root._ymouse;
}
else
{
this._x = 788.6;
this._y = 354.9;
}
}
Copy link to clipboard
Copied
HI!
Glad that you were able to get it to work! Seems a bit complex!
For kicks and giggles ... you can try this
name_of_MC.onPress = function() {
this.startDrag([lockCenter: True], [left: Number], [top: Number], [right: Number], [bottom: Number]) : Void
};
name_of_MC.onRelease = function() {
this.stopDrag();
};
Maybe this image can help explain how you can put in the numbers in the script above.
Hope that helps!
mark
Copy link to clipboard
Copied
Thank you so much Sir!
Here is the following script I use as you suggest:
on(press){
startDrag(this, true, 147.95, 199.95, 1053.6, 709.75);
_parent.kuas = true;
}
It works really well, and move "smoothly", way better than the previous one I used.
Copy link to clipboard
Copied
Woo HOO! So glad I could help and that you got it working... with the clean easy code!
Good job!
Copy link to clipboard
Copied
Hi Ratna,
I know its possible, I've done it in Flash Actionscript 1.0, and AS3... its been a while since I've programmed in Actionscript.
But maybe knowing that its possible, and this code can help get you started in the right direction!
function startScroll(e:MouseEvent):void {
var ypos:Number = e.currentTarget.y
var xpos:Number = e.currentTarget.x
e.currentTarget.startDrag(false,new Rectangle(-xpos,ypos,stage.stageWidth,0));
}
something like that!
hope that helps!
mark