How to limit the movement of my mc?

I have a clip moving randomly... but I have a limit or a border on his movement...

the problem is... the bondary is a round box and I do not know how to calculate the area...

is it possible to make a script that says... within this certain object, they will move randomly...

from now on, this is my code:

var speed: Number = 4;                                             This object should not go beyond the limit
object_mc.onEnterFrame = function() {}
If (Key.isDown (Key.RIGHT)) {}
This ._x = this ._x + speed;
} Else if (Key.isDown (Key.LEFT)) {}
This ._x = this ._x-speed;
}
If (Key.isDown (Key.UP)) {}
This ._y = this ._y-speed;
} Else if (Key.isDown (Key.DOWN)) {}
This ._y = this ._y + speed;
}
};

//////////////////////////////////////////////////////////////////////////////////////
function getdistance (x, y, x 1, y1) {//and so that it
var run mounted.
Run = x 1-x;
place = y1 - y;
Return (_root.hyp (walking, mounted)) End Function
}
hyp (a, b) function {}
return (Math.sqrt (a * a + b * b));
}
MovieClip.prototype.reset = function() {}
Specify the width and height of the movie
width = 650;
height = 488;
//-------------------
var dist, norm;
This.x = this ._x;
This.y = this ._y;
This.Speed = Math.random () * 4 + 2;
This.targx = Math.random () * width;
This.Targy = Math.random () * height;
Dist = _root.getdistance (this.x, this.y, this.targx, this.targy);
Norm = this.speed/dist;
This.diffx = (this.targx - this.x) * norm;
This.Diffy = (this.targy - this.y) * norm;
};
MovieClip.prototype.move = function() {}
If (_root.getdistance (this.x, this.y, this.targx, this.targy) > this.speed) {}
This.x += this.diffx;
This.y += this.diffy;
} else {}
This.x = this.targx;
This.y = this.targy;
If (! this.t) {}
This.t = getTimer();
}
If (getTimer () - this.t > 1000) {}
This.Reset ();
This.t = 0;
}
}
This ._x = this.x;
This ._y = this.y;
};
//////////////////////////////////////////////////////////////////////////////////////
Stop();

you defined r, centerX and centerY variables?  If so, show your code.

Tags: Adobe Animate

Similar Questions

  • How to restrict the movement of movieclip on the stage?

    Hi, I want to spend my movieclip to the left and right, but he moves out of the scene. I want to restrict the movement of X the width of my step.

    This is my code for the movement of movieclip:

    import flash.events.KeyboardEvent;

    stage.addEventListener (KeyboardEvent.KEY_DOWN, moveavatar);

    function moveavatar (event: KeyboardEvent): void

    {

    If (event.keyCode is 39)

    {

    avatarmove.x += 10;

    }

    Else if (event.keyCode == 37)

    {

    avatarmove.x = 10;

    }

    }

    How do I limit the movement of X the width of my step so it won't leave the stage? Thank you.

    You have the registration point in the upper left corner. In my case, I had to focus. If you want to keep as you have, replace with this:

    import flash.events.KeyboardEvent;

    stage.addEventListener (KeyboardEvent.KEY_DOWN, moveavatar);

    function moveavatar(event: KeyboardEvent): void {}

    avatarmove.x = Math.max (0, Math.min (stage.stageWidth - avatarmove.width, avatarmove.x - int(event.keyCode==37) * 10 + int(event.keyCode==39) * 10))

    }

  • Limit the movements of the mouse in Authorware

    Hi all


    I try to limit the movements of the mouse of a user in Authorware. So far, I was able to do something that changes the cursor when it is over a square (mobile area). However, I missed out yet how to limit the mouse to go outside the edge of the square. Thinking has been to follow the point where the user has left the square with the cursor and set CursorX and CursorY to these values. However, these system variables cannot set a value, read only (AFAIK). Did anyone have any suggestions?

    Kind regards

    Frank

    Cannot be done with Authorware alone...

    Easy solution - use the SetCursor function to hide the mouse (4) when he leaves the defined area, set it to the arrow (0) when he enters. Don't forget to put the arrow, so when you leave the page otherwise.

    More difficult, but what you need – load the SetCursorPos of WinAPI.u32 function that allows you to actually set the cursor position... then as above, when the cursor leaves the area defined, to put back...

    Help?

    Erik

  • How to limit the rotation?

    I do a little fake level indicator I want the pointer to rotate according to the movement of the pointer. I have a clip and have attached the code below.
    Things seem to work ok, but I can't limit the movement on the negative side, how to tell +-60 breast and tell if / else statement? I tried to add a separate statement for - 60, and he did the all unusable.

    Thank you

    Try it like this. (I have not tested because I don't have handy Flash, but I think that it should work).

    Whenever you call the function, it must call a variable (I called it needleRotation). Then the function must first check if the variable is out of your limits or 60-60. Finally, if this isn't out of bounds, then the needle turns to the appropriate amount.

    I would like to know if it works. If this isn't the case, I apologize.

  • How to limit the length of the texts on iOS9?

    Hello

    I just worked on why I am required by my mobile / cell phone provider EA.  They charge any text as a picture message / SMS, it is longer than 120 characters?  Does anyone know how to limit the length of the texts / SMS so that it is impossible to send a more 120 characters or create an alert so that you are aware of the number of characters in the text / sms?

    Thank you very much

    Hello Turnus123,

    Thank you for using communities of Apple Support.

    I see that you will have to pay for SMS more than 120 characters.  To help identify messages exceeds this amount, you can activate a number of characters in the message settings.  Simply go to settings > Messages and activate "number of characters".

    Message settings

    Take care.

  • Photo constantly order of photos in a slideshow changes no matter how many times the movements of the user the photo back to the good look at an order. Example: Bathroom Plans eventually grouped with pictures of kitchen! I have found no way to stop this o

    Apple Photo 1.3 serious problems - how can I SOLVE all these problems?

    (1) breaks down without rhyme or reason no matter where I am in the workflow.

    (2) pictures will not be Shut Down Every Time, even after several days of waiting.

    (3) aPhoto frequently badly chooses picture in the EDIT picture option, I get a picture different than the one I clicked on which is on a 100 pictures in a row.

    (4) picture constantly order of photos in a slideshow changes no matter how many times the movements of the end user the photo back to the good look at an order. Example: Bathroom Plans eventually grouped with pictures of kitchen! I have found no way to stop this weird behavior! Is there a way to stop this? If I drag the photo again some 7 additional photos in the slide show, after a minute or less, he appears again to where it was it not. !@#$%$#

    (5) If you make any CHANGES to a photo, it often changes the appearance of your complete slideshow of this picture with impatience. So you lose all this not work fix your configuration of the slide show. Even changing the order of photos once more that I had put back where they should be. !@#$$#@

    (6) photo identifies often shades of lamps and long door handles as the faces of the people.

    (7) photo made bad decisions when it comes to brightness, contrast and colors effortlessly around other than to use other software, where as with iPhoto there was a lot of workarounds. I could continue, but will save one who might be reading of this.

    I am up to date on all updates for my Mac. If anyone have REAL answers so please spilling the beans, but according to me, it's the only truth is that Apple has rolled out a product inferrer to replace an exceptional product, called iPhoto, which does not work on my new iMac computer 5K of 27 ".   If I knew what I would have chosen another computer that I use iPhoto to prepare more of fifty to sixty thousand photos in a given year and I use iPhoto to make hundreds of slideshows from it.  Are there plugins for Photo 1.3? I ask because I see where there could be Add-ons, but I can't find.

    Apple has taken a serious decision by turning his back to iPhoto and tens of millions of loyal users.

    Thanks in advance to anyone brave enough to tackle this job.

    James

    First, back up your library of Photos and hold down the command and option keys while launching Photos - repair your database - you have a corrupted database

    LN

  • I have a new time capsule airport. How to limit the search for who can use the time capsule backup process?

    I have a new time capsule airport. How to limit the search for who can use the time capsule backup process?

    Set a password to disk... disk tab in the utility... and just give to those you want to use the TC...

  • How to limit the media sharing on my computer

    Original title: multimedia file sharing...

    How to limit the sharing on my computer, IE multimedia: music, images and other files from other computers on the network or cell phones that are capable of DLNA?

    Hello

     
    Please check the links given and see if they help.
  • How to limit the email receipt/downloaded size?

    I need information on how to limit the size of an email received or downloaded in Windows Mail to reduce the cost of the enamel of satellite data. Want to just send and receive, especially to receive emails with no graphics and keep it small.

    Simply set up for this purpose a message rule: tools, Message rules, mail, new...
     
    Gary van, Microsoft MVP (Mail)
    ------------------------------------------------------

    "moosehuntingguy" wrote in the new message: * e-mail address is removed from the privacy... *
    I need information on how to limit the size of an email received or downloaded in Windows Mail to reduce the cost of the enamel of satellite data. Want to just send and receive, especially to receive emails with no graphics and keep it small.

    Gary van, MVP (Mail)

  • How to limit the number of printers can be installed on this computer by using Group Policy?

    How to limit the number of printers can be installed on this computer by using Group Policy?

    Hello

    Thanks for asking! If I understand correctly, you should limit the printers installed on the computer by using Group Policy. I suggest you follow the troubleshooting steps to check if this may help.

    The question you have posted is related to Technet and would be better suited to the Technet community. Please visit the link below to find a community that will provide the best support.
    http://social.technet.Microsoft.com/forums/en-us/category/WindowsServer

  • Does anyone know how to use the movement of scroller with the function of the fluid width?

    Hi all

    Does anyone know how to use the movement of scroller with the function of the fluid width?

    Thanks, Federico

    This feature is not yet implemented.

  • How to control the movement of the oam in muse & just play once the proposal?

    How to control the movement of the oam in muse & just play once the proposal?

    This must be configured during the creation of the oam, no Muse, but the animated application you use.

    Thank you

    Sanjit

  • How to activate the movement

    How to activate the movement on exsi 5.0

    Access your network, choose your vSwitch0 and click Properties. Click the network management, change and check the box of vMotion. Make sure you have same exchanges on both hosts. Right-click on a virtual machine and choose migrate and select destination host.

  • If I don't get creative cloud, how will limit the use of photoshop touch?

    If I don't get creative cloud, how will limit the use of photoshop touch?

    I don't think it will limit your work with PS Touch, but could enahnce it a little.

    Just try to free membership of 2 GB and find out:

    https://creative.Adobe.com/plans

    Thank you!

  • How to limit the number of connection to DB

    Hello

    I just go to the topic of connection pooling.
    Here, I would like to understand the number of details of connections that already exists in the database.

    Kindly guide me to know the following details.

    How to know the number of connections available in the database?
    How to limit the number of connections?

    V_$ Resource_Limit contains details of the sessions. Is this even for connections?

    I have more clarification on the difference of connections and Sessions.

    Kindly tell me the above.

    Thank you
    Orahar.

    Orahar wrote:
    Hello

    I just go to the topic of connection pooling.
    Here, I would like to understand the number of details of connections that already exists in the database.

    Kindly guide me to know the following details.

    How to know the number of connections available in the database?

    The number of currently active sessions (db, internal sessions registered)

    SELECT COUNT (*)
    SESSION $ v

    How to limit the number of connections?

    to increase or decrease the maximum number of connections:

    for example: change processes control system = 200 scope = spfile;

    >

    V_$ Resource_Limit contains details of the sessions. Is this even for connections?

    I have more clarification on the difference of connections and Sessions.

    Connection means a user process is successfully connected to the listener to have a session on the database running instance. (listener who listen s new connection requests)
    Establish sessions: means, a (dedicated) server process began to serve a user process. It is done when the credentials of the user authenticated successfully. Now, from process-user shall communicate to the server process directly.

    hope that helps.

    Kind regards
    X.

Maybe you are looking for

  • problem of aht in 5.1

    I can't get AHT to run with keys so I decided to try to make a boot usb AHT l http://rivenbyfive.blogspot.com/2012/01/download-and-run-apple-hardware-test.htm drive subsequently My OS is 10.11.5. Can I use two initials command sets without difficulty

  • Broken hp compaq Presario CQ57

    Hello I just broke my phone, I think. It does not react when I press the button or when I put in the charger. He had a few problems with this charger because it has overheated, so we have already ordered a new (still in waiting for him). Until we get

  • Restore the ability to fax for HP OfficeJet J6480 Cougar (or Lion)

    Once he was once, in a very beautiful land ruled by snow leopards, I had my HP OfficeJet J6480 installed twice - a queue as a printer and a queue by fax.  I rarely used the fax, and somewhere along the line between SL and Lion Mountain Lion, the queu

  • BlackBerry Smartphones email works, but not with BlackBerry

    Hello world I came across a rather strange problem, after some extensive research, I can't find any solution so I came here to ask if anyone can provide all the answers to this. I have my own email [field] and it works great, reception/sending emails

  • Some feature ISE questions

    Hello guys,. I am relatively new to the ISE and would like to get some answers on the features and the administration, I could not find in the documentation. Would be great if you could help me :-). 1. I would use MAB to printers and other devices of