eggli
05-23-2007, 02:36 AM
Just trying to upgrade my 3.4.x laszlo system to 4.0.2, got lot of problems on code that runs perfectly on 3.4.x, here's one sample:
<image id="leftpic" x="0" y="0" width="490" height="550" align="center" valign="middle"
datapath="pageset:/DATA[1]/ROW[1]/IURL/text()" clickable="true" visible="true">
<method event="onframesloadratio">
<![CDATA[
if(this.framesloadratio == 1){
if(leftpic.resourcewidth > 490 || leftpic.resourceheight > 550)
{
var oratio = leftpic.resourcewidth/leftpic.resourceheight;
var widthover = leftpic.resourcewidth/490;
var heightover = leftpic.resourceheight/550;
var resizeratio = (widthover>heightover)?widthover:heightover;
var newwidth = leftpic.resourcewidth/resizeratio;
var newheight = leftpic.resourceheight/resizeratio;
leftpic.setWidth(newwidth);
leftpic.setHeight(newheight);
leftpic.setAttribute("stretches", "both");
}
else
{
leftpic.setAttribute('stretches', 'none');
leftpic.setWidth(leftpic.resourcewidth );
leftpic.setHeight(leftpic.resourceheight );
}
}
]]>
</method>
</image>
The code above is going to load some images/SWF URL from a XML datasource, and when the loading is completed(framesloadratio==1), it will check the resource's height/width to ensure the resource is not larger than the container image, if it's larger than the container, resize it into right Height:Width ration size w/o making the image squeezed/expanded into wrong ratio.
The code above is not going operational in 4.0.2, while:
1. the onframeloadratio event is no longer trigger, I've tried onloadratio, not working either.
2. the lines that setting the image's width/height is buggy, you don't get the result if you do it ONCE, you have to it twice to get the image resized.
The final *working* code is here:
<image id="leftpic" x="0" y="0" width="490" height="550" align="center" valign="middle"
datapath="pageset:/DATA[1]/ROW[1]/IURL/text()" clickable="true" visible="true">
<method event="onload">
<![CDATA[
if(leftpic.resourcewidth > 490 || leftpic.resourceheight > 550)
{
var oratio = leftpic.resourcewidth/leftpic.resourceheight;
var widthover = leftpic.resourcewidth/490;
var heightover = leftpic.resourceheight/550;
var resizeratio = (widthover>heightover)?widthover:heightover;
var newwidth = leftpic.resourcewidth/resizeratio;
var newheight = leftpic.resourceheight/resizeratio;
leftpic.setWidth(newwidth);
leftpic.setHeight(newheight);
leftpic.setAttribute("stretches", "both");
}
else
{
leftpic.setAttribute('stretches', 'none');
leftpic.setWidth(leftpic.resourcewidth );
leftpic.setHeight(leftpic.resourceheight );
}
leftpic.setWidth(leftpic.width);
leftpic.setHeight(leftpic.height);
]]>
</method>
</image>
As you can see, I can no longer monitor a image is loaded or not via frame load ratio nor load ratio, and I have to do the setWidth(this.width) thing to make the resize happend(setting something's width with it's own width, sounds cool, ya?).
Guess I'm gonna to downgrade from 4.0.2 to 3.4.x =\
<image id="leftpic" x="0" y="0" width="490" height="550" align="center" valign="middle"
datapath="pageset:/DATA[1]/ROW[1]/IURL/text()" clickable="true" visible="true">
<method event="onframesloadratio">
<![CDATA[
if(this.framesloadratio == 1){
if(leftpic.resourcewidth > 490 || leftpic.resourceheight > 550)
{
var oratio = leftpic.resourcewidth/leftpic.resourceheight;
var widthover = leftpic.resourcewidth/490;
var heightover = leftpic.resourceheight/550;
var resizeratio = (widthover>heightover)?widthover:heightover;
var newwidth = leftpic.resourcewidth/resizeratio;
var newheight = leftpic.resourceheight/resizeratio;
leftpic.setWidth(newwidth);
leftpic.setHeight(newheight);
leftpic.setAttribute("stretches", "both");
}
else
{
leftpic.setAttribute('stretches', 'none');
leftpic.setWidth(leftpic.resourcewidth );
leftpic.setHeight(leftpic.resourceheight );
}
}
]]>
</method>
</image>
The code above is going to load some images/SWF URL from a XML datasource, and when the loading is completed(framesloadratio==1), it will check the resource's height/width to ensure the resource is not larger than the container image, if it's larger than the container, resize it into right Height:Width ration size w/o making the image squeezed/expanded into wrong ratio.
The code above is not going operational in 4.0.2, while:
1. the onframeloadratio event is no longer trigger, I've tried onloadratio, not working either.
2. the lines that setting the image's width/height is buggy, you don't get the result if you do it ONCE, you have to it twice to get the image resized.
The final *working* code is here:
<image id="leftpic" x="0" y="0" width="490" height="550" align="center" valign="middle"
datapath="pageset:/DATA[1]/ROW[1]/IURL/text()" clickable="true" visible="true">
<method event="onload">
<![CDATA[
if(leftpic.resourcewidth > 490 || leftpic.resourceheight > 550)
{
var oratio = leftpic.resourcewidth/leftpic.resourceheight;
var widthover = leftpic.resourcewidth/490;
var heightover = leftpic.resourceheight/550;
var resizeratio = (widthover>heightover)?widthover:heightover;
var newwidth = leftpic.resourcewidth/resizeratio;
var newheight = leftpic.resourceheight/resizeratio;
leftpic.setWidth(newwidth);
leftpic.setHeight(newheight);
leftpic.setAttribute("stretches", "both");
}
else
{
leftpic.setAttribute('stretches', 'none');
leftpic.setWidth(leftpic.resourcewidth );
leftpic.setHeight(leftpic.resourceheight );
}
leftpic.setWidth(leftpic.width);
leftpic.setHeight(leftpic.height);
]]>
</method>
</image>
As you can see, I can no longer monitor a image is loaded or not via frame load ratio nor load ratio, and I have to do the setWidth(this.width) thing to make the resize happend(setting something's width with it's own width, sounds cool, ya?).
Guess I'm gonna to downgrade from 4.0.2 to 3.4.x =\