ActionScript 3.0 :: Mathematically Check If A Point Is Inside A Rotated Rectangle?
Oct 12, 2009
i need to check if a point is within a rotated rectangle. I have to do this mathematically, as none of the objects are on the stage so i can't use hitTestPoint. I know the position and rotation of the rectangle, and if necessary can get the four corners as points as well.
I kind of feel silly asking this, because i am pretty sure it's not a hard thing to do, i just can't work it out and so far any google searches just bring up hitTestPoint.
I have a rectangle of any arbitrary width and height. I know X,Y, width, and height. How do I solve the upper right hand coordinates when the rectangle is rotated N degrees? I realized if it were axis aligned I would simply solve for (x,y+width). Unforunatly this doesn't hold true when I apply a transform matrix on the rectangle to rotate it around its center.
Is there a simple way to take a few square images and set rotationY for each one to be the same degrees, then using an equation line each clip up after the previous one? For some reason the width property of the rotated clips is not lining them up correctly for me. I managed to get the desired result by trial and error (see below), but really need to get an equation for this so I can move the clips around with little hassle.
I'm trying to create a drag-to-select feature. Basically, I'll have several dynamically created mc's and want to be able to click and drag to select several of them at once.I have it so I can drag to draw a square and I have the x/y coords of my mc's. My question is, how do I tell if the x/y coord of the mc is found within the area of the square?
I have a Movieclip (MC1) with and moving object (OBJ1) inside it and using AS3. I want to do a hit test on it with another object (OBJ2) that is on the stage. Normally I would just do MC1.x + OBJ1.x to get my coords for the hit test. But how do I do it if MC1 has been rotated?
I would like to create a rectangle inside of a rectangle, starting approximately 15% inward from the right side of the other rectangle.
I know how to create rectangles with:
Code: var newHotRect:MovieClip = new MovieClip(); newHotRect.graphics.beginFill(0x00FF00); newHotRect.graphics.drawRect(0, 0, 100, 100); addChild(newHotRect);
But how would I make another rectangle on top of that (the black one pictured) that is approximately 15% from the right?
I toyed around with .right, and .bottomright with no success. Can anyone lead me in the right direction? or even finding the x and y of the upper right or bottom right side of a rectangle?
Here's the layout:I have a main SWF. Inside that main SWF is a container MC that has been rotated in 3D space to have a bit of perspective. Inside _that_ container is a container MC into which is loaded various images, videos, and SWFs. Images: no problem. Videos: no problem.The problem:If an SWF is loaded into the media MC that has an MC in it with a listener/startDrag combination allowing that MC to be dragged it seems to fail (the drag).I've tested this child SWF extensively to make sure the drag works, and I've even loaded it externally into other SWFs and it works. I've also tested in various ways to make sure that the problem isn't something simple, like an intervening clip in my main SWF keeping the MouseEvent from reaching the MC with the startDrag
I have two rectangles: var rect1:Rectangle = new Rectangle(66,147,89,67);
var rect2:Rectangle = new Rectangle(155,147,89,67);
How to calculate the centre point of these rectangles based on their x and y positions. I want the centre point to be calculated with relative to stage
I have the following code to create a Sprite with a rectangle in it:
container = new Sprite(); container.graphics.beginFill(0x00CCFF, .5); container.graphics.lineStyle(1, 0x00CCFF);[code].......
The only thing is, I'd like the registration point to be in the middle (not the top left corner). Is there a way to set up the registration point in the middle of the rectangle, but still have the position of the rectangle be correct?
i.e. not moved over so that the top left corner of the rectangle is in the "middle" of where I want the rectangle to be...
I want to make an editor like this site. [URL] If you browse this link you will find "Button. If you press this button you will navigate to a editor to design your layout. After draw a rectangle or circle or line you can resize that or can rotate that. When you finish if press the "you will back to the previous page where your desinged layout display. If you press the "" again then you will navigate the editor with the previously designed layout. I want to make a site like this. I want to use the flash cs4 to make the editor. Anybody knows how to draw a rectangle or circle shape with mouse and how to scale by setting the point and how to rotate by setting the rotation point also by using flash cs4 and as3?.
I need to access the text inside the moieclip.. i am creating a emptymovieclip(name : _root.holder.contentMC) in this i am loading a swf file.. now i am creating another movieclip as _root.holder.contentMC.drawRect1.. the drawrect1 movieclip is used for drawing a rectangle in that swf file.. (for ex: in PDF file we will draw a rectangle to select the text)
problem:now i need to get the text availabgle inside the drwarect1 movieclip.. i dont know how to do this ..
I am building a site with some features of google map. I want to pan, zoom in out a map with tweening effect.But when I zoom the map(Movie clip) it zooms out of the rectangular boundary. I also want to wrap the map(when scrolled). How can I do all these?
Experimenting with adding a square shape inside a rectangle, in the following code, the compiler bounced the error: "Call to a possibly undefined method addChild through a reference with static type flash.display:Shape".
how to limit the region an object can be dragged in if the region is an irregular shape. I've tried with the 'set bounds' command and tried making a shape out of rectangles - but no joy.
I'm wondering how I can create a dynamic rectangle wich has some text in it, the text is dynamic so the rectangle has to adapt to the length of the text. How to approach this?
Given a MovieClip containing a vectorshape (loaded from the library) - is there a way to check whether a line (from point(x1,y2) to point(x2,y2) intersects this shape?
For those of you still with me, I am tasked with making some scrollable content in Flash. Load in a TextFile using LoadURL(), then display it. To get the text, we've written our own class TextFieldExtended, which is basically just there to give the textfile location to the constructor and then have the class do the various steps of getting it and loading it for you.So I needed to get a Scrollbar, which I got hereThe thing is, it works with Sprites.After trying to get it to accept TextFieldExtended, I bumped into a block, since the scrollbar relied heavily on a Sprite property that TextFieldExtended didn't have or could have.
So I tried adding the TextFieldExtended instance to a Sprite instance using addchild.A problem occurs here that I do not know how to handle. It seems that a Rectangle is drawn and the Text is drawn on that. I say this because the scrollbar moves the Rectangle up and down a bit, but the text doesn't scroll, just the Rectangle it is positioned in and the text then moves along with it.My question: can this be fixed, or is does this implementation of scrollbars need a lot of adaptations before this is possible?
draw a shape on the stage, make it into a movieclip, registration point wherever, tl is fine, name it mc, and put his code:
trace(mc.getChildAt(0).y);
now get inside a movieclip and move that shape around (away from registration point) for example above registration point, or wherever and output will always be 0.
is it possible for the same actionscript 2 script to be working if its inside the frames frame frame when you get down to the point where it says LEFT RIGHT UPP DOWN?
I draw a rectangle i should see a little bold circle to indicate a perfect rectangle, I seemed to lost mine, can somebody please tell me how to get it back!
I'm trying to test of a point is inside of a Quadrilateral, as defined by four points.I found some script on another site in another language and tried converting it, but I doesn't seem to work. It might be that I don't understand what their "sign()" method does. I thought it was Math.sin().
I would like to constantly (with an interval) check if the mouse is inside a movieclip or not. I think this should be done with hitTest, but I'm not quite sure how to use it.
I am trying to convert a rectangle(actually multiple rectangles) to a curved rectangle. I think it should be pretty easy but I guess i am stupid. Basically I would have a start position and stop position (many of these), and they would be converted to curved rectangles and follow in a cicrle around.