Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I looked at using static variables but that was a little messy, I also looked at using Dependency Injection but spending a few hours to set up the framework and get it running is to costly when all I am doing is passing parameters on a popView, so what I came up with is the similar approach I have used when doing Native Android Apps with the Android SDK. A Singleton with getters and setters. Basically the way I have been able to do this is with the use of a Singleton sharedInstance. See code below:</p> <pre><code>package com.controls.Text { import flash.utils.Dictionary; [Bindable] public class ParameterManager { private static var instance:ParameterManager = new ParameterManager(); private var dictionary:Dictionary=new Dictionary(); public function ParameterManager( ) { if (instance != null) { throw new Error('Must use ParameterManager.getInstance().') } } public static function getInstance(): ParameterManager { return instance; } public function setParameter(key:*, value:*):void { dictionary[key]=value; } public function getParameter(key:*):* { return dictionary[key]; } } } </code></pre> <p>The method setting the value of the parameter:</p> <pre><code> protected function myList_changeHandler(event:IndexChangeEvent):void { var listViewReturnObject:String = new String(); listViewReturnObject = list.selectedItem.DMV_VALUE_1; ParameterManager.getInstance().setParameter("selectedItem", listViewReturnObject); navigator.popView(); } </code></pre> <p>The method getting the value:</p> <pre><code> protected function control_creationCompleteHandler(event:FlexEvent):void { var listViewReturnObject:Object = new Object(); listViewReturnObject= ParameterManager.getInstance().getParameter("selectedItem"); if (listViewReturnObject != null) { dataTxt.text= String(listViewReturnObject); ParameterManager.getInstance().setParameter("", null); //Make sure objects are cleared when done. } } </code></pre>
 

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