• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Load or Draw a SVG with javascript

Community Beginner ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

Hello everyone! 

I'm working with some images and need to load dynamic SVG to show some graphics shapes, but I found this is not possible natively, so I'm looking for options. 
I can't import the SVG to the FLA, also use transparent MPG or GIF to dynamic load results on tons of files and a huge size increase. 

note: all my SVG are composed only with Path objects. no polygons, and no simple shapes. 
I tried to draw the paths of SVG using Path2D() but it draw only for a fraction of a seccond and then disapears. 

Anyone has tried to draw or import SVG, I have no idea other options, besides change the framework  

Thank you for reding 

Views

128

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

why can't you import an svg?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Thanks kglad, 

I'm trying to make a dynamic project. witch load different content maintaining the main structure. 
I would like to avoid editing the FLA just to import files to the project if those files can be loaded dynamically 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

LATEST

you can use preloadJS, https://createjs.com/docs/preloadjs/modules/PreloadJS.html

 

eg,

 

displayPicture('./images/svg_file.svg');
var tl = this;
 
function displayPicture(imgPath) {
var image = new Image();
image.onload = onLoadF;
image.src=imgPath;
}
 
function onLoadF(e) {
var img = new createjs.Bitmap(e.target)
tl.addChild(img);
stage.update();
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines