AS2 + AS3 Draw a Dotted Rounded Corner Box
So you might think that rounded corners is easy in as3 with the new drawing tools. This is only so true if you don’t want it dotted.
Thanks to senocular AS2 DashedLine.as which was easily converted to an as3 version DashedLine.as for as3 we can draw dotted lines and curves with actionscript. This left me with the task of using the quadratic drawing tools (no i didnt add a cubic curveTo to the Dashed line class) to draw circles (or quarters of circles, for the curners), which isnt the easiest, but i’ll spare you the details and simply say, its done!
Using Draw.curvedBox(obj, offsetX, offsetY, width, height, cornerRadius) we can draw into any graphics object (whether it be a normal Sprite.graphics or a DashedLine Object). This is essential as the Dashed line tool doesnt actually give us a fill, so we might need to draw a normal shape for the background.
import com.senocular.drawing.DashedLine import com.tonp.utils.Draw var dl = new DashedLine(this,1,5); dl.lineStyle(3,0x000000,1); Draw.curvedBox(dl,10,10,100,100,20)
to draw a curved corner box with a fill, or solid outline, send in mc.graphics as the first attribute (or just the mc in as2)
So we can now do a box with curved corners in either AS2 or AS3 and in dotted or normal… phew!
November 9th, 2007 at 1:17 am
Thanks this is just what I needed.
April 18th, 2008 at 1:31 pm
Thank you for this nice work. I will use it in the coming version of my site, I’ll show the result ^___^
April 23rd, 2008 at 12:37 pm
Nice one, many thanks!
I noticed something when testing it though. If you, for example, have an onenterframe that clears the line and draws a new line each frame, the line will “animate” (similar to the marquee tool in photoshop), since the dash offset isn’t reset. This change to the clear-method seems to have done the trick for me:
public function clear():void {
this.isLine = true;
this.overflow = 0;
this.pen = {x:0, y:0};
this.target.clear();
}
(I have only tested that together with moveTo and lineTo though, don’t know if it will break some of the other methods in there.)
August 9th, 2008 at 5:20 pm
Honi soit legate left buy cytotec then announced estivities.
August 23rd, 2008 at 3:13 am
THis does not work for me at all
import dashedline;
import flash.display.Shape;
var n= new Shape()
var dashLines:dashedline = new dashedline(this, 10, 6);
dashLines.lineStyle(10,0×0000FF,50)
dashLines.moveTo(50, 50);
dashLines.lineTo(100, 50);
September 17th, 2008 at 3:23 pm
You need to add your shape n to the display list
eg. addChild(n);
October 20th, 2008 at 8:06 pm
Hey thanks! The only thing that is missing is the how to on the Draw class.
October 25th, 2008 at 12:55 am
Good for people to know.
October 27th, 2008 at 5:24 am
[…] http://blog.alegitimatebusiness.com/2007/11/07/as2-as3-draw-a-dotted-rounded-corner-box/ « ???????????????????? […]
February 5th, 2009 at 8:50 pm
[…] Getting dotted lines in ActionScript seems to be one of those old chestnuts. The ever-resourceful Senocular has a neat ActionScript 2 solution, ported to ActionScript 3 here. […]
March 27th, 2009 at 10:19 pm
Hey, the senocular site is down and I need this dashed curve library for AS2. Does any one have it by any chance? Thanks
Joe
April 24th, 2009 at 10:58 am
I read your blog for a long time and must tell you that your posts are always valuable to readers.
May 26th, 2009 at 12:53 pm
Really nice work, thanks man !
Using Flashdevelop however, i get all these ‘warnings’ for all sorts of variables not having a type-declaration, how would you go about that ? Should i just add them or leave strictMode ? Or ignore ? (although that doesn’t really add to the workflow)
I was just wondering, I will declare them in my copy..
July 22nd, 2009 at 4:20 pm
I’ve got a few layers in my .fla file and the line (”dl”) is being drawn on the stage in the bottom-most layer only. In other words, if I put any kind of display object on the stage it’s covering up the line.
Is there a way to add the dashedline object to another movie clip? As it is, I’m getting the following error:
TypeError: Error #1034: Type Coercion failed: cannot convert com.senocular.drawing::DashedLine@417cd151 to flash.display.DisplayObject.
Thanks for great class.
July 23rd, 2009 at 2:42 am
The DashedLine class takes a target which is draws into the .graphics of. You seem to be trying to addChild on the DashedLine object, not the clip which it is drawing the graphics into.
DashedLine isnt a display object, it just draws into your displayobject - which you should change the level of - via adding it to your other clip
September 3rd, 2009 at 11:11 pm
Excellent site, keep up the good work
December 14th, 2009 at 9:31 pm
Hi … I found your website by mistake. I was searching in Yahoo for PDF software that I had already bought when I came upon your site, I must say your website is pretty cool I just love the theme, its amazing!. I don’t have the time at the moment to fully read your entire site but I have bookmarked it and also will sign up for your RSS feed. I will be back in a day or two. thanks for a awesome site.
December 18th, 2009 at 9:24 am
???????? ??? ??????! ? ??? ????? ?? ??? ???? ????? ? ???????? ????? ???!
February 24th, 2010 at 3:41 pm
Duuuuuuuuude.. Needed a curved dashed line drawer for AS3.. Did some googling around and looksy who’s name popped up.. Worked a treat.. Thanks Polly.. I knew you were good for something (apart from chugging jugs of beer)
March 10th, 2010 at 3:07 pm
Thanks to you and senocular for the great Dashed line class. And thank you, fiskhandlarn for the clear () code, it’s exactly what I needed.
March 13th, 2010 at 7:30 am
This site I found has lots of great info on herbs and was really helpful. Its hard to find a good place with good information
March 25th, 2010 at 12:55 am
yo good website yea nice job good good…this post deserves nothing …hahaha just joking
…nice post
ohhh nice info
April 12th, 2010 at 4:22 pm
I’m a big fan of this site and I check it regularly. Keep up the great work!
April 19th, 2010 at 7:37 am
Hey, I read all your articles, keep them coming.
April 25th, 2010 at 1:59 pm
I really appreciate the work that you put into your blog. It really shows. Thanks
June 6th, 2010 at 9:42 am
I’ve been really enjoying Treme. I’ve missed the Wire.
September 3rd, 2010 at 7:11 pm
I venture there are loads of individuals like me, who come across varied good blogs or sites by fortune. Your site appears to hold a good community and a solid blogosphere presence. Its good to hold absorbing and different positions on issues.
October 21st, 2010 at 3:21 pm
brilliant, thanks.
November 4th, 2010 at 1:53 pm
Bonjour, pouvez vous nous citer quelques-unes des sources utilisées ici? Merci d’avance
December 5th, 2010 at 4:12 pm
This is great! I was just discussing this with my son a couple days ago. Looking forward to hearing what he think about your blog. Thanks for posting!
March 27th, 2011 at 4:54 am
I’d personally let you know how fantastic your site is, but what could I say that the 1000 people above me haven’t already? Maybe…your website is very fishy? Now there, I doubt that particular one is on this site.
April 17th, 2011 at 7:41 am
Thanks for the sensible critique. Me and my neighbor were just preparing to do some research on this. We got a grab a book from our local library but I think I learned more from this post. I’m very glad to see such magnificent information being shared freely out there.
May 15th, 2011 at 5:06 pm
FREE SHAKO WITH EVERY LADDER ORDER!
July 7th, 2011 at 1:33 am
With havin so much written content do you ever run into any problems of plagorism or copyright violation? My site has a lot of exclusive content I’ve either created myself or outsourced but it seems a lot of it is popping it up all over the internet without my agreement. Do you know any ways to help reduce content from being stolen? I’d certainly appreciate it.
July 31st, 2011 at 6:51 am
This site is very good. Just how has been that made ?
August 22nd, 2011 at 3:31 pm
??
October 26th, 2011 at 4:50 am
Speedily and easily build your internet traffic and PR, which provides Internet internet site visitors to add your page to any social bookmarking internet site.
October 27th, 2011 at 3:16 am
painting tips…
[…]alegitimatebusiness.com » Blog Archive » AS2 + AS3 Draw a Dotted Rounded Corner Box[…]…
December 15th, 2011 at 8:54 pm
hello,
thanks for this awesome class, it s very useful, however, i have a question.
I m usign tweenMax to build a dynamic line between 2 point. i tween an arrow and in the tween, i use the onUpdate to call a function and draw the line.
It works perfectly. But i would like to remove this line in a nicer way than just clear, like a fade, or reduce the thickness etc… How can i access to the existing line and do the stuff i want to do?
I tried to make a tween and on update, call a function where i decrement the alpha via the lineStyle but it doesn t affect the existing line.
Hope i m clear enough.
thanks a lot
December 24th, 2011 at 10:58 am
I love your wordpress template, where did you download it from? 565161
December 24th, 2011 at 2:08 pm
I adore your wp web template, wherever would you obtain it through? 848837
March 25th, 2012 at 7:38 am
Outstanding post, I conceive people really should larn a lot from this weblog its really user friendly .
October 8th, 2012 at 1:50 pm
[…] Pour dessiner des boites arrondies ou des lignes en pointillés voir les deux classes DashedLine et Draw de Senocular et Tony. […]