View Full Version : AN.Controller.startSceneById no longer recognized in version 1.3
4 Jul 2012, 6:51 AM
Hey, I am using this animator for half of my project and the other half I'm writing by hand. I need to tie into the controller to tell it which scene to go to directly from the page select screen I made. I had this working perfectly in in version 1.2 but last night I upgraded to 1.3 (build 171)and everything that used the AN.Controller broke and throws the error "Object has no method 'startSceneById'"
This confuses me as I've looked at the new controller object and it should still return that method correctly. Any help on how to get startSceneById() working correctly would be greatly appreciated
5 Jul 2012, 8:22 AM
Yeah, there is a slight change. The AN.Controller is a "class" that is instantiated into separate objects that are the actual controller(s). To tie into your existing code you could for example try either of these approaches
1) Set the project property panel -> actions -> start action to store the controller in a global variable e.g.
"myController = controller;"
Then you can access the controller from the global "myController" object.
2) If you load your js before the animation js loaded, you could add a method for connection e.g
"yourFramework.setController(controller)" in the same project start action method.
7 Jul 2012, 8:08 AM
Thanks for the speedy response. I just got a chance to read it and I'm sort of confused. I've gotten the controller in a global variable already. When I reference it by myController.startSceneById(''), I am told startSceneById('') isn't a method of the myController object. I have looked at the code and that method should still be valid as myController should be returning the whole AN.Controller.
I guess my question should of been, what is the new syntax for calling controller.startSceneById('').
If there are any other ways I can dictate which scene is started by an ID number, that'd be great also :)).
Thanks for your time
8 Jul 2012, 12:43 AM
The syntax should be the same. The difference is that AN.Controller used to be the controller itself, now it is just the "template" for new controllers.
Make sure that in your project start action you have set
"myController = controller;"
since the "controller" is the actual instance of the controller.
"myController = AN.Controller;"
I tried this and I could call
"myController.startSceneByID(..)" without problems.
Another issue could be that you are trying to call the controller before it is loaded?
8 Jul 2012, 7:11 PM
I was setting my global variable to controller but not getting an error that it didn't exist. I moved where I set my variable to the bottom of the setTimeout that sets the config data for the controller and that seemed to do it. Most likely I was setting it before controller loaded. Thanks a lot for your help!
Powered by vBulletin® Version 4.1.5 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.