Newbie question here: I'm working with Flash Builder 4.5 on an Actionscript project. I've created the following classes:
package
{
public class ComplexNumber
{
public var real:Number; // real component
public var imag:Number; // imaginary component
}
}
and,
package
{
public class ComplexArray
{
public var real:Array; // real component array
public var imag:Array; // imaginary component array
}
}
and a static function:
package
{
public class ComplexDivide
{
public static function v1p0(a:Number, b:Number, // numerator: a+bi
c:Number, d:Number // denominator: c+di
):ComplexNumber
{
var z:ComplexNumber = new ComplexNumber();
var divisor:Number = c*c + d*d;
z.real = (a*c + b*d) / divisor; // real component
z.imag = (b*c - a*d) / divisor; // imaginary component
return z;
}
}
}
and in another .as file I'm trying to call this function
var BXFN_complex:ComplexArray = new ComplexArray();
for (var ii:int = 0; ii <= 2; ii++) {
BXFN_complex[ii] = ComplexDivide.v1p0( 1, 0, 2, 3 );
}
but the code inside this loop generates the following run time error: "ReferenceError: Error #1056: Cannot create property 0 on ComplexArray." Thus, my code for "BXFN_complex[ii] = ~" is incorrect. Anyone know how to achieve what I'm trying to do? Basically, ComplexDivide.v1p0 returns two numbers, and BXFN_complex is an object containing two number arrays, and I want to assign the ComplexDivide two numbers into the ii'th element of arrays in BXFN_complex.