AS3 font embedding - Error message - actionscript-3

I would like to embedd a font with AS3 using the "swf method".
The error I get is:
Font "myFont" could not be created
../assets/swf/myFont.swf cannot be transcoded.
As per Google this problem is because of a path-error.
But I think I set the right path, didn't I?
My folder structure
main.fla
../com
..../subfolder
....../testButton
......../testButton.as
....../assets
......../swf
........../myFont.swf
in my testButton.as I'm trying to embedd the myFont.swf:
public class testButton extends Sprite {
[Embed(source="../assets/swf/myFont.swf", fontName="myFont",
fontWeight='bold', mimeType="application/x-font")]
private var myEmbeddedFont:Class;
In the main.fla I'm creating an object of the class.

Just convert the original font file into a .otf and install it. Flash will detect it and you'll be able to use it like a normal font without the embedding.

Related

How to add an HTML5 animation generated with Adobe Animate CC to a Ionic 2 project page?

I have made an animation with Adobe Animate CC as HTML 5 canvas item. I can publish the animation in several ways:
as html: 1 file html, 1 file js, several directory with included file. Pages are all inclusive (head, body, including libraries) and including it in a Ionic page means unpack the html (right?). I'm trying but it seems a bit complex.
as movie .mov, but it's a bit expensive in terms of file size
In both cases, i'm not sure how to include the published result in a Ionic page and I think I'm missing something.
So, how do I include a Adobe Animate CC animation in a Ionic 2 Framework page?
UPDATE: I tried to unpack the html. Tried publishing the animation as HTML5 animation, with the publish setting "Included javascript in HTML". This way all the necessary js is put inside the html file that the publish procedure outputs. Then I took that js (the one contained in
<script> some js here </script>
immediately after the import of the library createjs) and put it in a mylibrary.js file in /assets/js/mylibrary.js. This way, I was able to import it in the ts file of one ionic page like
import mylibrary from '../../assets/js/mylibrary'
and then try to initialize the animation like
ionViewDidLoad(){
mylibrary.init()
}
In the original file the init() function was called on body like
<body onload="init()">
Unfortunately it doesn't work. The error thrown is
cjs.Bitmap is not a constructor
that is not really important as error, if not to state that clearly the library createjs is not imported in the right way for it cannot associate its cjs variable of mylibrary.js that contains a function like
(function (lib, img, **cjs**, ss, an) {
… (all code here)
})(lib = lib||{}, images = images||{}, **createjs = createjs||{}**, ss = ss||{}, AdobeAn = AdobeAn||{});
to createjs variable of the library. I mean, commenting the cjs.Bitmap line, it starts complaining about the subsequent cjs.Rectangle that does not exixts.
So I tried to include the library, first taking the include from the Animate generated html
<script src="libs/createjs-2015.11.26.min.js"></script>
and put it in my main 'index.html' app file (copying in asset/js the directory lib containing the file). Did not work. Tried with the live version of the library
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
Did not work.
Tried even to add all the other (unecessary library linked to createjs like easejs etc https://code.createjs.com/). Did not work.
Then I tried adding the library in the ts file adding before the import of mylibrary
import createjs from '../../assets/js/createjs'
Did not work.
Even tried to npm install createjs, createjs-module and createjs-easeljs and import them.
import easeljs from 'createjs-easeljs';
import createjs-module from 'createjs-module';
import createjs from 'createjs';
Guess what? Did not work.
Any time I said "did not work" the problem was ever the same error "cjs.Bitmap is not a constructor". Presently I couldn't find a way to import an animation generate via Adobe Animate CC into Ionic.
Just for people passing by, not an elegant solution, but at least one.
You can save in Adobe Animate your animation as video ('mov' file) and optimize its size and format with Adobe Media Converter or whatever other program you like. I've converted it in mp4 in this case.
NB: When you publish the video, if there is an audio track, it will be included in the video only if beginning at the second frame of the animation. It is a little tricky to discover, so worthy to be said.
As soon as you have an 'mp4' file, add it to your app assets, and you could include it to a Ionic page in the classical html way. In my case, it was a video to play fullscreen so here it is my code:
<ion-content padding>
<div id="videocontainer">
<video fullscreen="fullscreen" autoplay="true" (ended)="onVideoEnded()">
<source src="assets/video/your_video_name.mp4" type="video/mp4">
</video>
</div>
</ion-content>

How to load .dae object with texture, and material

I just started with Minko and trying to undestand this https://github.com/aerys/minko/blob/master/doc/tutorial/06-Loading_3D_files.md tutorial. I did some steps:
sceneManager->assets()->loader()
->queue(FIREAXE_D)
->queue(FIREAXE_N)
->queue(FIREAXE_S)
->queue(TEXTURE_FILENAME)
->queue("effect/Basic.effect")
->queue(OBJ_MODEL_FILENAME);
and now I am trying to use these three textures with my object and file .mtl -> material.
auto _ = sceneManager->assets()->loader()->complete()->connect([=](file::Loader::Ptr loader)
{
auto objModel = sceneManager->assets()->symbol(OBJ_MODEL_FILENAME);
objModel->component<Transform>()->matrix()->appendScale(0.01f);
objModel->component<Transform>()->matrix()->translation(-1.f, -1.f, 0.f);
objModel->component<Texture>()->set(sceneManager->assets()->texture(FIREAXE_D));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_N));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_S));
root->addChild(objModel);
});
This won't work and what about .mtl file? How to attach it to my object?
However tutorials are still to tiny and buggy it is better to look for examples but I cann't find any with texture loading for object right now.
This won't work and what about .mtl file? How to attach it to my object?
Your question is about loading a Collada (*.dae) file. Collada files don't have *.mtl files, *.obj files do.
Still, it works the same for any dependency of any file: they are automatically loaded if they can actually be found at the provided path/URI.
You can add include/search paths using the file::Options::includePaths() property, or customize how URI are resolved by using the file::Options::uriFunction(). Many other properties of the file::Options class will help you customizing how assets are loaded.
However tutorials are still to tiny and buggy
If you find bugs please open an issue on github.
it is better to look for examples but I cann't find any with texture loading for object right now.
The following example loads a Collada file along with animations and textures:
https://github.com/aerys/minko/tree/master/example/assimp

Abour ResourceBundle in AS3

I creadet a class that has more ResourceBundles in it. My app is multilanguage so I will need many ".properties" files.
here is a sample code
[ResourceBundle("LocalizedStrings_en_US")]
[ResourceBundle("LocalizedStrings_fr_FR")]
...
public class LocaleLoader
{
...
}
My question is if I add many ResourceBunlde lines in this class, will the file size of the main swf increase drastically or not?
Should use separata class files to load separate ResourceBundles for each language?
The [ResourceBundle] annotation itself won't have any effect on the file size. It's the -locale compile option of the mxmlc that matters.
-locale=en_US means to embed only the US-locale in the SWF
-locale=en_US, ja_JP means to embed both the US-locale and the Japan-locale
If you don't embed the Japan-locale you can load it at runtime with resourceManager.loadResourceModule(...).
To address completely the topic of Flex Localization Support please refer to the Slides & Samples in the Flex Localization Support article I wrote in the Obecto Training Portal.

How to add image in the library

I have the image path manipulate from database with php. Now how can i have to import those image in the library so that i can use them as a symbol. Thanks in advance.
You cannot load it into library, but you can load this image via php and use it on stage with action script. Take a look at this answer to the similar question:
Load image dynamicly in flash
You can download it to the server and generate source file with Class that have field like this:
class Library
{
[Embed(source = 'path_to_folder/image_name.png')] public static var imageClass : Class;
}
Alsou you should refer this class somewhere to be sure it will be compiled into your swf and use it like this:
const image:Bitmap = new (Library.imageClass)();
In that case you need to recompile your swf every time the image is changed.
But I'm totaly agree with Bartek that it is better to use dynamic loading.

Alternative for getDefinitionByName

In the past, there was a simple trick, to include the flex mxmlc module by adding the following line to the flash-cs4 makefile:
-include-libraries “/absolute/path/to/my/assets/assets.swc”
This gave you the ability to use getDefinitionByName, an helper function to access the embedded swc asset-library (instead of creating hand-written classes all assets).
Unfortunately, this has stopped working since flash-cs4. Does anybody know another solution?
Unfortunately, the only workaround I have found is to explicitly refer each of asset classes somewhere in the code. You may create dummy class like this:
public class AssetsExporter extends Sprite
{
public static function export()
{
AssetClass1;
AssetClass2;
//etc
trace( "DEBUG AssetsExporter.export()" );
}
}
Specify this class as Document class in Flash IDE, so it will be compiled into the resulting swc. Then in the main code of your application call
AssetsExporter.export();
After doing this you will be able to use getDefinitionByName().
You can add them to the libraries in the publish settings.
(Image from http://wiki.gigya.com/ via Google Images)
By the way, if you use SWC files, you can also do
new somepackage.SomeClass();
instead of
new getDefinitionByName("somepackage.SomeClass")
where applicable. This is because SWC files are included at compile time, not runtime.
Even though you can change a compiler setting manually, its easy if you are using FlashDevelop as this is very simple to fix.
Right click your included swc from the Project list. Choose options then "include library (complete library)".
..you can now use getDefinitionByName to get an unreferenced class from your swc file.