Global variables should work exactly this way. However one thing
which is not correct in your code is the usage of the preloader. You
need to wait for the preloader. You can't directly use getWidth()/
getHeight()
function A)
{
preloader = new qx.io.image.Preloader("CHASSIS-M7I-FRONT.PNG");
preloader.addEventListener("load", function() {
origHeight = ....
B(5);
}
}
Sebastian
Am 10.05.2007 um 05:41 schrieb kumar balaji:
> Thanks Folks for the quick help.
> Now I am able to get the height and width of an image
> using ImagePreloader class, but when I refresh it, the
> height and width are reported as 0.
>
> Let me breifly explain what I face. Am using a global
> variable to store the height and width of an image.
> But looks like this global variable doesnt store it
> when I use it in recursive functions. As a developer I
> would expect a global variable to be available for all
> the functions inside a javascript file though am using
> it in recursive functions as well. Is this expected in
> javascript?
>
> Eg. sample.js
> var preloader;
> var origHeight;
> var origWidth;
>
> function A()
> {
> preloader = new
> qx.io.image.Preloader("CHASSIS-M7I-FRONT.PNG");
> origHeight = preloader.getHeight();
> origWidth = preloader.getWidth();
> B(5);
> }
>
> function B(var count)
> {
> alert(origHeight);
> alert(origWidth);
> if(count == 0)
> return;
> else
> B(--count);
> return;
> }
>
> Here I get the correct origHeight and origWidth for
> the first time. But as the variables enter into
> recursive functions, it doesnt seem to alert the
> correct values. I tried alerting
> 'preloader.getHeight()' and 'preloader.getWidth()'
> inside the recursive function. But the same effect(I
> always get 0 for height and width).
>
> Also I tried using
> qx.manager.object.ImagePreloaderManager.getInstance().create()
> call, facing similar issue.
>
> Any clarifications?
>
> Regards
> Balaji
>
>
> --- Sebastian Werner <[EMAIL PROTECTED]>
> wrote:
>
>> You can alternatively use the ImagePreloader class.
>> After the image has
>> been loaded this class can tell you the dimensions.
>>
>> Sebastian
>>
>>
>> kumar balaji schrieb:
>>> Hello,
>>> Am very young to QooxDoo and I need some
>> information
>>> about finding out the width of an image.
>>>
>>> for eg, lets say I have defined a variable
>> imagePlot
>>> as a basic image.
>>> var imagePlot = new
>> qx.ui.basic.Image("MyPic.PNG");
>>>
>>> After this, If I say
>>> 'alert(imagePlot.getWidthValue())' or
>>> 'alert(imagePlot.getHeightValue())', it always
>> returns
>>> 0, whereby am expecting the width and height of
>> the
>>> image.
>>> imagePlot.getWidth() and imagePlot.getHeight()
>> returns
>>> 'auto'. what does that mean?
>>>
>>> Is there any methods defined to compute height and
>>> width of an image? Can anybody clarify me?
>>>
>>> Regards
>>> Balaji
>>>
>>>
>>>
>>>
>>
> ______________________________________________________________________
> ______________
>>> We won't tell. Get more on shows you hate to love
>>> (and love to hate): Yahoo! TV's Guilty Pleasures
>> list.
>>> http://tv.yahoo.com/collections/265
>>>
>>>
>>
> ----------------------------------------------------------------------
> ---
>>> This SF.net email is sponsored by DB2 Express
>>> Download DB2 Express C - the FREE version of DB2
>> express and take
>>> control of your XML. No limits. Just data. Click
>> to get it now.
>>> http://sourceforge.net/powerbar/db2/
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> [email protected]
>>>
>>
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>>
>>
> ----------------------------------------------------------------------
> ---
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2
>> express and take
>> control of your XML. No limits. Just data. Click to
>> get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>>
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel