PDA

View Full Version : "Stretches" with dynamic resource


maverickbu
02-20-2008, 06:57 PM
Basically, the "stretches" attribute seems to be ignored when I load a resource dynamically. When I specify the resource explicitly, it stretches as expected. Here's the line of code:


<view name="icon" height="32" width="32" resource="${classroot.objecticon}" stretches="both">


Ideas?

rcyeager
02-20-2008, 07:29 PM
Works for me, in both Flash and DHTML.

I happen to have a sample here that stretches images in both runtimes: http://www.qrowd.com/widgetWizard.htm?uuid=aa10e477e93b49ee8d6db5e900cd 451f

Can you post a complete test that demonstrates the issue?

Robert
http://www.qrowd.com
http://www.cooqy.com

ange52
07-15-2008, 07:06 AM
I'm having a similar problem. When I state the resource explicitly, it stretches properly and fits the view as it should. When I load a resource dynamically, however, the spacing is distorted in a weird way.

I'm attempting to dynamically load 200x200 SWF images into a 40x40 thumbnail view. The images load and appear in the app. The images are scaled down appropriately. But for some reason, a few images are far off to the right, other images are down low... Although the original 200x200 images are spaced in the center of the SWF, almost none of the 40x40 thumbnails have images spaced in the center.

Any ideas on how I can change this?

Thanks all,
Ange52

ange52
07-17-2008, 07:35 AM
...Just wondering if this could be a problem with my SWFs somehow? Or if resizing from 200x200 to 40x40 is overwhelming Laszlo? Is there another way to resize SWFs (onload handler, maybe) instead of using stretches="both"?

Thanks again,
Ange52

FlashAppPgmr
07-17-2008, 10:44 AM
Are you trying to load SWFs or images?

ange52
07-17-2008, 04:16 PM
I'm trying to load SWF files that are 200x200 pixels, and have an image centered on only one frame.

ange52
07-21-2008, 07:58 AM
I have drafted up a little demo of this problem. You won't be able to replicate the exact issue because the SWF files are not online and I have masked the URLs, but I hope that all this code will be enough...


<canvas width="500" height="500">

<dataset name="dsImages" src="http://localhost:8888/mySite/media/findMedia.php" type="http" request="false" />

<button x="200" y="0">Load images
<handler name="onclick">
parent.dsImages.setQueryString("find=q&amp;cat=all");
parent.dsImages.doRequest();
</handler>
</button>

<view name="holder" x="0" y="50" width="500" height="450" bgcolor="red">
<wrappinglayout axis="x" spacing="5" />
<view name="pic" datapath="dsImages:/xml/item" width="40" height="40" stretches="both" bgcolor="white">
<handler name="ondata" args="d">
var path = d.getAttr("path");
var name = d.getAttr("name");
var ext = d.getAttr("type");
var str = "http://localhost:8888/mySite/" + path + name + "." + ext;
this.setSource(str);
</handler>
</view>

</view>

</canvas>


In this demo app, you click the button at the top and images load in. The "pic" view is 40x40 with a white background, and it replicates and properly loads in the given SWF files. This much is great. But here is the problem: The SWF files that come in do NOT stay in the 40x40 white box created by the view. It seems as if the SWFs are scaling down, but for some reason they move.

I have attached a pic to help show what is going on.

Any further thoughts?

FlashAppPgmr
07-21-2008, 11:09 AM
Looks like the Y axis is incrementing with each image.
use "xspacing" instead of "spacing" (which does both axes).

ange52
07-21-2008, 12:37 PM
Thanks for the idea! Sadly, I gave it a shot and it didn't work out.

The only line of code I changed now reads:

<wrappinglayout axis="x" xspacing="5" />


The picture shows that the white boxes are now almost touching vertically, but the loaded SWFs continue to be placed in weird spots.

Any other ideas?

ange52
07-21-2008, 12:47 PM
I just tested a few other things, and the problem gets a bit more interesting...

I tried specifying that the "pic" view needs to be 200x200:

<wrappinglayout axis="x" spacing="5" />
<view datapath="dsImages:/xml/item" width="200" height="200" bgcolor="white">
...
</view>

This comes out looking just as expected (see attached -- "200x200.png").

Next, I tried not specifying anything about the dimensions, I just load them in:

<wrappinglayout axis="x" spacing="5" />
<view datapath="dsImages:/xml/item" bgcolor="white">
...
</view>

In this case, the "pic" view skews automatically (see attached -- "no-set-dimensions.png"). Although it is loading in a SWF that is 200x200, the "pic" view, for some unknown reason, resizes and scales to different dimensions. Furthermore, the app looks the same whether or not I say stretches="both" on this variation.

It seems like this issue is related to my problem when I try to load the SWFs in at 40x40 with stretches="both". Does this help make things any bit clearer? Thanks for your patience,
Ange52

senshi
07-21-2008, 12:57 PM
I'm trying to load SWF files that are 200x200 pixels, and have an image centered on only one frame.
The images are centered within the swf-file? If this is the case, what happens if you just place the images in the upper-left corner. (Maybe some offsets aren't added, so the whole image looks distorted...)

ange52
07-21-2008, 05:56 PM
Oh Senshi... of course the first thing you recommend turns out to be the solution! I thought I tried experimenting with this earlier, but it turns out you are exactly right. Senshi, you are the man.

In order to make sure the stretching is balanced (not skewed horizontally more than it is vertically or vice versa), I'm adding an invisible background box to the SWF files. Now the images are remaining centered and they are scaling perfectly.

Thank you all for your help!

matzelito
03-31-2009, 04:42 AM
Hi i have the same problem,
i load dynamically an swf- File, which is smaller then his canvas,
but it doesn't stretch :confused:

but your workaround doesn't work for me :

<canvas width="1920" height="960" bgcolor="#EAEAEA" title="schwarzes Brett" debug="false" >
<view id="werbefilm" x="0" y="0" width="1920" height="960" resource="http:resources/film.swf" stretches="both" >

<view name="invisible-bg-box" resource="unvisible.png" width="1920" height="960" stretches="both" x="0" y="0" >

</view>

</view>



</canvas>