July 21, 2008

Flash woes

As far as I can tell, in Flash ActionScript 2.0 there's no easy way for an object to determine its absolute position on the table. this._x and this._y give you your position relative to your parent's coordinate system -- which usually is what you want. But I also want something akin to an "_absx" and "_absy" that tell me where I am relative to the table, and that's not there.

So what you gotta do is this:

my_x = this._x + _parent._x + _parent._parent._x;

Or however deep you're nested. Which, in turn, means that your actionscript does need to know how deep you're nested, which makes the object less than fully flexible. (Or it means your nesting objects all have to be homed at 0,0, so they can't be moved around. That's even less flexible and it defeats the purpose of having nesting objects.)

Reason I got into this was because I was trying to create an object that would rubber-band a line between one object and another no matter where they moved. The source object and destination object are both nested inside of other objects, and that's a pain.

Also, high school trigonometry was 40 years ago, and I didn't take that course anyway. Yeesh. Still, I finally got it working. (It didn't help that the coordinate system is weird, and all the Flash trig functions work in radians, but the _rotation attribute takes its parameters in degrees, and so on and so on. Weirdness in the key of F.)

You may have noticed that I haven't been saying much about the bionic ducks lately. That's because they haven't been around for maybe the last month or so. I wondered if something had happened to them, and went for a walk last week. Plenty of ducks in the stream down next to the bus station (including some hens with ducklings), but none here. I thought about it and realized why: it's because the brush has grown up around our section of the stream, so it isn't possible any longer for the ducks to walk from our mowed lawn down to the water. Ducks are uncomfortable in places where there's no easy access to water. Also, with the brush hanging over the stream, it feels really narrow and there's plenty of places for predators to hide and pounce on passing ducks. (There aren't any predators, of course, but the ducks don't know that.) So there's only been one hen around here, and her only occasionally. She showed up this morning and ate a lot of my bread, though.

Unless Alex, our complex handy-man, gets going with his weed cutter and clears the bank of the stream, it's probably going to be like this until the growing season ends. Or maybe it'll be up to me; I've entertained the idea of buying a sickle and clearing a section of it myself. But I probably shouldn't do that; it's everyone's yard and other people might object.

Posted by: Steven Den Beste in Daily Life at 04:42 PM | Comments (9) | Add Comment
Post contains 496 words, total size 3 kb.

1 Are you sure it's not just camoflage?

I mean really sure?  Mwah-ha-ha-ha-ha-haaaaaaaaa!

Posted by: Wonderduck at July 21, 2008 06:03 PM (AW3EJ)

2 Of course. The anti-bionic-duck death ray has a proximity alarm, and it hasn't been going off.

Posted by: Steven Den Beste at July 21, 2008 06:24 PM (+rSRq)

3 Now that's good camoflage!  Mwah-ha-ha-ha-ha-haaaaaaaaaaaa!

Posted by: Wonderduck at July 21, 2008 07:13 PM (AW3EJ)

4 In your dreams.

Posted by: Steven Den Beste at July 21, 2008 07:54 PM (+rSRq)

5 Or in your nightmares!  Mwah-ha-ha-ha-ha-haaaaaaaaaaaaaaaaaa!!!

Posted by: Wonderduck at July 21, 2008 09:25 PM (AW3EJ)


I'll put my faith in the anti-bionic-duck death ray.

Go on! Make my day!

Posted by: Steven Den Beste at July 21, 2008 09:28 PM (+rSRq)


Steven, can't you just recurse?

while (pops != null) { x = x + pops._x; pops = pops.parent; }

or something along those lines--I don't know Flash at all.


As for the ducks, if you go at the underbrush with a scythe, you will most likely not have to worry about what your neighbors think in the way you are currently envisioning.

Posted by: RickC at July 22, 2008 06:58 AM (rBD+D)

8 You do the same recursion using JavaScript in HTML, with the added bonus of having to compensate for browser layout bugs. It's one of the reasons almost everyone is using big JS libraries these days that contain all the necessary high-level calls and workarounds. I think I spent three hours trying to get my pop-up furigana to appear in the right place in most browsers, and there are still corner cases where they're a bit off in some browsers.


Posted by: J Greely at July 22, 2008 07:28 AM (9Nz6c)

9 Did you sleep well, Steven?  Mwah-ha-ha-ha-ha-haaaaaaaaaaaaaaaaaa!!!

Posted by: Wonderduck at July 22, 2008 03:21 PM (AW3EJ)

Hide Comments | Add Comment

Enclose all spoilers in spoiler tags:
      [spoiler]your spoiler here[/spoiler]
Spoilers which are not properly tagged will be ruthlessly deleted on sight.
Also, I hate unsolicited suggestions and advice. (Even when you think you're being funny.)

At Chizumatic, we take pride in being incomplete, incorrect, inconsistent, and unfair. We do all of them deliberately.

How to put links in your comment

Comments are disabled. Post is locked.
10kb generated in CPU 0.006, elapsed 0.0153 seconds.
21 queries taking 0.0105 seconds, 26 records returned.
Powered by Minx 1.1.6c-pink.