You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Peter Ent <pe...@adobe.com> on 2014/12/12 21:28:06 UTC

[FlexJS] Seeking input on FlexJS core.graphics change

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

Re: [FlexJS] Seeking input on FlexJS core.graphics change

Posted by OmPrakash Muppirala <bi...@gmail.com>.
This is the classic immediate vs. retain mode graphic api problem [1]

I like your proposal of having separate APIs that result in
SVG.createGraphicShape vs. Canvas.drawGraphicShape.  This way, we can cater
to both workflows.

Thanks,
Om

[1]
http://msdn.microsoft.com/en-us/library/windows/desktop/ff684178%28v=vs.85%29.aspx

On Fri, Dec 12, 2014 at 12:28 PM, Peter Ent <pe...@adobe.com> wrote:
>
> 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
>