Archive for the ‘AS3’ Category

AS2 + AS3 Draw a Dotted Rounded Corner Box

Wednesday, November 7th, 2007

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)

DashedLine.as for as3

Draw.as for as3

Draw.as for as2

So we can now do a box with curved corners in either AS2 or AS3 and in dotted or normal… phew!

Using Firebugs console.log in flash AS2 & AS3

Wednesday, November 7th, 2007

To use the excellent features of the firebug plugin for Firefox when debugging in flash, simply put this class in your ClassPath.

This will allow you to log Objects (yes it will iterate deep objects) log data which is externally loaded such as server requests. Overall it just makes life that little bit simpler.

Usage:

var obj:Object = {hi:”Hello World”, {hi_again:”Hello again”}}
console.log(obj)
console.debug(obj)
console.warn(obj)
console.info(obj)
console.error(obj)
console.assert(exp) – tests that expression is TRUE
console.dir(obj) – print an objects properties like in the DOM view
console.dirxml(xml)
console.group(name)
console.endGroup(name)
console.time(name)
console.endTime(name)
console.profile(name)
console.endProfile()

Download console.as ( for AS2 )

Download console.as ( for AS3 )

thanks to whomevers code i’ve cannibalized to get these, sorry i lost your links.