Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Jakob Sternberg

AIR / Security / ApplicationDomain - issue

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 post
Share on other sites

Hmm...I wish I had an easy answer for you, but I'm not much of an AIR guy and this question definitely sounds like it's about AIR, not LoaderMax. Have you tried posting in Adobe's forums maybe? 

Link to post
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 post
Share on other sites

And oh yes, this is definately not a complaint! 
Knowing "greensock syntax" from AS2.. Being new with AS3 , using your stuff for AS3 makes things more comfortable :D - it's just great.
 

  • Like 1
Link to post
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 post
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 post
Share on other sites

Sure, you can use the BinaryDataLoader in LoaderMax for that. Or the DataLoader. 

Link to post
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.

×