How to hide the unwanted content visible outside of mx:SWFLoader boundaries
The issue:
I was stumbled upon once ago when I loaded my external SWF file authored by the Flash IDE by the help of
The corresponding task in Adobe JIRA bug-database:
http://bugs.adobe.com/jira/browse/SDK-14590
I currently fight this issue by applying the mask over the content that is loaded by the
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
resize="applyMask()" >
<mx:Script>
<![CDATA[
private function applyMask() : void {
if (swf != null &&
swf.content != null &&
swf.content.loaderInfo.width > 0 &&
swf.content.loaderInfo.height > 0) {
var scaleRatioX : Number = swf.content.loaderInfo.width /
this.width;
var scaleRatioY : Number = swf.content.loaderInfo.height /
(this.height - this.controlBar.height);
var scaleRatio : Number = Math.max(scaleRatioX, scaleRatioY);
swf.width = swf.content.loaderInfo.width > 0 ?
Math.round(swf.content.loaderInfo.width / scaleRatio) : 100;
swf.height = swf.content.loaderInfo.height > 0 ?
Math.round(swf.content.loaderInfo.height / scaleRatio) : 100;
var s : Shape = new Shape();
s.graphics.beginFill(0xFFFFFF);
s.graphics.drawRect(0, 0, swf.width, swf.height);
s.graphics.endFill();
swf.addChild(s);
s.visible = false;
swf.mask = s;
}
}
]]>
</mx:Script>
<mx:SWFLoader id="swf"
complete="applyMask()"
source="navigation.swf"/>
</mx:VBox>
2008
13
Feb
- Posted by JabbyPanda at 04:28 am
- Permalink for this entry
- Filed under: Adobe Flex
- RSS comments feed of this entry
- TrackBack URI
This is something I may have to consider at work.
At work, a lot of our Flash(8) designers hid content off the stage area.
If older Flash 8 content will be displayed in our new Flex projects, this is something to remember among things.
I had this problem for some months last year on a video site I was working on, that has flash ads or video ads that play prior to the videos, some of the advertisers had sent their creative, and I was experiencing this problem, researching for months, did not find anything, the solution I used, was masking the files in flash, ie the swf content that is being loaded, this could be a daunting task over time, and required that the advertisers send their creatives in fla’s. I found this post searching for something else in google, I wish this was available sooner, and I am glad I am not the only person with this problem. Thank you very much for this solution. This should be at the top of google search. very helpful.