Results 1 to 13 of 13
-
March 11th, 2005, 07:18 AM #1389Registered User
postsThe baddest Flash discovery you will see today
globalToLocal() is broken.
globalToLocal() is broken.
globalToLocal() is broken.
globalToLocal() is broken.
globalToLocal() is broken.
Any questions?
So anyway, localToGlobal works fine. However globalToLocal is so broken it looks like some really bad use of sin() is going on. With it off, translating a point through a rotated object is fine. With it ON objects weave in and out of the screen and flicker every second frame. Which is exactly what happened when I originally wrote my own version of this function and got it completely wrong.
Fix it Macromedia.
-
March 11th, 2005, 07:23 AM #2
-
March 11th, 2005, 07:24 AM #3389Registered User
postsUno momento.
-
March 11th, 2005, 07:40 AM #4389Registered User
postshttp://darken.spark.lithotech.co.nz/globaltolocal.zip - 15mb
Apologies for the large size. Here's the only difference between these two movies:
Working:
Not working:Code:function update_location() { var point:Object = {x: this.initial_x, y: this.initial_y}; _root.World.Ground.Ground_Rotation.Ground_Position.Map.localToGlobal(point); //this.globalToLocal(point); this._x = point.x; this._y = point.y; }
In the end I got around the globalToLocal requirement by moving most of my movie's container objects to 0,0. Previously they were centered on the screen, which was just a nih-friendly thing.Code:function update_location() { var point:Object = {x: this.initial_x, y: this.initial_y}; _root.World.Ground.Ground_Rotation.Ground_Position.Map.localToGlobal(point); this.globalToLocal(point); this._x = point.x; this._y = point.y; }
Another thought that just occurred to me is that I have my processor overclocked. This can definitely affect which type of math operations are selected by programs, so let me know if in fact both of these movies work. The globalToLocal.swf should display the behaviour I'm talking about though.
-
March 11th, 2005, 07:54 AM #5
15mb is too big for me and I cant tell what you have going on there based on your code but Im a little confused in where the globalToLocal comes into play when it works without it? If it works, why have it at all?
Anyway, the biggest problem people have with these methods (and what may be your problem) is properly scoping them. For example, lets say you have this movie clip
_root.World.Ground.Ground_Rotation.Ground_Position .Map
And you want to position Map based on a global point. To convert that global point to a position for map, you would use
_root.World.Ground.Ground_Rotation.Ground_Position .globalToLocal(point);
since Map's positioning is based in the coordinate space of it's parent, Ground_Position.
-
March 11th, 2005, 08:03 AM #6389Registered User
postsIt gets trickier than that. These are my two paths:
_root.World.Ground.Ground_Rotation.Ground_Position .Map
_root.Pawns
Inside the path at the top are empty spawner objects. They create objects inside the _root.Pawn, hence the localtoGlobal then the globalToLocal. In this case it was safe enough to relocate Pawns to 0,0 and drop the globalToLocal as you said.
Ground_Rotation and Ground_Position as you may have guessed are getting all the transformations. The spawner object is actually much deeper inside that path, but we work out its position relative to the Map object (this.initial_x and this.initial_y) and use this as a point of reference instead, as the map tiles (and spawners) are loaded dynamically.
This is exactly what globalToLocal was designed for, and not having it working is a bit frustrating. At this point I would bank money on it not functioning correctly, although the reason escapes me. I'm starting to think overclocking and I'll try adjusting this later, in the meantime somebody who treats their PC gentler is welcome to let me know their own results.
-
March 11th, 2005, 08:07 AM #7389Registered User
postsAlso, just to check off every avenue I do indeed (or was trying to) localise the points relative to _root.Pawns and not its child object.
-
March 11th, 2005, 08:28 AM #8
-
March 13th, 2005, 02:21 AM #9389Registered User
postsThis is close to the structure I have, but not quite. In any case it looks like pairing up localToGlobal and globalToLocal is a bad idea, but individually they're ok.
-
March 13th, 2005, 08:58 AM #10
-
March 13th, 2005, 02:27 PM #11389Registered User
postsYeah, but as I said - it doesn't mirror the structure I have here nor any of the other factors that could be influencing it to break.
No matter, this wasn't really a query for help but I was trying to see if anyone else was experiencing this.
-
March 13th, 2005, 05:41 PM #12
-
March 13th, 2005, 07:44 PM #13389Registered User
postsNot at all. I'll explain my logic. For the sake of an example, here's two paths:
_root.someobject.rotatedobject.movedobject.blob
_root.someholder
First instance:
The top path has been transformed at various stages in the path. The second path is also transformed, but its just being offset and not rotated. In this instance we see movement of the objects on the terrain to be remarkably similar to the pink curve in this diagram. This indicates a missing step in a sin/cos calculation.
Second instance:
We relocate the second path to 0,0 thereby removing all transformations on it. At this point using globalToLocal() on that object should result in the values supplied being returned with no change made on them. Except that isn't what happens, and we still get the Taylor curve mentioned above.
Third instance:
With the second path at 0,0 we don't actually need to do another globalToLocal(). We remove it and the movie works perfectly.
If globalToLocal() were working and if it was indeed a bug in my code, instances two and three would produce the same results. It's simple, basic geometry.
The error could absolutely be caused by something else I'm doing somewhere in the movie - in fact I'm banking on it. A function that breaks with no interference whatsoever wouldn't make it into production, but some internal math or path operation that breaks under certain circumstances would.
What we have here is a bug, and by the looks of it nobody else has encountered it yet. Whatever, I'm going to pass it along to whoever thinks it's their job to fix it.
Similar Threads
-
Flash 5 - Flash MX problem...
By FIREWIGHT in forum Flash IDEReplies: 6Last Post: October 7th, 2007, 11:01 PM -
XML to TextField
By brendanwov in forum Best of Kirupa.comReplies: 56Last Post: May 29th, 2007, 06:52 AM -
Someone here must know website flash sound issues!
By pantherrun in forum Flash IDEReplies: 1Last Post: August 19th, 2004, 11:23 AM -
website flash player conflict part 2- need our vet sound geeks
By pantherrun in forum Flash IDEReplies: 0Last Post: August 18th, 2004, 10:20 PM -
Scroll Bar...why wont you work?
By ffoeg78 in forum Flash IDEReplies: 7Last Post: August 7th, 2003, 03:14 PM

Reply With Quote



Bookmarks