ActionScript 2.0 :: Drawing A Rounded Rectangle At Runtime?
Oct 25, 2005
I've seen a few tutorials on this site that discuss the Drawing API, What I'm wanting to do is draw a rounded rectangle at runtime to a particular size.I initially tried resizing an already-created rectangle, but as the movie clip resized, the radius on the corners got distorted.
I would like to tween between a short rounded rectangle and a tall rounded rectangle. (I only want deal with the height - no other parameters). I am programming with ActionScript 3. My tweening engine is TweenLite.I have been tweening a sprite that contains a rounded rectangle. The tweened sprite produces distortion. I suppose that I have been scaling the original image, rather than the height of the rounded rectangle?Here is a simple example of my code:
Draw the rounded rectangle:
roundRect = new Sprite();roundRect.graphics.beginFill(0x000000);roundRect.graphics.drawRoundRect(0,0,50,15,4,4); //Original Height: 15roundRect.graphics.endFill();addChild(roundRect);
Then I listen for a mouse click event on the rounded rectangle.The mouse event triggers a function with the following code:
I'm trying to get plain straight corners on a rectangel. I have been drawing a rectangle or even before drawing one, selecting the little tool in the lower left and I put in a value of 0, but as soon as I draw anything it rounds up again. How do I get rid of this problem??
I'm trying to achieve a roundedRectangle in gradient by using just code but i'm getting stuck.I was able to achieve the gradient part but adding the rounded piece its difficult, please see me code,
create a method for drawing rectangle with rounded corners, but while being able to specify which of the four corners (any, all, none,etc.) you wanted to round.The method below does the trick, but for some reason my corners don't match the same curves that I get using the same radius with drawRoundRect().
In other words, if I call my method (and set all four corners to be rounded) and compare that with the same call to drawRoundRect() the actual curves of the corners are slightly different.
HTML Code: public function drawComplexRoundedRect(startX:int,startY:int,rectWidth:int,rectHeight:int,radius:int,canvas:Sprite,roundTopLeft:Boolean=false,roundTopRight:Boolean=false,roundBottomLeft:Boolean=false,roundBottomRight:Boolean=false):void{
How can I create a rounded rectangle with a dashed line? I've seen several routines that draw their own straight lines, but nothing for rounded rectangles.
i have been tasked to create a rollover state that has dynamic irregular shapes that surround the movieclip target. The target is always a rectangle and the shapes will look roughly like:I think i will have to draw this old school without using the easy predfined shape classes. I first thought about doing two rounded rectangles to fake it, but the line cross over (pointing green arrow) will overlap. Anyone have ideas on how to approach this? If i go with the drawing api, is there a formula to working out the rounded curveTo angles on the corners to always be the same radius?
I would like to have an invisible drop target so I can dropand item and have it go to another part of the training. However,if I create a rectangle as a sprite and don't fill it in, itdoesn't recognize it as an area apparently because nothing happenswithout a fill color. I tried just a regular rectangle, shape, etc.
I'm trying to draw a rectangle with my mouse using actionscript. I found a script online for elispes. I used that and it worked just fine. But when I change it to a rectangle, it doesn't work.
Code: var color:Number; stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing); stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
I'm trying to create a rectangular mask - located at x:0, y:173 (1 pixel high ) - that will be stretched (_yscale) to the bottom of the image using the Flash Tween Class. Trouble is, the entire rectangle moves as if if were using "_y" instead of "_yscale". Tweening "_height" doesn't work any better. Can someone spot the problem with this file? If you comment out this line
var mask_tween:Object = new Tween(maskClip, "_yscale", Strong.easeOut, 0, 100, 1, true);
then you will see the correct placement of the mask rectangle. It just doesn't tween/scale properly.
public function onMouseDownHandler(e:MouseEvent) { //trace("mouse down clicked!");
[Code]....
I am drawing a rectangle with the above code in as3 inside a area. Problem is that, when i try to acees the drawn rectangle x and y position it is showing 0,0. if i drag the drawn rectangle and try to access the x and y position then also it is calculating from the 0,0 position. first time when i draw the rectangle it is drawing well by dragging the mouse but why the x and y axis is 0,0; if i try to set the x and y position manually then when i try to draw by dragging , it is not drawing relative with the mouse.
I have two options and I want to know whats faster. I have a pool of 1000 sprites objects in as3 on screen. When its needed each sprite has to resize itself. I can 1- Make each sprite a simple container to use graphics to draw a rectangle, that is, call a 'spriteInstance.graphics.' ,draw the rectangle and on each 'refresh', I do graphics.clear and redraw the rectangle but with the new size, this for each sprite. or 2- Create each sprite with a border and on each refresh, resize it Whats better?
I have a button that when clicked is supposed to draw a rectangle behind my mask layer but when I try to run it I get this error: 1067: Implicit coercion of a value of type Class to an unrelated type flash.display:BitmapData.
Here is the related ActionScript Code: fabric_mc.phoenixFab.addEvenetListener(MouseEvent.CLICK, changeFabric); function changeFabric(event:MouseEvent):void{ this.graphics.beginBitmapFill(phoenixFabric); this.graphics.drawRect(181, 46, 319, 319); this.graphics.endFill }
I want to draw a rectangle (1px border, no fill) and then scale it using ActionScript. If I scale the movieclip, obviously the border scales as well. Is there any way to scale a dynamically created shape in ActionScript?
I want to draw a rectangle (1px border, no fill) and then scale it using ActionScript. If I scale the movieclip, obviously the border scales as well. Is there any way to scale a dynamically created shape in ActionScript?
I have a line within a rectangle.The line can draw outwards 360 degrees.I need to determine which of the rectangle's 4 sides the line is drawing out of.
I am drawing a rectangle at 0,0 with a line-style-thickness of 4px. It has height 100% and width 50%. The right-hand edge has a border 4px wide, but all 3 other sides are only 2px, suggesting the mid-point of the edge is classed as the border. Why isn't the edge drawn 'inside' the rectangle?
I need to to incorporate a functionality where the user can use his mouse to draw a rectangle by dragging his mouse over the canvas - much like the Rectangle Drawing Tool in the Flash Authoring environment. The requirement is something like a rubberband tool where the user can define a portion of a map by drawing a rectangle over it. The coordinates needs to be captured.
If I draw a rectangle or trapezium, how might I go about drawing bitmap data into that shape? I need to give a slight perspective to a loaded photo. Native 3D rotations seem to leave the bitmap really blurry, and a full 3D engine is too heavy for this project.
I need to to incorporate a functionality where the user can use his mouse to draw a rectangle by dragging his mouse over the canvas - much like the Rectangle Drawing Tool in the Flash Authoring environment. The requirement is something like a rubberband tool where the user can define a portion of a map by drawing a rectangle over it. The coordinates needs to be captured. Can anyone help me with the actionscript.
I need to have the ablity to create 3000+ sprites so they can be interact. In this case it is a bunch of booths at trade show. I have done a lot of experimentation about how to create/draw these in the quickest possible manner.I have used timers, loops, enter frame events and I am still not satisfied with speed.My new idea is to create a seperate swf before hand that has everything drawn out so this doesn't have to be done at runtime, the swf can just be downloaded. So my question is.... What would be the best way to develop a module that draws out everything into a swf file so that at runtime, I am not drawing anything, I am just uploading the file.
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?
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 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.
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?
how to respond when a rectangle hits another rectangle? I already know how to detect the collision, I just don't know how to respond to it. I'm just trying making a simple side-scrolling platform game where I have platforms I can walk on and bump against on all sides. I have searched everywhere and just can't find the tutorials I'm looking for.
I've seen the Loom project, but are there any alternatives that are more mature (and actively developed)? I am looking for something that would allow load-time weaving of pointcuts into existing binary code at runtime with the AVM2 runtime.