Home > Development > blogs
My last few posts on the Flash/Flex/ActionScript drawing API gave me a few ideas... Everyone always says how it reminds them of old-school programming in BASIC or Pascal. I decided to make it easier for anyone to play with the drawing API, without having to compile any programs for themselves. I call this the "Drawing API Explorer". Using the drawing API explorer application, you don't have to override updateDisplayList or anything. All of the hard work is done.
This example uses runtime code evaluation to draw shapes using the ActionScript drawing API. Check it out below!
There are two tabs. The first tab allows you to type in code that will be executed when you click on the "run" button. The second tab shows you a bunch of ActionScript drawing API examples. Just click on an example name in the left, and the code will be displayed. You can run the examples by clicking on the "run this example" button, or you can edit the example code by clicking on the "edit this example" button. When you click on the "edit" button, it will switch over to the first tab and paste the code into there.... Be careful! It will clear whatever was in there previously.
You can use any kind of loops, if-statements, switch statements, etc... It supports all methods of the Graphics, Math, and Matrix ActionScript classes. You can use the variable g to represent the graphics object, the variable w to represent the draw target area width, and the variable h to represent draw target area height. I have tried the following, and know they work:
- g.lineStyle
- g.beginFill
- g.endFill
- g.moveTo
- g.lineTo
- g.curveTo
- g.drawRect
- g.drawRoundRect
- g.drawCircle
See the ActionScript drawing API documentation for more information about the drawing API syntax and capabilities.
Go ahead and test it out here:
The runtime code evaluation uses the D.eval() code library. The D.eval() API is a SWC library for Flex applications that enables the runtime generation and execution of code and expressions in ActionScript 3.
You can launch this application in a new window here:
http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/DrawingAPIExplorer.html
View the source code here:
http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/srcview/index.html
Or, download the source code here:
http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/srcview/DrawingAPIExplorer.zip
- comments: 1
- actionscript
- drawing api
- flex
- tags:
Comments
1 Comments
Leave a comment
Stay Connected
Search InsideRIA
Poll: Colin Moock's The Charges Against ActionScript
Which of Colin's points about improving ActionScript 3.0 do you most agree with?
News & Events
Latest Features
Tag Cloud
- .net
- 3d
- actionscript
- adam flater
- adobe
- air
- air api
- air cookbook
- air resources
- air xml webkit
- ajax
- ajaxworld
- alertthingy
- amp
- analytics
- ant
- antipattern
- apache
- api
- app engine
- apple
- application
- april fools day
- aptana
- architecture
- asp
- audio
- authors
- away3d
- aws
- bad usability calendar
- benchmarking
- berlin
- beta
- bitmaps
- blazeds
- blendmode
- book
- browserplus
- bsd
- business
- businessweek
- cairngorm
- camp
- career
- cdn
- chart
- cloud
- code
- code generation
- coldfusion
- command design pattern
- communication
- community
- compiler
- component
- compression
- conference
- creativecommons
- cs3
- cs4
- curl
- customer
- cuzillion
- dare
- data
- datatable
- datavisualization
- dbunit
- ddlutils
- debug
- decompiler
- deep zoom
- degrafa
- design
- design patterns
- desktop
- development
- diary
- dionalmaer
- drawing api
- dreamweaver
- drupal
- ebay
- ejb 3.0
- elixir
- embedded jboss
- encryption
- europe
- event
- excerpt
- experience
- ext
- externalinterface
- eyetracking
- features
- filters
- fireworks
- fitc
- flash
- flash10
- flashforward
- flashplayer
- flex
- flex4
- flexbuilder
- flexunit
- form factor
- framework
- friendfeed
- gadget
- gears
- gesture
- googledocs
- googlegears
- gpl
- graphics
- graphics mask
- guidelines
- guimark
- hosting
- how-to
- html
- ia
- ie
- ie8
- igoogle
- interaction
- interface
- interview
- iphone
- iphonedevcamp
- iron man
- j2ee
- jakob
- java
- javafx
- javaone
- javascript
- javase
- javase6
- jaxer
- jms
- job
- joyent
- keynote
- languages
- lcds
- learning
- lffs
- library
- license
- licensing
- linux
- listen
- livecycle data services
- madrid
- map
- marketing
- math
- maturity
- maven
- max
- memory
- merapi
- mesh
- metrics
- microsoft
- mikepotter
- mit
- mix08
- mobile
- model locator design pattern
- mono
- mozilla
- mvc
- mxmlc
- neilson
- nio
- nitro
- nitrolm
- offline
- onairbustour
- onairtour
- onairtoureurope
- ontologies
- oop
- open source
- openflux
- openscreen
- opensource
- optimization
- orm
- papervision3d
- paris
- pattern
- pattern mining
- performance
- php
- podcast
- popular
- portable
- preload
- pricing
- prism
- Processing
- Processing.js
- profiler
- protagonize
- push
- rails
- release
- research
- resources
- ria
- ria community
- ria roundup
- rich
- ruby
- rules
- sanctuary
- scheduling
- scott sheridan
- search
- security
- seo
- server
- service oriented architecture
- services
- session bean
- silverlight
- singularity
- social
- sockets
- software
- source
- spain
- spry
- sqlite
- static code
- steveounders
- stockholm
- streaming
- survey
- swc
- swf
- switchboard
- syscon
- test driven development
- testing
- testng
- thermo
- tip
- tools
- training
- trends
- tufte
- tutorial
- ui
- ui pattern library design
- uirc
- unconference
- unit testing
- usability
- user experience
- ux
- vector images
- view source
- vision
- warsaw
- wdn08
- web
- web 2.0
- web 2.0 expo
- whenisgood
- why
- widgets
- workshop
- wwdc
- xulrunner
- yahoo
- yui
Related Books
Development Series
Get an overview of the tools and technologies that work together to allow developers to build Rich Internet Applications (RIAs) quickly and easily.
Recent Comments
Archives
About This Site
Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.
About Us
Meet the Experts
Meet Our Contributors
Send Us Feedback

Very cool example!
Will experiment with that.
Thanks!