History | Log In     View a printable version of the current page.  
Issue Details (XML)

Key: SDK-14590
Type: Bug Bug
Status: Closed Closed
Resolution: Retired
Priority: C C
Assignee: Peter deHaan (Adobe)
Reporter: Stefano Spelta
Votes: 3
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Flex SDK

SWF object in SWFLoader draws outside container bounds

Created: 02/08/08 11:44 AM   Updated: 06/02/09 05:45 PM
Component/s: mx: SWFLoader
Security Level: Public (All JIRA Users )

File Attachments: 1. Zip Archive Example.zip (12 kb)
2. Text File workaround.mxml (0.4 kb)

Image Attachments:

1. screenshot-1.jpg
(54 kb)

2. workaround scrollRect.jpg
(20 kb)

Severity: Incorrectly Functioning with Workaround
Reproducibility: Every Time
Discoverability: Medium
Found in Version: SDK Flex 3 (Released)
Milestone: SDK Gumbo - Release
Affected OS(s): Windows - XP
Steps to Reproduce:
Steps to reproduce:

Execute application
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" width="637" height="463" alpha="1.0" color="#010B0D" borderThickness="2" borderColor="#000000" cornerRadius="2" layout="absolute" horizontalAlign="center" verticalAlign="middle">
    <mx:Panel height="104" width="488" x="83" y="25">
        <mx:SWFLoader source="Banner.swf" width="468" height="60">
        </mx:SWFLoader>
    </mx:Panel>

    <mx:Panel height="104" width="487" x="84" y="311">
        <mx:SWFLoader source="Banner.swf" width="468" height="60">
        </mx:SWFLoader>
    </mx:Panel>

</mx:WindowedApplication>

where the only difference between the two panels is in the width propoerty (488 vs 487).

 
Actual Results:
The SWF in the first panel drwas ouside of the panel bounds
The SWF in the second panel doesn't, but scrollbars are added
 
 
Expected Results:
In the first panel the SWF should have draw in the panel , without any scrollbar added
 

Workaround (if any):
(a) Apply a mask to the panel:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Panel title="Banner goes here" layout="absolute">
<mx:Box id="box2" backgroundColor="red" width="{swfLdr.width}" height="{swfLdr.height}" />
<mx:SWFLoader id="swfLdr" source="Banner.swf" width="468" height="60" mask="{box2}" />
</mx:Panel>

</mx:Application>

It uses the "mask" property to mask the content which falls outside the SWFLoader instance.
 

(b) Set the scrollRect property:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Panel title="Banner goes here" layout="absolute">
        <mx:SWFLoader id="swfLdr"
                source="Banner.swf"
                width="468" height="60"
                resize="swfLdr.scrollRect = new Rectangle(0,0,swfLdr.width,swfLdr.height);" />
    </mx:Panel>

</mx:Application>


Or
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Panel title="Banner goes here" layout="absolute">
        <mx:SWFLoader id="swfLdr"
                source="Banner.swf"
                width="468" height="60"
                scrollRect="{new Rectangle(0,0,swfLdr.width,swfLdr.height)}" />
    </mx:Panel>

</mx:Application>

Language Found: English
Bugbase Id: none
Triaged: Yes
Regression: No
QA Owner: Peter deHaan (Adobe)
Resolved by: Joan Lafferty
Participants: Alex Harui, Andriy Panas, David Gofman, Joan Lafferty, Lauren Park, Peter deHaan (Adobe), Randy Gibbs, Stefano Spelta and Steve Breinberg


 All   Comments      Sort Order:
David Gofman - [02/09/08 06:20 PM ]
Looks nice and cool! Anyway I think I know why you have that problem.
I am sure you created attached SWF file using Flash Application.
Multiple layers, motions all nice Flash features. At same time you specified Stage dimension 470x65. That size applied inside Flash Player window. When you embedded to another SWF your stage properties gone. Your start point x, y, width and height base of your image layout (circles). What are negative by x and y and out of 470 pixels. That reason why Panel 1 displayed all Stage components. For Panel 2 you can apply horizontalScrollPolicy="off" verticalScrollPolicy="off" to get your expected behavior.

Stefano Spelta - [02/11/08 03:03 AM ]
Thank you David for your answer.

Yes, the attached SWF was created using Flash but not by me. That's why I could not understand this strange behaviour.

It's OK for me to use your suggestion on the second panel as a workaround.

Just for my better understanding, do you think this is an expected behaviour for the SWFLoader component or is it really a bug?

Thanks
Stefano

David Gofman - [02/11/08 03:19 AM ]
I am not using SWFLoader since Flash 8. But I had same problem before. So, what happened in my code I created SWF 1 and loaded SWF 2 what is bigger then my container. As soon as SWF 2 loaded inside container, some times container changed size or new SWF was over a container holder. I don't remember how I fixed that problem (maybe set _root.lock=true and loaded in background mode or add event listener onLoad for SWFLoader variable) hole idea you have to wait until movie will loaded and after attach to your container. That reason why in your code a second panel working fine.

Peter deHaan (Adobe) - [02/12/08 06:12 PM ]
Does something like the following workaround work for you?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Panel title="Banner goes here" layout="absolute">
<mx:Box id="box2" backgroundColor="red" width="{swfLdr.width}" height="{swfLdr.height}" />
<mx:SWFLoader id="swfLdr" source="Banner.swf" width="468" height="60" mask="{box2}" />
</mx:Panel>

</mx:Application>

It uses the "mask" property to mask the content which falls outside the SWFLoader instance.

Peter

Peter deHaan (Adobe) - [02/12/08 06:14 PM ]
Able to repro in 201.3 and latest moxie.

Andriy Panas - [02/13/08 05:36 AM ]
I am using the similar trick as Peter deHaan had suggested to hide everything that is rendered outside of the SWFLoader container borders:

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:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
resize="applyMask()" >
....
<mx:SWFLoader id="swf"
complete="applyMask()"
source="navigation.swf/>
</mx:VBox>


Moreover, I reapply "applyMask" every time when I resize the parent mx:VBox container:


Peter deHaan (Adobe) - [02/18/08 04:12 PM ]
Not a regression, has workaround. Recommend deferral for Moxie.

Randy Gibbs - [03/17/08 12:29 PM ]
I also seem to have this problem but the workarounds given above are not appropriate. I am loading the external swf dynamically using Loader and wish to display it in a Canvas with auto scrollbar behavior. Since, I do want the scrollbar behavior, the mask work-around is not appropriate. Once loaded, the content may be scaled (by user request) and the scrollbars should then appear. The external swf is actually a child of the object which in turn is the child of the scrollable Canvas. I can't wait until the child swf loads to add its parent to the Canvas as David Gofman suggests. Is there another work-around. Perhaps some way to overtly reset the Canvas when the onLoad event signals that the external swf in question has loaded?

Peter deHaan (Adobe) - [04/27/09 01:12 PM ]
Another workaround is setting the scrollRect property, as seen in the following example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Panel title="Banner goes here" layout="absolute">
        <mx:SWFLoader id="swfLdr" source="Banner.swf" width="468" height="60" scrollRect="{new Rectangle(0,0,swfLdr.width,swfLdr.height)}" />
    </mx:Panel>

</mx:Application>

Steve Breinberg - [04/27/09 09:49 PM ]
This is a good workaround, so I think we can defer.

Lauren Park - [04/27/09 09:54 PM ]
Changed Priority, Severity and Discoverability.

Peter deHaan (Adobe) - [04/27/09 11:52 PM ]
Closing as deferred.

Alex Harui - [05/14/09 05:34 PM ]
Recommend will not fix. Don't want to add clipping to SWFLoader.

Joan Lafferty - [06/02/09 03:47 PM ]
Per Alex's recommendation, we probably don't want to add this clipping to SWFLoader. We recommend that you implement the suggestions in previous comments if you run into this bug.

Retiring bug.

Peter deHaan (Adobe) - [06/02/09 05:45 PM ]
Closing as retired.