at the moment Iâm toying with the idea of porting some old FlashDevelop AS3 projects to
OpenFL - mainly for deploying to HTML5.
For these projects I always create a library .swf file (created in another application and exported as an AVM1 movie) which holds assets like buttons and stuff which are then imported using:
[Embed(source="../assets.swf",symbol='backgroundGradient')]
private var backgroundGradientTemplate:Class;
and instantiated using:
var tempBack:Sprite = new backgroundGradientTemplate();
for example.
After some research I realized I can do almost the same with OpenFl! At least in theory.
Reality is a bit different though.
If I embedd my library and try to use a symbol, e.g.
var test = Assets.getMovieClip ("lib:texBox");
and try to run (targeting flash) the debugger complains: [openfl.Assets] There is no MovieClip asset with an ID of "lib:texBox"
Well, what should I say, it IS there.
Itâs a MovieClip containing a rounded rectangle as well as a dynamic TextField.
Okay, after some more experiments, changing the instantiation to this
The text is a bit blurry though and the debugger throws the following errors: [openfl.text.TextField] WARNING: Could not find required font âAriaâ, it has not been embedded Error: WebGL: texImage2D: Conversion requires pixel reformatting.
So basically this seems to work! What can I do to make it really work?
Iâm using OpenFL 4.7.3 and Lime 3.7.2.
You can grab the sample project here: Link
I looked at your sample project and edited it. This works for me no problems and since we have same Openfl&Lime versions (latest) so should work for you (?)
Thanks for taking the time!
Unfortunately this doesnât solve my problem. In your code youâre using another swf
to import assets from. Yours was exported using Flash CS5.5 as an AVM2 movie.
Problem is, Iâm not using Flash CSx to create my assets and my application just can
export up to swf8.
I stumbled across this thread: Link
The user seems to have the same problem and it could be solved
by forcing type âswfliteâ on all targets as @singmajesty pointed out.
I just donât know what this means.
I tried:
We can read fonts in our decoder, but we donât have our own webfont generator, only a converter that supports most TTF and some OTF fonts. As a result, youâll need to include the font you want as a separate asset. Thatâs what the âCould not find required fontâ message is about
Long time no talk.
Actually the problem still persists - trying to instantiate the whole swf by
var test = Assets.getMovieClip ("lib:");
was just a little test to see if itâs able to load the swf at all.
Thereâs no practical use and if I try to do the same targeting flash, I get a cannot convert flash.display::AVM1Movie@4c63f31 to flash.display.MovieClip.
which completely makes sense.
I donât have problems importing assets from an AVM2 movie by the way. Itâs really
just AVM1 movies, swf7 in this case. Could you have a look at the sample project
in my initial post?
Or can you recall what you mean by forcing type âswfliteâ on all targets in this topic: Link
Thanks for the insight about font handling - I have a problem with it too but will start
a new thread for it.
Sorry for this late reply. Iâve been pretty busy and we decided to redo most of our
assets as AVM2Movies meanwhile to be able to move on with the project.
The problem remains though. I donât want to attach the whole movie to the stage.
It was just a test to see if itâs loaded at all.
Itâs still unable to find the assets inside the AVM1Movie (which are marked as export
for actionscript of course).
[openfl.Assets] There is no MovieClip asset with an ID of âlib:texBoxâ
Yes! If you target anything except for Flash, we can get the individual symbol names. However, on Flash Player, an AVM1Movie is an opaque type that can only play, you cannot access individual âExport for ActionScriptâ classes