Hi,

I've recently completed a set of FlexJS chart classes that "optimize" the chart 
graphics. You can read about it on the FlexJS Wiki [1] (at the end of the 
page). What this means is that rather than creating a nesting of objects to 
represent, say, a bar on a chart, I use the FlexJS 
core.graphics.GraphicsContainer's drawRect() function.

In JavaScript, this results in a single SVG <rect> element. In ActionScript, 
this results in a call to the Flash drawingAPI drawRect() function.  This works 
well because there is an ActionScript and a JavaScript version of the 
core.graphics package. Most of the FlexJS chart code is in the FlexJSJX project 
which is cross-compiled into JavaScript so I don't have to write both versions.

While this seemed ideal at first, I've run into a situation where I can get 
events from the JavaScript side, but not from the ActionScript side, on a 
per-element basis. For example, in JavaScript I can tell when the mouse enters 
the <rect> element, but in ActionScript, there is no object, just a drawing.

What I propose to do is add to the core.graphics.GraphicsContainer object a set 
of functions that create elements in both JavaScript and ActionScript. Where we 
now have:

graphicsContainer.drawRect(0, 0, 100, 200)
   (makes JavaScript): <rect x="0" y="0" width="100" height="200">
   (makes ActionScript): graphics.drawRect(0,0,100,200)

I would add:

graphicsContainer.createRect(0, 0, 100, 200) which would do the same thing in 
JavaScript as .drawRect(), but the ActionScript version would yield a Shape. In 
this way we have parity between the JavaScript and ActionScript versions with a 
simple object tree for graphics that also can generate events.

The current ActionScript "optimized" package would become the "NonInteractive" 
package and later we could have that match to HTML5 <canvas> and its drawing 
API and keep the parity going.

Let me know what you think.

Regards,
Peter Ent
Adobe Systems

[1] https://cwiki.apache.org/confluence/display/FLEX/FlexJS+Charts

Reply via email to