looks like you have it sorted, but just to add more information in case someone else comes along to this question, you generally see this error when you are trying to use something that hasn't been created yet. A lot of the time you will see it when trying to access UI components that have not yet been created (its good to rely on the creationComplete event for these sort of things), but in this case it looks like you are using the webservice before it is completely ready (the wsdl hasnt been loaded yet).
Just so you know, you can also define your webservices in mxml (mx:webservice) and specify the wsdl there or you can also load the wsdl later on from a configuration file afterwards just by referencing the ID.
You don't have to make the method static; doing so would likely be useless, as you'd want the method call to do something with the component's current state, I'm guessing -- use some of its data, change its appearance, etc. What you really need is an object reference.
Since Application.application resides at the top (or actually very close to the top) of the fabled Display List, you should be able to access each component by starting at that point and then traversing the Display List -- until ultimately, upon arriving at your nested component, calling its publicly defined method.
However, I must say (with the utmost respect!) that you're venturing into dangerous OO waters, here. :) The right way to do this would really be to figure out some way to pass a reference to your custom component to the ActionScript class that requires access to it -- for example, in your MXML:
<mx:Script>
<![CDATA[
private function this_creationComplete(event:Event):void
{
var yourObject:YourClass = new YourClass(yourCustomComponent);
}
]]>
</mx:Script>
<components:YourCustomComponent id="yourCustomComponent" />
... and then in your ActionScript class:
public class YourClass
{
private var componentReference:YourCustomComponent;
public function YourClass(component:YourCustomComponent)
{
this.componentReference = componentReference;
}
private function yourMethod():void
{
this.componentReference.someMethodDefinedInYourComponent();
}
}
An approach like that would probably serve you better. Does it make sense? I'll keep an eye our for comments; post back and I'll do my best to help you through it.
Best Answer
David is right -- while you can access the public members of your Application.mxml object statically and from anywhere in your application, design-wise that's a bit of a no-no. It's better to strive for loose coupling between your objects, and the way that's done in the Flex idiom is generally to extend EventDispatcher and to dispatch events. So for example, your WebService wrapper might look something like this:
... and your Main.mxml file like this:
In this case, the end result is the same -- completing the web-service load triggers the function in Main.mxml. But notice how
mywrapper_webServiceComplete()
is declared privately -- it's not called directly byMyWrapperClass
. Main.mxml simply subscribes (withaddEventListener()
) to be notified when MyWrapperClass is finished doing its work, and then does its own work; MyWrapperClass knows nothing about the details of Main.mxml's implementation, nor does Main.mxml know anything about MyWrapperClass other than that it dispatches awebserviceComplete
event, and exposes a publicdoWork()
method. Loose coupling and information hiding in action.Good luck!