I am new to AS3. I have 2 files:
main.as:
package
{
import flash.display.*;
public class Main extends Sprite
{
public function Main()
{
var f0:Flower = new Flower("rose");
var f1:Flower = new Flower("daisy");
}
}
}
Flower.as:
package
{
public class Flower
{
public var namex:String;
public function Flower(name:String)
{
trace("Previous public var name: " + namex);
namex = name;
}
}
}
Basically, I get 2 nulls in my output. The first one I understand why; when I first trigger
var f1:Flower = new Flower("rose");
It calls the flower's function and demands a trace of a var which has not been set yet, so therefore we get a null. After the trace it sets the var with
namex = name;
which is the value string rose. but then, when I trigger the flower daisy, I am supposed(in my opinion) to receive this message: "Previous public var: rose", because when we triggered rose we told him to set public var namex to the value which we first supplied in main(rose). So why do I get 2 nulls instead of 1 null, shouldn't the other be "Previous public var: rose";
Another thing, can I get a clear explanation about what
var f1:Flower = new Flower("rose");
does exactly? does it create an object? an instance? or is it only supplying a value(rose) to the function in flower.as?