randyHurd
randyHurd

Reputation: 64

Alternative syntax for as3 x and y positions

I have looked everywhere, because I remember seeing something like this. Typically I write x and y coordinates out one line at a time, but I've seen it done differently, but I cannot remember how, or figure it out on my own. I will show you some of the syntax I have been trying, and maybe someone will see what I'm getting at.

var frog = new Frog;

addchild(frog);
frog.x = 100;
frog.y = 100;
// above works, and is typical for me.

// below is what I'm trying.
addChild(frog);
frog(x:100,y:100);

// or maybe
addChild(frog(100,100)); // doesn't work

Basically I'm looking for shorthand. Perhaps I seen it before, but didn't note the context, but It would be nice to trim a lot of my code down. And I hate thinking that I've been doing things the hard way all along.

Upvotes: 0

Views: 35

Answers (1)

Marty
Marty

Reputation: 39456

If your constructor in Frog was like this:

public function Frog(x:Number = 0, y:Number = 0)
{
    this.x = x;
    this.y = y;
}

Then:

var frog:Frog = new Frog(100, 100);

Would work.

Upvotes: 1

Related Questions