Hi,

Arrays are static properties in class1, you need to access them properly. 
Corrected your code, see below:


<code>

var areaUnitNames:Array = class1.areaUnitNames;
var areaUnitConvertRates:Array = class1.areaUnitConvertRates;

var len:Number = areaUnitNames.length;

while(i <= len ) {
                        if(areaUnitConvertRates[i] == prefix) {
                                rate_ = parseFloat(areaUnitConvertRates[i]);
                                break;
                        }
                        i++;
                }



</code>


It should work now...


-abdul


-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of mtoppine
Sent: Monday, August 01, 2005 11:41 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Using of an class with arrays

Hi all!

I´ll have an problem with actionscript right now. 

I'll have two classes: class1 and class2. The class1 consists from
arrays like this:

public static var areaUnitNames:Array  = [
     "meter^2",
     "mm^2", "cm^2", "hectare", 
     "km^2", "in^2", "ft^2",
     "yd^2", "rood", "acre",
     "mile^2"
     ];


--------------------------------------------

  public static var areaUnitConvertRates:Array = [
     1.0,
     1E-6, 1E-4, 1E4,
     1E6, 6.4516E-4, 9.290304E-2,
     8.3612736E-1, 1.01171E3, 4.0468564224E3,
     2.58998811E6 
     ];

In the class2 I´m trying to create an new instance from class1 like this:

import class1;

private var rates:class1;
rates = new class1();

and then I´m trying to go through the arrays in the class like this:

                //Area units array
                while(i <= rates.areaUnitNames.length) {
                        if(rates.areaUnitConvertRates[i] == prefix) {
                                rate_ = 
parseFloat(rates.areaUnitConvertRates[i]);
                                break;
                        }
                        i++;
                }


The problem is that I can´t get out any data from the arrays. The
.length method doesn´t work eather. It returns only undefined.

Thanks for your answers!











--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hmeg99d/M=362329.6886308.7839368.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1122885169/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to