Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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:</p> <pre><code>public class MyWrapperClass extends EventDispatcher { [Event(name="webserviceComplete", type="flash.events.Event")] public function MyWrapperClass(target:IEventDispatcher=null) { super(target); } private function handleWebServiceLoadComplete(event:ResultEvent):void { dispatchEvent(new Event("webserviceComplete")); } public function doWork():void { // Load the service, etc., and ultimately call handleWebServiceLoadComplete()... } } </code></pre> <p>... and your Main.mxml file like this:</p> <pre><code>&lt;mx:Script&gt; &lt;![CDATA[ private function app_creationComplete(event:Event):void { var myWrapper:MyWrapperClass = new MyWrapperClass(); myWrapper.addEventListener("webserviceComplete", mywrapper_webServiceComplete, false, 0, true); myWrapper.doWork(); } private function mywrapper_webServiceComplete(event:Event):void { // Do the work you would've otherwise done in the public method } ]]&gt; &lt;/mx:Script&gt; </code></pre> <p>In this case, the end result is the same -- completing the web-service load triggers the function in Main.mxml. But notice how <code>mywrapper_webServiceComplete()</code> is declared privately -- it's not called directly by <code>MyWrapperClass</code>. Main.mxml simply subscribes (with <code>addEventListener()</code>) 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 a <code>webserviceComplete</code> event, and exposes a public <code>doWork()</code> method. Loose coupling and information hiding in action.</p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload