Re: [Flashcoders] Adding a property to an AS3-component

2009-01-26 Thread Alexander Farber
Thanks Dave, I've read up on it and understand this now.

Too bad Flash docs do not mention which class is dynamic

Regards
Alex

On Sat, Jan 24, 2009 at 6:14 PM, Dave Watts dwa...@figleaf.com wrote:
 is it actually possible to add a new property
 to an AS3-component, like button?

 In AS3, classes will only allow this if they're dynamic classes, and
 most classes aren't dynamic. You could, however, write a new class to
 extend Button.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Adding a property to an AS3-component

2009-01-26 Thread Ian Thomas
On Mon, Jan 26, 2009 at 9:00 AM, Alexander Farber
alexander.far...@gmail.com wrote:
 Thanks Dave, I've read up on it and understand this now.

 Too bad Flash docs do not mention which class is dynamic

At the top of the documentation page:
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/MovieClip.html

It says under Class:
'public _dynamic_ class MovieClip'

HTH,
   Ian
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] top down plane games

2009-01-26 Thread David Hershberger
I may be misunderstanding the trouble you are having, but are you looking
for sine and cosine?

var velocity: Number = 3; // Absolute velocity, regardless of direction
speedX = velocity * Math.cos( cursorAngle ); // X component of velocity
speedY = velocity * Math.sin( cursorAngle ); // Y component of velocity

Or, since you are starting with a dx,dy and computing an angle from that,
you can just normalize the vector to whatever length (speed) you want.:

var velocityVector: Point = new Point( dx, dy );
velocityVector.normalize( velocity ); // Set length of vector but preserve
direction
speedX = velocityVector.x;
speedY = velocityVector.y;

Dave

On 1/25/09, Corban Baxter corb...@gmail.com wrote:

 thanks todd. thats what I have been doing for the most part. I'm
 working on figuring out how to move the Camera sprite around on an
 angle.

 i've got script that makes the airplane point towards the mouse at all
 times. but thats the easy part. now i need the Camera sprite to move
 at a consistent rate at the same angle the plane is pointing. Just
 can't see to figure out what it take to do that.

 var minXMove:Number = 0;
 var minYMove:Number = 0;
 var maxXMove:Number = (levelMap.width - stage.stageWidth) * -1;
 var maxYMove:Number = (levelMap.height - stage.stageHeight) * -1;

 stage.addEventListener(Event.ENTER_FRAME, pointAtCursor);

 function movemap():void {


 //move on x-axis
 levelMap.x += speedX;

 if (levelMap.x = minXMove) {
 levelMap.x = minXMove;
 }
 if (levelMap.x = maxXMove) {
 levelMap.x = maxXMove;
 }


 //move on y-axis
 levelMap.y += speedY;

 if (levelMap.y = minYMove) {
 levelMap.y = minYMove;
 }
 if (levelMap.y = maxYMove) {
 levelMap.y = maxYMove;
 }
 }

 function pointAtCursor(e:Event) {

 // get relative mouse location
 var dx:Number = mouseX - plane.x;
 var dy:Number = mouseY - plane.y;
 speedX = (dx * -1);
 speedY = (dy * -1);

 // determine angle, convert to degrees
 var cursorAngle:Number = Math.atan2(dy,dx);
 var cursorDegrees:Number = 360*(cursorAngle/(2*Math.PI));

 // point at cursor
 plane.rotation = cursorDegrees;

 plane.x -= (plane.x-mouseX) / 6;
 plane.y -= (plane.y-mouseY) / 6;

 movemap();

 }

 the hard part is getting the speedX and speedY to be numbers that
 don't cause the map to fly to fast. Just not sure where to go from
 here.





 On Sun, Jan 25, 2009 at 2:42 PM, Todd Kerpelman t...@kerp.net wrote:
  Well, I'm no plane game expert, but here's probably how I'd approach
 it...
 
  Within your PlaneGame movie, create a child sprite called Camera.
 
  Make all your interface stuff children of the PlaneGame movie. But make
 the
  background, your plane, the enemies, etc, all children of this Camera
 child
  sprite.
 
  Then, when it comes to creating the background scrolling below you
 look,
  don't have your background move at all. Only have the things that would
  actually move in real life (planes and tanks and whatever) move.
 
  Instead, make your Camera sprite scale and/or move itself to track your
  plane (or, even better, a point a couple hundred pixels in front of your
  plane.) That will make it look like the background is moving, but it's
  really staying in place. And it will simplify your planes and tanks and
  bullets, because you can basically just look at each sprite's position
 and
  velocity, without having to try and somehow compensate for a magical
 moving
  background.
 
  For development purposes, by the way, I would start your game by not
 having
  the camera move at all, and just making sure everything works right in a
  tiny little world the size of your screen. Once that's working, then you
 can
  enlarge the bounds of your world and start moving your camera around.
 
  Good luck!
 
  --T
 
 
 
  On Sun, Jan 25, 2009 at 11:16 AM, Corban Baxter corb...@gmail.com
 wrote:
 
  hey guys! I'm trying to build a simplified version of
  http://www.miniclip.com/games/skies-of-war/en/. Mostly looking to
  replicated the movement. But I have no ideas on where to start. I'm
  having alot of trouble setting the angles correctly to give the
  background a constant speed but allowing it to change angles. I
  understand its going to be based on the planes current angle. But
  that's where I get confused on getting the speeds to not over lap and
  making it seem like it moving faster. Ok I'm rambling now. but I was
  hoping someone might be able to help me understand this better and
  give me some examples I could use to get moving. Any help would be
  great! thanks!
 
  --
  Corban Baxter
  http://www.projectx4.com
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  

RE: [Flashcoders] top down plane games

2009-01-26 Thread Merrill, Jason
I think you should definitely consider picking up this book and going through 
the animation and physics lessons:

Foundation Actionscript 3.0 Animation by Keith Peters (published by Friends of 
Ed)

I just picked it up and have been really impressed with it - there is a lot of 
discussion on trigonometry, physics, 3d, and general advanced pure-Actionscript 
flash animation topics.  A lot of what has been discussed in this thread is 
also covered in the book.  http://www.friendsofed.com/book.html?isbn=1590597915 


Jason Merrill
Bank of America Instructional Technology  Media   ·   GCIB  Staff Support 
LLD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] top down plane games

2009-01-26 Thread Todd Kerpelman
Well, again, don't know how much this will help you, but in the past when
I've done a camera following a moving object with a scrolling background,
I've attached a virtual spring from my camera to the position I want to go
to and then just let the spring drag my camera to the right place. If you
put on some pretty heavy damping, it ends up looking pretty good, and I
don't have to think about angles. :)

Your spring code would probably look something like this...

private function onEnterFrame(e:Event):void
{

var accelX:Number = (_pointToFollow.x - this.x) * _k;
var accelY:Number = (_pointToFollow.y - this.y) * _k;
_velX += accelX;
_velY += accelY;
this.x += _velX;
this.y += _velY;
_velX *= _damping;
_velY *= _damping;

}

You probably want _k to be something in the .1 range, and _damping to be in
the .75 range. All of this assumes, by the way, that you're not rotating the
camera to match the rotation of the plane.

But the book Jason recommended might have better ideas. I haven't read it
yet.

--T



On Sun, Jan 25, 2009 at 1:15 PM, Corban Baxter corb...@gmail.com wrote:

 thanks todd. thats what I have been doing for the most part. I'm
 working on figuring out how to move the Camera sprite around on an
 angle.

 i've got script that makes the airplane point towards the mouse at all
 times. but thats the easy part. now i need the Camera sprite to move
 at a consistent rate at the same angle the plane is pointing. Just
 can't see to figure out what it take to do that.

 var minXMove:Number = 0;
 var minYMove:Number = 0;
 var maxXMove:Number = (levelMap.width - stage.stageWidth) * -1;
 var maxYMove:Number = (levelMap.height - stage.stageHeight) * -1;

 stage.addEventListener(Event.ENTER_FRAME, pointAtCursor);

 function movemap():void {


//move on x-axis
levelMap.x += speedX;

if (levelMap.x = minXMove) {
levelMap.x = minXMove;
}
if (levelMap.x = maxXMove) {
levelMap.x = maxXMove;
}


//move on y-axis
levelMap.y += speedY;

if (levelMap.y = minYMove) {
levelMap.y = minYMove;
}
if (levelMap.y = maxYMove) {
levelMap.y = maxYMove;
}
 }

 function pointAtCursor(e:Event) {

// get relative mouse location
var dx:Number = mouseX - plane.x;
var dy:Number = mouseY - plane.y;
speedX = (dx * -1);
speedY = (dy * -1);

// determine angle, convert to degrees
var cursorAngle:Number = Math.atan2(dy,dx);
var cursorDegrees:Number = 360*(cursorAngle/(2*Math.PI));

// point at cursor
plane.rotation = cursorDegrees;

plane.x -= (plane.x-mouseX) / 6;
plane.y -= (plane.y-mouseY) / 6;

movemap();

 }

 the hard part is getting the speedX and speedY to be numbers that
 don't cause the map to fly to fast. Just not sure where to go from
 here.




 On Sun, Jan 25, 2009 at 2:42 PM, Todd Kerpelman t...@kerp.net wrote:
  Well, I'm no plane game expert, but here's probably how I'd approach
 it...
 
  Within your PlaneGame movie, create a child sprite called Camera.
 
  Make all your interface stuff children of the PlaneGame movie. But make
 the
  background, your plane, the enemies, etc, all children of this Camera
 child
  sprite.
 
  Then, when it comes to creating the background scrolling below you
 look,
  don't have your background move at all. Only have the things that would
  actually move in real life (planes and tanks and whatever) move.
 
  Instead, make your Camera sprite scale and/or move itself to track your
  plane (or, even better, a point a couple hundred pixels in front of your
  plane.) That will make it look like the background is moving, but it's
  really staying in place. And it will simplify your planes and tanks and
  bullets, because you can basically just look at each sprite's position
 and
  velocity, without having to try and somehow compensate for a magical
 moving
  background.
 
  For development purposes, by the way, I would start your game by not
 having
  the camera move at all, and just making sure everything works right in a
  tiny little world the size of your screen. Once that's working, then you
 can
  enlarge the bounds of your world and start moving your camera around.
 
  Good luck!
 
  --T
 
 
 
  On Sun, Jan 25, 2009 at 11:16 AM, Corban Baxter corb...@gmail.com
 wrote:
 
  hey guys! I'm trying to build a simplified version of
  http://www.miniclip.com/games/skies-of-war/en/. Mostly looking to
  replicated the movement. But I have no ideas on where to start. I'm
  having alot of trouble setting the angles correctly to give the
  background a constant speed but allowing it to change angles. I
  understand its going to be based on the planes current angle. But
  that's where I get confused on getting the speeds to not over lap and
  making it seem like it moving faster. Ok I'm rambling now. but I was
  hoping someone might be able to