now when you use Flex SDk 4.5.x to generate a SWC
you obtain an extra class looking like
_050c3e6ed85dab3426a1c292e29d382819826b144ad91294b679b8ff99f20d8b_flash_display_
Sprite
*where does this come from ?*
when /compiler/src/java/flex2/tools/Compc.java kick in
{{{
List<CompilationUnit> units =
CompilerAPI.compile(fileSpec, sourceList, classes.values(), sourcePath, resources, bundlePath,
swcContext, mappings, configuration, compilers,
new CompcPreLink(rbFiles, configuration.getIncludeResourceBundles(), false),
configuration.getLicensesConfiguration().getLicenseMap(), sources);
}}}
this call to /compiler/src/java/flex2/tools/CompcPreLink.java
is there to generate extra code to deal with RSL
{{{
private void codegenRootClass(List<Source> sources, List units, ResourceContainer resources,
CompilerSwcContext swcContext, Configuration configuration,
List<DefineTag> fonts, String uniqueRootClassName)
{
String rootClassName = "_" + uniqueRootClassName + "_";
String sourceText = null;
if (fonts.size() == 0)
{
rootClassName += "flash_display_Sprite";
sourceText = codegenRSLRootClass("flash.display.Sprite", rootClassName);
}
else
{
rootClassName += "mx_core_FlexModuleFactory";
sourceText = PreLink.codegenModuleFactory("flash.display.Sprite",
//...
}}}
and later
{{{
/**
* Generate a root class for an RSL with wrapper calls to Security.allowDomain() and
* Security.allowInsecureDomain(). The purpose is to allow callers to trust the RSL SWFs
* in the same way they can trust an application swf.
*
* @param base The class root class extends.
* @param rootClassName
* @return The root class actionscript class definition as a String.
*/
private static String codegenRSLRootClass(String base,
String rootClassName)
{
String lineSep = System.getProperty("line.separator");
String[] codePieces = new String[]
{
"package", lineSep,
"{", lineSep, lineSep,
"import flash.display.Sprite;", lineSep,
"import flash.system.Security;", lineSep, lineSep,
"/**", lineSep,
" * @private", lineSep,
" */", lineSep,
"[ExcludeClass]", lineSep,
"public class ", rootClassName, lineSep,
" extends ", base, lineSep,
"{", lineSep,
" public function ", rootClassName, "()", lineSep,
" {", lineSep,
" super();", lineSep,
" }", lineSep, lineSep,
PreLink.codegenRSLSecurityWrapper(true, lineSep),
"}", lineSep, lineSep,
"}", lineSep,
};
return StringJoiner.join(codePieces, null);
}
}}}
this also call /compiler/src/java/flex2/tools/PreLink.java
{{{
/**
* Generate flash player Security wrapper calls.
*
* @param lineSep
* @return
*/
static String codegenRSLSecurityWrapper(boolean isLibraryCompile, String lineSep)
{
if (!isLibraryCompile)
return "";
String[] code = {
" /*", lineSep,
" * Calls Security.allowDomain() for the SWF associated with this RSL", lineSep,
" * @param a list of domains to trust. This parameter is passed to Security.allowDomain().", lineSep,
" */", lineSep,
" public function allowDomainInRSL(... domains):void", lineSep,
" {", lineSep,
" Security.allowDomain.apply(null, domains);", lineSep,
" }", lineSep, lineSep,
" /*", lineSep,
" * Calls Security.allowInsecureDomain() for the SWF associated with this RSL", lineSep,
" * @param a list of domains to trust. This parameter is passed to Security.allowInsecureDomain().", lineSep,
" */", lineSep,
" public function allowInsecureDomainInRSL(... domains):void", lineSep,
" {", lineSep,
" Security.allowInsecureDomain.apply(null, domains);", lineSep,
" }", lineSep,
};
return StringJoiner.join(code, null);
}
}}}
*How to support that in redtamarin ?*
We need to have the definitions for
* *flash.display.Sprite*
* *flash.system.Security*
and support at least *Security.allowDomain* and *Security.allowInsecureDomain*
Let be sure we do that in *avmglue* and then that each time we want to read the
bytecode from a SWC that avmglue is loaded first.
Original issue reported on code.google.com by zwetan on 24 Sep 2011 at 9:00
Original issue reported on code.google.com by
zwetan
on 24 Sep 2011 at 9:00