Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display SVG in FLEX

There are any way to display dynamically loaded SVG in FLEX?

like image 260
Eugene Burtsev Avatar asked Mar 22 '11 07:03

Eugene Burtsev


People also ask

Can you use flexbox with SVG?

Flexbox can organize non-SVG DOM elements: You can't use Flexbox to arrange elements within SVG. That is, if you have a bunch of rect elements within your SVG, Flexbox can't move them. But, if you have several, separate SVG elements (think small multiples), Flexbox can arrange them for you.

How do you place elements in Flex?

Flex Start positions element at the start of the page. Flex End sets the element to the end of the page. Space Around arranges the items evenly but with spaces between them. The spaces will be equal among all the elements inside a flex-box container, but not outside them.

Can images be flex items?

However, with flexbox, the images are fully responsive—you can test it by resizing the browser window. Another advantage is that now the images (flex items) can be easily positioned in different ways (we'll see how to do it below).


2 Answers

There's no "native" way to load and display SVG files dynamically.

From the latest flex documentation:

SVG drawing restrictions

  • You can only embed an SVG file in an application; you cannot load one at run time
  • SMIL and animation are not supported
  • Masking and filters are not supported
  • Pattern Fill and some advanced Gradients are not supported
  • Interactivity and scripting is not supported
  • SVG text is rendered as nonsearchable and nonselectable SWF shape outlines, meaning it is not rendered as native text in Flash Player or AIR

Alternatively you can use third-party libs to do the work, such as:

  • http://code.google.com/p/svgweb/
  • http://code.google.com/p/as3svgrendererlib/
like image 87
bmleite Avatar answered Oct 03 '22 00:10

bmleite


did you try spark.primitives.Path?

like image 20
www0z0k Avatar answered Oct 02 '22 23:10

www0z0k