Jump to content
GreenSock

pepe

TransformManager (AS2) eventHandler: instance vars [SOLVED]

Recommended Posts

hi, i´m developing some stuff with the TransformManager class, and it was all working perfectly. Then, i added an event handler function, like the example below:

(this is an example code, only important code is shown)

 

class TestClass
{
private var test_string:String = "TEST";

           public function TestClass() {
                  transformManager_obj = new TransformManager({ [b]eventHandler:onTransformObject[/b], forceSelectionToFront:true, allowDelete:true, bounds: { xMin:_xMin, xMax:_xMax, yMin:_yMin, yMax:_yMax } } );
           }

private function onTransformObject(event_obj:Object):Void {
trace("onTransformObject "+test_string);
trace("Action: " + event_obj.action + ", MovieClip: " + event_obj.targetObject + ", transformed?: " + event_obj.transformed);
}

 

The function is called correctly, because the second trace works perfectly, but the fisrt trace outputs: "onTransformObject: undefined".

test_string is an instance variable, i have tried with other instance variables, or calling other functions within the class but none are called. And if i call "onTransformObject" directly from the contrsuctor or other functions, the first trace works correctly.

 

Any ideas?

 

Thanks in advance!

Link to comment
Share on other sites

Ah, the joys of working with AS2. :)

 

It's a scope issue. Delegate.create() is your friend.

 

eventHandler:Delegate.create(this, onTransformObject)

 

(don't forget to import mx.utils.Delegate)

Link to comment
Share on other sites

Thanks Jack! It´s incredibly how fast you reply!

I should have known it was the Delegate... :oops:

Now it´s working perfectly!!!

 

Thanks Again!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×