Highlighted

Load external vector shapes in iOS?

New Here ,
Apr 15, 2018

Copy link to clipboard

Copied

Hi,

Some of our app's art is in vector form. We release new art often, so we don't want to have to upload a new iOS binary every time we want our users to get new art.

We load external SWFs with the Loader class. This works well in flash and android air, but in iOS we encounter the "Uncompiled Actionscript" issue described in the following thread:

http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-io...

https://blogsimages.adobe.com/airodynamics/files/2012/10/uncompiledAS2.png

However, this confuses us a bit, as the swf does not contain code, only vector art:

This leads be to ask the following questions, which I have not been able to find an answer for:

1) Do vector shapes get compiled to actionscript code, making them equivalent to code in these regards?

2) Does the "Linkage" generate classes inside the SWF, causing the resulting SWF to be regarded as code?

3) If (2) is the problem, is there an alternative way to label vector assets in a SWF to allow loading them on demand?

4) (The bottom line) is there a way to dynamically load vector art in an AIR app deployed on iOS?

TOPICS
Development

Views

444

Likes

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

Load external vector shapes in iOS?

New Here ,
Apr 15, 2018

Copy link to clipboard

Copied

Hi,

Some of our app's art is in vector form. We release new art often, so we don't want to have to upload a new iOS binary every time we want our users to get new art.

We load external SWFs with the Loader class. This works well in flash and android air, but in iOS we encounter the "Uncompiled Actionscript" issue described in the following thread:

http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-io...

https://blogsimages.adobe.com/airodynamics/files/2012/10/uncompiledAS2.png

However, this confuses us a bit, as the swf does not contain code, only vector art:

This leads be to ask the following questions, which I have not been able to find an answer for:

1) Do vector shapes get compiled to actionscript code, making them equivalent to code in these regards?

2) Does the "Linkage" generate classes inside the SWF, causing the resulting SWF to be regarded as code?

3) If (2) is the problem, is there an alternative way to label vector assets in a SWF to allow loading them on demand?

4) (The bottom line) is there a way to dynamically load vector art in an AIR app deployed on iOS?

TOPICS
Development

Views

445

Likes

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
Apr 15, 2018 0
Adobe Community Professional ,
Apr 15, 2018

Copy link to clipboard

Copied

The linkage is likely to cause code to be made. Also, I see that there is export classes made when you publish a swf, even with AS2, and if you have no classes.

One thing that I haven't tried, but might be worth a go, is to not use linkage, but instead have an instance name on the symbol on stage. Then try an addChild() of that instance from the Loader to where you needed it. Or just addChild the Loader itself, where the graphic on stage doesn't have an instance name.

Another idea would be to do the code stripping that you're supposed to do in order to have online swfs with code, but just do that on a test IPA, not your real one. As part of that you should get swfs that have no code, which might then load.

For a completely different approach you could read this article:

Using SVG as a level design format – Zeh Fernando

I don't fully understand it, but it feels like doing live rendering of SVG data might work.

One last thought, tinypng.com can make PNG versions of images be a lot smaller, if the vector approach doesn't work out.

Likes

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
Reply
Loading...
Apr 15, 2018 0
Engaged ,
Apr 16, 2018

Copy link to clipboard

Copied

Unfortunately Linkage does generate classes/code, if you check out a SWF or SWC in something like FlashDevelop you can see that adding Linkage to a MovieClip calling it "testclip" is creating this class behind the scenes:

package {

import flash.display.MovieClip;

public class testclip extends MovieClip {

public function testclip ();

}

}

One thing you could try is to have a separate SWF for each element (instead of using Linkage on multiple clips in the same SWF), with a separate xml file you load that keeps track of all of the filenames for those SWFs so you know what you need to load.  Obviously that's much more cumbersome and slow depending on how many elements you need to load, but it might work in a pinch if you can't find any other ways around it.

Likes

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
Reply
Loading...
Apr 16, 2018 0
Advocate ,
Apr 17, 2018

Copy link to clipboard

Copied

As Colin has pointed out your best chance is to access the swf and retrieve the assets from the scene. You could even store several shapes on the stage and have a catalag file or similar to distinguish them (Child 1 is Asset A, Child 2 is Asset B, etc.). We are loading external MovieClips from our servers in iOS and we currently have one asset per swf, but depending on the number of assets you might want to include more than one per file.

Likes

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
Reply
Loading...
Apr 17, 2018 0
New Here ,
Apr 17, 2018

Copy link to clipboard

Copied

Thanks for the suggestions!

Followup questions:

1) If we load a SWF with a catalog file to distinguish, how much of a memory / performance overhead can we expect, when compared to using linkage?

2) Is it possible to download a zip file with SWFs of individual items, and decompress the individual SWF from zip and load it from memory (perhaps with Loader.loadBytes)? Or will we have to work with temporary files? Has anyone had success with this approach?

Likes

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
Reply
Loading...
Apr 17, 2018 0
New Here ,
Apr 17, 2018

Copy link to clipboard

Copied

hello everyone,

what me and techt3563422 are trying to do is load assets from swfs and use them multiple times.

if it comes to having every asset in a different swf that's ok but the question is can we instantly clone the content inside?

as for now, I only managed to duplicate the loader but that is not instant and requires waiting for the completion event every time.

I did not manage in any way to clone the content of the swf, say if I place an asset on the stage and give it an instance name all I could clone was a blank movie clip since the asset could not get a class of his own.

any ideas and leads would be great,

thanks!

Likes

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
Reply
Loading...
Apr 17, 2018 0
Advocate ,
Apr 18, 2018

Copy link to clipboard

Copied

If your content is static you could render your shapes into Bitmaps and use those multiple times, this is what we are doing. However if your content is animated or you require to keep the vector data, I am not sure what you could do. It's worth a try to see what happens if you get the class from your Shape and create a new instance. Could be that you end up with an empty Shape, though.

Likes

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
Reply
Loading...
Apr 18, 2018 0
Advocate ,
Apr 18, 2018

Copy link to clipboard

Copied

From an externally loaded .swf:

- You can't clone objects on the timeline of the .swf (they have no definition = No exported to AS)

- You can clone the .swf itself = either load the .swf again or get its class definition (even without code a .swf has a class definition) and make a new instance of it.

- Yes you can zip multiple .swf, extract them and load them in app but again no AS inside whatsoever mandatory.

Recommended:

Don't use external .swf on mobile.

- You might use it to take advantage of vector format, learn to work with raster directly since you'll need to draw those vector in raster anyway and that drawing operation can be slow to very slow on mobile.

- Or you might want to take advantage of compression capability of .swf, again not worth it, zip your raster assets if you need to, extract them and load them (or embed them directly even better) .

- Or you might just use it for organization convenience, again not worth it, use raster and make your life easier.

Likes

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
Reply
Loading...
Apr 18, 2018 0
Engaged ,
Apr 18, 2018

Copy link to clipboard

Copied

The game I am working on relies on a lot of external assets that change frequently. The advantages of vectors is are very small file size, and resolution independance.

The solution we use is:

- Load asset url, if it's the first load, vector asset is loaded

- Once vector is loaded, gets rasterized at optimal resolution for device

- Asset is then duplicated whenever needed as BitmapData

- On subsequent loads, asset is just rendered internally from BitmapData

It works quite well, considering we are not talking about thousands of different Bitmaps to be held in RAM.

Likes

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
Reply
Loading...
Apr 18, 2018 0
Advocate ,
Apr 18, 2018

Copy link to clipboard

Copied

Well then the easiest solution is to treat your .swf like you would treat any external asset > one graphic = one swf. Set your naming convention (you probably did already), load them (or deal with your zip first), resize them, take your screenshot, save it, and you are done (use a worker). Dealing with unique assets is not a big deal really, that's what most people using rasters have to do.

Likes

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
Reply
Loading...
Apr 18, 2018 1
Engaged ,
Apr 18, 2018

Copy link to clipboard

Copied

Yep our situation is a bit complex, relies on a database of items that change frequently stored on network, locale dependant, etc.

Just to point out that vectors do have an advantage. As long so you rasterise once on load then work with generated BitmapData...

Likes

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
Reply
Loading...
Apr 18, 2018 0