About Orland MediaDevelopmentTrainingBlogRSS FeedContact us
Microphone

localToGlobal() in AS3 not working

Date: Wednesday 13th May 2009
Time: 17:06
Category: ActionScript 3.0
Views: 3,427
Comments: 15 Comments

localToGlobal() not working? The LiveDocs on this potentially very useful method, along with its partner globalToLocal() are not actually very helpful.

What they don’t make clear is that you need to be sure to overwrite your point when using it:

// WRONG:
var pt:Point = new Point(target.x, target.y);
target.parent.localToGlobal(pt);
parent.globalToLocal(pt);

// RIGHT:
var pt:Point = new Point(target.x, target.y);
pt = target.parent.localToGlobal(pt);
pt = parent.globalToLocal(pt);

Simply running a localToGlobal() method on a point in a given scope is not enough. You need to write the result back into the point. You might be forgiven for not seeing this, because it was not necessary for the equivalent method in AS2!

localToGlobal() and globalToLocal() can be the source of considerable frustration, especially as this differences such as this are not mentioned by Adobe. But properly understood these methods are not complicated. If this post helped you please let us know. :)

Rate this post
1 star2 stars3 stars4 stars5 stars   (16 votes, average: 4.25 out of 5)

AS3 course in July

Date: Thursday 7th May 2009
Time: 16:59
Category: ActionScript 3.0
Views: 572
Comments: No comments

Our next Applied ActionScript 3.0 course will more than likely be scheduled for early July, 2009.

The course is limited to only 5 delegates. If you would like to reserve a place please let us know – we’d be happy to have you there.

Rate this post
1 star2 stars3 stars4 stars5 stars   (Roll over and click)

Error #1007: Instantiation attempted on a non-constructor with APE

Date: Friday 1st May 2009
Time: 11:40
Category: ActionScript 3.0
Views: 4,363
Comments: No comments

We’re using APE – the ActionScript Physics Engine – for our current project.

If you run into the TypeError:

Error #1007: Instantiation attempted on a non-constructor

..when compiling with Flash CS4, the reason is that APE defines a class called Vector, which clashes with a new class, of a different kind, in Flash 10, also called Vector.

The solution is to either avoid publishing for Flash 10, if you don’t need it, or replace all references to Vector throughout the APE code with the fully qualified reference org.cove.ape.Vector.

Rate this post
1 star2 stars3 stars4 stars5 stars   (Roll over and click)
Lenovo Microsoft Adobe Heart Internet Envirowise
Copyright © 2008 Orland Media Ltd | All rights reserved Company details Ethical policy Terms & conditions Privacy policy