Forum Topic: Vectors in AS3

(111 views • 8 replies)

This topic is 1 page long.

<< < > >>
None

kizza0

Reply To Post Reply & Quote

Posted at: 11/3/09 10:31 PM

kizza0 NEUTRAL LEVEL 08

Sign-Up: 10/13/07

Posts: 276

To represent vectors in AS3, is it anything like this?
v={
p0:{x:10, y:5},
vx:2,
vy:1
};

BOOM HEADSHOT

BBS Signature

None

CloudEater

Reply To Post Reply & Quote

Posted at: 11/3/09 10:56 PM

CloudEater LIGHT LEVEL 02

Sign-Up: 10/17/09

Posts: 295

Do you want to draw the vector? Cod here's a good tutorial on how to draw them > Drawing Vectors

Why don't you just make an array?
var v:Array = newArray(10, 5, 2, 1);


None

kizza0

Reply To Post Reply & Quote

Posted at: 11/3/09 11:21 PM

kizza0 NEUTRAL LEVEL 08

Sign-Up: 10/13/07

Posts: 276

No, i understand how to draw lines, thanks anyway. I'd usually use an array but this gives no errors.
var v={p0:{x:10, y:5},vx:2,vy:1};
What is it?

BOOM HEADSHOT

BBS Signature

None

Fion

Reply To Post Reply & Quote

Posted at: 11/3/09 11:36 PM

Fion LIGHT LEVEL 34

Sign-Up: 08/21/05

Posts: 2,374

At 11/3/09 11:21 PM, kizza0 wrote: No, i understand how to draw lines, thanks anyway. I'd usually use an array but this gives no errors.
var v={p0:{x:10, y:5},vx:2,vy:1};
What is it?

It's just an object with an object and two variables attached.


None

CloudEater

Reply To Post Reply & Quote

Posted at: 11/3/09 11:39 PM

CloudEater LIGHT LEVEL 02

Sign-Up: 10/17/09

Posts: 295

At 11/3/09 11:36 PM, Fion wrote:
At 11/3/09 11:21 PM, kizza0 wrote: No, i understand how to draw lines, thanks anyway. I'd usually use an array but this gives no errors.
var v={p0:{x:10, y:5},vx:2,vy:1};
What is it?
It's just an object with an object and two variables attached.

How would you locate those variables? would it be v.p0.x, v.p0.y, v.vx & v.vy?


None

Fion

Reply To Post Reply & Quote

Posted at: 11/3/09 11:41 PM

Fion LIGHT LEVEL 34

Sign-Up: 08/21/05

Posts: 2,374

At 11/3/09 11:39 PM, CloudEater wrote: How would you locate those variables? would it be v.p0.x, v.p0.y, v.vx & v.vy?

Yeah:

var v ={p0:{x:10, y:5},vx:2,vy:1};
trace(v.p0.x); //outputs 10
trace(v.p0.y); //outputs 5
trace(v.vx); //outputs 2
trace(v.vy); //output 1

None

CloudEater

Reply To Post Reply & Quote

Posted at: 11/3/09 11:52 PM

CloudEater LIGHT LEVEL 02

Sign-Up: 10/17/09

Posts: 295

At 11/3/09 11:41 PM, Fion wrote: Yeah

That's good. Would this work in AS2?


None

Fion

Reply To Post Reply & Quote

Posted at: 11/3/09 11:56 PM

Fion LIGHT LEVEL 34

Sign-Up: 08/21/05

Posts: 2,374

At 11/3/09 11:52 PM, CloudEater wrote: That's good. Would this work in AS2?

Certainly would.


None

henke37

Reply To Post Reply & Quote

Posted at: 11/4/09 01:35 AM

henke37 NEUTRAL LEVEL 23

Sign-Up: 09/10/04

Posts: 3,613

flash.geom.Vector3D, exactly what you wanted, and implemented in native code for that extra speed boost.

Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.


All times are Eastern Standard Time (GMT -5) | Current Time: 04:26 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!