• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to limit the area of custom cursor

Explorer ,
Jun 14, 2017 Jun 14, 2017

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

flash cat.PNG

TOPICS
ActionScript

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 23, 2017 Jun 23, 2017

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.

startDrag-script.jpg

Hope that helps!

mark

Votes

Translate

Translate
Community Expert ,
Jun 15, 2017 Jun 15, 2017

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

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 15, 2017 Jun 15, 2017

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2017 Jun 19, 2017

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

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 23, 2017 Jun 23, 2017

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;

  }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 23, 2017 Jun 23, 2017

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.

startDrag-script.jpg

Hope that helps!

mark

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 29, 2017 Jun 29, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 30, 2017 Jun 30, 2017

Copy link to clipboard

Copied

LATEST

Woo HOO! So glad I could help and that you got it working... with the clean easy code!

Good job!

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2017 Jun 19, 2017

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

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines