Jump to content
Search Community

AIR / Security / ApplicationDomain - issue

Jakob Sternberg test
Moderator Tag

Recommended Posts

Hi, i'm creating a AIR app.

The main functionality of the App is downloaded to "ApplicationStorage", and loaded by the "AIR-SWF" (The SWF that makes the AIR App, it's more or less empty, and just loads the main SWF)

With LoaderMax i load a fontface class by loading a SWF and then using  loader.getClass("myFontClass") to get the Class, then i use Font.registerFont(myFontClass) - It works fine when just running as normal "html/flash-web-app"
 

The problem is when i load above functionality into AIR-SWF, it doesent work anymore. When trying to register the font it gives me:
 

ArgumentError: Error #1508: The value specified for argument font is invalid.

 

So somehow when in AIR, the getClass("myFontClass") does not return the FontClass

So the subload scenerio that fails is abstraclty like this:
 

app:\\AppLoader.swf > app-storage:\\MainAppUIAndFunctionality.swf > app-storage:\\fonts\fNormal.swf

* Slashes are infact forwardslashes
 

-
I've been doing AS2 for ages, but I'm relatively new to both AS3 and AIR, so any tips are welcome.
 

Note: In publish settings of the loaded SWF's i've set communction to "Local", and i apply System.allowDomain("*") - also i get no security related issues in the process  - in short it works, just not when loaded by the AIR-SWF

Any help for an old newbie? =)

 

Link to comment
Share on other sites

Yeah, i know.. i just seek advice among the wise ^^
And yes i tried Adobe forums..

I'm using the technique herehttp://www.scottgmorgan.com/runtime-font-embedding-in-as3-there-is-no-need-to-embed-the-entire-fontset-anymore/  <-- oops corrected wrong link

But instead of getting the font class like this (dont even know how to this way - with LoaderMax)

var FontLibrary:Class = event.target.applicationDomain.getDefinition("_Arial") 
as Class;

Ofcourse with LoaderMax i get the class by using:

var FontLibrary:Class = event.target.getClass("_Arial"); 

--
 

I guess these two ways are actually doing the same for me? yes? (i thought there maybe could be difference.. wich made it fail) ..
 

 

Omg. ApplicationDomain?.. LoaderContext?.. meeeh, it hurts my brain..



 

Link to comment
Share on other sites

Yeah, I know - ApplicationDomains and LoaderContexts are kinda tough to understand at first. I was scratching my head when I first heard about them. 

 

Let us know if you hear anything from the Adobe folks or solve your problem a different way. 

Link to comment
Share on other sites

OK, AIR is especially touchy..

AIR-SWF will always run with sandboxType="application";

If i load the SWFs normally, using SWFLoader, the SWF files from app-storage:/ will have have sandboxType="localWithFile";

But if i instead read the file binary and use loadBytes(data,context) , with loader context.allowLoadBytesCodeExecution= true - then the "loaded" SWFs gets sandboxType="application" 
- Apparently this is the "trick",  i'm not entirely sure what consequences it will have in the big picture, but it makes the font-load-thing work!!! 

--
I got definitive answers from this article:
"ApplicationDomain dirty secrets." http://code.google.com/p/maashaack/wiki/ApplicationDomain
--

Now i have to see if i can get LoaderMax to load binary data and then use that data in loadBytes... ^_^


 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...