Flex – Use ByteArray to load SWF in AIR

We require the AIR application to load the swf generated by flex, which uses SWFLoader to load the swf generated by flash. This does not meet the requirements. This will cause the following error:
SecurityError: Error #3226 : When LoaderContext.allowCodeImport is false, the SWF file cannot be imported.

This is our AIR application.





import mx.controls.SWFLoader;

[Embed(source=" FlexLoadingFlash.swf")]
public var flexMovie:Class;

private function initApp():void {
// First convert the Swf into MovieClip
var movieclip :MovieClip = new flexMovie();

// get the byteArray from movieClip
var byteArray:ByteArray = movieclip.movieClipData;

var swfLoader:SWFLoader = new SWFLoader();

// load bytearray into swfLoader
swfLoader.source = byteArray;

swfLoader.maintainAspectRatio = false;
swf Loader.percentHeight = vbox.height;
swfLoader.percentWidth = vbox.width;
swfLoader.invalidateDisplayList();
swfLoader.invalidateSize();

// now add the swfloader into container
vbox.addChild(swfLoader);
}

]]>







Please tell us how to solve this problem.

Use Loader.loadBytes() to load SWF. Create an instance of LoaderContext. The loadBytes method takes the LoaderContext instance as a parameter. Set the allowCodeImport property of the LoaderContext instance to true, and it should work Work

We require the AIR application to load the swf generated by flex, which uses SWFLoader to load the swf generated by flash. This does not meet the requirements. This will cause the following error:
SecurityError: Error# 3226: When LoaderContext.allowCodeImport is false, the SWF file cannot be imported.

This is our AIR application.





import mx.controls.SWFLoader;

[Embed(source="FlexLoadingFlash.swf")]
public var flexMovie:Class;

private function initApp():void {
// First convert the Swf into MovieClip
var movieclip:MovieClip = new flexMovie();

// get the byteArray from movieClip
var byteArray:ByteArray = movieclip.movieClipData;

var swfLoader:SWFLoader = new SWFLoader();

// load bytearray into swfLoader
swfLoader.source = byteArray;

swfLoader. maintainAspectRatio = false;
swfLoader.percentHeight = vbox.height;
swfLoader.percentWidth = vbox.width;
swfLoader.invalidateDisplayList();
swfLoader.invalidateSize();

// now add the swfloader into container
vbox.addChild(swfLoader);
}

]]>

< /mx:Script>





Please tell us how to solve this problem.

Use Loader.loadBytes() Load the SWF. Create an instance of LoaderContext. The loadBytes method takes the LoaderContext instance as a parameter. Set the allowCodeImport property of the LoaderContext instance to true and it should work

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5849 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.