Repository: flex-asjs
Updated Branches:
  refs/heads/develop 27256ce84 -> 670bbaa0a


Modified some examples to remove circular-dependencies from the code.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/670bbaa0
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/670bbaa0
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/670bbaa0

Branch: refs/heads/develop
Commit: 670bbaa0ab544292e332e6a3d9d3c20c5f9418d0
Parents: 27256ce
Author: Peter Ent <[email protected]>
Authored: Thu Aug 18 14:10:40 2016 -0400
Committer: Peter Ent <[email protected]>
Committed: Thu Aug 18 14:10:40 2016 -0400

----------------------------------------------------------------------
 examples/flexjs/DataBindingExample/pom.xml      |  1 -
 .../src/controllers/MyController.as             | 55 ++++++++++++--------
 .../src/controllers/MyController.as             | 55 ++++++++++++--------
 .../src/controllers/MyController.as             | 55 ++++++++++++--------
 examples/flexjs/TodoListSampleApp/pom.xml       |  1 -
 .../todo/controllers/TodoListController.as      | 22 ++++----
 6 files changed, 111 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/670bbaa0/examples/flexjs/DataBindingExample/pom.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/pom.xml 
b/examples/flexjs/DataBindingExample/pom.xml
index 3e6ac92..90e2f70 100644
--- a/examples/flexjs/DataBindingExample/pom.xml
+++ b/examples/flexjs/DataBindingExample/pom.xml
@@ -42,7 +42,6 @@
         <extensions>true</extensions>
         <configuration>
           <mainClass>DataBindingExample.mxml</mainClass>
-          <removeCirculars>true</removeCirculars>
         </configuration>
       </plugin>
       <plugin>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/670bbaa0/examples/flexjs/DataBindingExample/src/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/controllers/MyController.as 
b/examples/flexjs/DataBindingExample/src/controllers/MyController.as
index 2ee16ae..b7d52bd 100644
--- a/examples/flexjs/DataBindingExample/src/controllers/MyController.as
+++ b/examples/flexjs/DataBindingExample/src/controllers/MyController.as
@@ -19,63 +19,74 @@
 package controllers
 {
        import org.apache.flex.events.Event;
-       
+
        import org.apache.flex.core.Application;
        import org.apache.flex.core.IDocument;
-    
+       import org.apache.flex.net.HTTPService;
+       import org.apache.flex.collections.LazyCollection;
+
     import models.MyModel;
-       
+
        public class MyController implements IDocument
        {
                public function MyController(app:Application = null)
                {
                        if (app)
                        {
-                               this.app = app as DataBindingExample;
                                app.addEventListener("viewChanged", 
viewChangeHandler);
                        }
                }
-               
+
+               private var model:MyModel;
+               private var initialView:Object;
+               private var service:HTTPService;
+               private var collection:LazyCollection;
+
         private var queryBegin:String = 
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22";
         private var queryEnd:String = 
"%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json";
-               private var app:DataBindingExample;
-               
+
                private function viewChangeHandler(event:Event):void
                {
+                       var app:Application = event.target as Application;
                        app.initialView.addEventListener("buttonClicked", 
buttonClickHandler);
                        app.initialView.addEventListener("radioClicked", 
radioClickHandler);
             app.initialView.addEventListener("listChanged", 
listChangedHandler);
+
+            initialView = app.initialView;
+                       model = app.model as MyModel;
+                       service = app["service"] as HTTPService;
+                       collection = app["collection"] as LazyCollection;
                }
-               
+
         private function buttonClickHandler(event:Event):void
         {
-            var sym:String = MyInitialView(app.initialView).symbol;
-            app.service.url = queryBegin + sym + queryEnd;
-            app.service.send();
-            app.service.addEventListener("complete", completeHandler);
+            var sym:String = MyInitialView(initialView).symbol;
+            service.url = queryBegin + sym + queryEnd;
+            service.send();
+            service.addEventListener("complete", completeHandler);
         }
-        
+
                private function radioClickHandler(event:Event):void
                {
-                       var field:String = 
MyInitialView(app.initialView).requestedField;
-                       MyModel(app.model).requestedField = field;
+                       var field:String = 
MyInitialView(initialView).requestedField;
+                       model.requestedField = field;
                }
-               
+
         private function completeHandler(event:Event):void
         {
-                       MyModel(app.model).responseData = 
app.collection.getItemAt(0);
+                       model.responseData = collection.getItemAt(0);
         }
-        
+
         private function listChangedHandler(event:Event):void
         {
-            MyModel(app.model).stockSymbol = 
MyInitialView(app.initialView).symbol;
+            model.stockSymbol = MyInitialView(initialView).symbol;
         }
-        
+
                public function setDocument(document:Object, id:String = 
null):void
                {
-                       this.app = document as DataBindingExample;
+                       var app:Application = document as Application;
                        app.addEventListener("viewChanged", viewChangeHandler);
                }
 
        }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/670bbaa0/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
----------------------------------------------------------------------
diff --git 
a/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as 
b/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
index 2ee16ae..b7d52bd 100644
--- a/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
+++ b/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
@@ -19,63 +19,74 @@
 package controllers
 {
        import org.apache.flex.events.Event;
-       
+
        import org.apache.flex.core.Application;
        import org.apache.flex.core.IDocument;
-    
+       import org.apache.flex.net.HTTPService;
+       import org.apache.flex.collections.LazyCollection;
+
     import models.MyModel;
-       
+
        public class MyController implements IDocument
        {
                public function MyController(app:Application = null)
                {
                        if (app)
                        {
-                               this.app = app as DataBindingExample;
                                app.addEventListener("viewChanged", 
viewChangeHandler);
                        }
                }
-               
+
+               private var model:MyModel;
+               private var initialView:Object;
+               private var service:HTTPService;
+               private var collection:LazyCollection;
+
         private var queryBegin:String = 
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22";
         private var queryEnd:String = 
"%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json";
-               private var app:DataBindingExample;
-               
+
                private function viewChangeHandler(event:Event):void
                {
+                       var app:Application = event.target as Application;
                        app.initialView.addEventListener("buttonClicked", 
buttonClickHandler);
                        app.initialView.addEventListener("radioClicked", 
radioClickHandler);
             app.initialView.addEventListener("listChanged", 
listChangedHandler);
+
+            initialView = app.initialView;
+                       model = app.model as MyModel;
+                       service = app["service"] as HTTPService;
+                       collection = app["collection"] as LazyCollection;
                }
-               
+
         private function buttonClickHandler(event:Event):void
         {
-            var sym:String = MyInitialView(app.initialView).symbol;
-            app.service.url = queryBegin + sym + queryEnd;
-            app.service.send();
-            app.service.addEventListener("complete", completeHandler);
+            var sym:String = MyInitialView(initialView).symbol;
+            service.url = queryBegin + sym + queryEnd;
+            service.send();
+            service.addEventListener("complete", completeHandler);
         }
-        
+
                private function radioClickHandler(event:Event):void
                {
-                       var field:String = 
MyInitialView(app.initialView).requestedField;
-                       MyModel(app.model).requestedField = field;
+                       var field:String = 
MyInitialView(initialView).requestedField;
+                       model.requestedField = field;
                }
-               
+
         private function completeHandler(event:Event):void
         {
-                       MyModel(app.model).responseData = 
app.collection.getItemAt(0);
+                       model.responseData = collection.getItemAt(0);
         }
-        
+
         private function listChangedHandler(event:Event):void
         {
-            MyModel(app.model).stockSymbol = 
MyInitialView(app.initialView).symbol;
+            model.stockSymbol = MyInitialView(initialView).symbol;
         }
-        
+
                public function setDocument(document:Object, id:String = 
null):void
                {
-                       this.app = document as DataBindingExample;
+                       var app:Application = document as Application;
                        app.addEventListener("viewChanged", viewChangeHandler);
                }
 
        }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/670bbaa0/examples/flexjs/DataBindingExample_as/src/controllers/MyController.as
----------------------------------------------------------------------
diff --git 
a/examples/flexjs/DataBindingExample_as/src/controllers/MyController.as 
b/examples/flexjs/DataBindingExample_as/src/controllers/MyController.as
index 2ee16ae..b7d52bd 100644
--- a/examples/flexjs/DataBindingExample_as/src/controllers/MyController.as
+++ b/examples/flexjs/DataBindingExample_as/src/controllers/MyController.as
@@ -19,63 +19,74 @@
 package controllers
 {
        import org.apache.flex.events.Event;
-       
+
        import org.apache.flex.core.Application;
        import org.apache.flex.core.IDocument;
-    
+       import org.apache.flex.net.HTTPService;
+       import org.apache.flex.collections.LazyCollection;
+
     import models.MyModel;
-       
+
        public class MyController implements IDocument
        {
                public function MyController(app:Application = null)
                {
                        if (app)
                        {
-                               this.app = app as DataBindingExample;
                                app.addEventListener("viewChanged", 
viewChangeHandler);
                        }
                }
-               
+
+               private var model:MyModel;
+               private var initialView:Object;
+               private var service:HTTPService;
+               private var collection:LazyCollection;
+
         private var queryBegin:String = 
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22";
         private var queryEnd:String = 
"%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json";
-               private var app:DataBindingExample;
-               
+
                private function viewChangeHandler(event:Event):void
                {
+                       var app:Application = event.target as Application;
                        app.initialView.addEventListener("buttonClicked", 
buttonClickHandler);
                        app.initialView.addEventListener("radioClicked", 
radioClickHandler);
             app.initialView.addEventListener("listChanged", 
listChangedHandler);
+
+            initialView = app.initialView;
+                       model = app.model as MyModel;
+                       service = app["service"] as HTTPService;
+                       collection = app["collection"] as LazyCollection;
                }
-               
+
         private function buttonClickHandler(event:Event):void
         {
-            var sym:String = MyInitialView(app.initialView).symbol;
-            app.service.url = queryBegin + sym + queryEnd;
-            app.service.send();
-            app.service.addEventListener("complete", completeHandler);
+            var sym:String = MyInitialView(initialView).symbol;
+            service.url = queryBegin + sym + queryEnd;
+            service.send();
+            service.addEventListener("complete", completeHandler);
         }
-        
+
                private function radioClickHandler(event:Event):void
                {
-                       var field:String = 
MyInitialView(app.initialView).requestedField;
-                       MyModel(app.model).requestedField = field;
+                       var field:String = 
MyInitialView(initialView).requestedField;
+                       model.requestedField = field;
                }
-               
+
         private function completeHandler(event:Event):void
         {
-                       MyModel(app.model).responseData = 
app.collection.getItemAt(0);
+                       model.responseData = collection.getItemAt(0);
         }
-        
+
         private function listChangedHandler(event:Event):void
         {
-            MyModel(app.model).stockSymbol = 
MyInitialView(app.initialView).symbol;
+            model.stockSymbol = MyInitialView(initialView).symbol;
         }
-        
+
                public function setDocument(document:Object, id:String = 
null):void
                {
-                       this.app = document as DataBindingExample;
+                       var app:Application = document as Application;
                        app.addEventListener("viewChanged", viewChangeHandler);
                }
 
        }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/670bbaa0/examples/flexjs/TodoListSampleApp/pom.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/TodoListSampleApp/pom.xml 
b/examples/flexjs/TodoListSampleApp/pom.xml
index c2cf144..06ada34 100644
--- a/examples/flexjs/TodoListSampleApp/pom.xml
+++ b/examples/flexjs/TodoListSampleApp/pom.xml
@@ -48,7 +48,6 @@
         <extensions>true</extensions>
         <configuration>
           <mainClass>TodoListSampleApp.mxml</mainClass>
-          <removeCirculars>true</removeCirculars>
         </configuration>
       </plugin>
       <plugin>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/670bbaa0/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as
----------------------------------------------------------------------
diff --git 
a/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as
 
b/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as
index 4465fb3..6402a9c 100644
--- 
a/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as
+++ 
b/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as
@@ -25,20 +25,25 @@ package sample.todo.controllers {
        import sample.todo.models.TodoListModel;
 
        public class TodoListController implements IDocument {
-               private var app:Application;
+
+               private var model:TodoListModel;
 
                public function TodoListController(app:Application = null) {
-                       if (app != null) {
-                               this.app = app;
-                       }
+                        if (app != null) {
+                               // store the model for future use.
+                               model = app.model as TodoListModel;
+                       }
                }
 
                /**
                 *
                 */
                public function setDocument(document:Object, id:String = 
null):void {
-                       app = document as Application;
+                       var app:Application = document as Application;
                        app.addEventListener("viewChanged", viewChangeHandler);
+
+                       // store the model for future use
+                       model = app.model as TodoListModel;
                }
 
                /**
@@ -46,6 +51,7 @@ package sample.todo.controllers {
                 * @param event
                 */
                private function viewChangeHandler(event:Event):void {
+                       var app:Application = event.target as Application;
                        
app.initialView.addEventListener(TodoListEvent.LOG_TODO, logTodo);
                        
app.initialView.addEventListener(TodoListEvent.ITEM_CHECKED,handleItemChecked);
                        
app.initialView.addEventListener(TodoListEvent.ITEM_REMOVE_REQUEST, 
handleItemRemove);
@@ -57,18 +63,14 @@ package sample.todo.controllers {
                 */
                public function logTodo(evt:TodoListEvent):void {
                        // still need to change model a view get the changes
-                       var todoModel:TodoListModel = app.model as 
TodoListModel;
-                       //todoModel.todos.push({title: evt.todo, selected: 
false});
-                       todoModel.addTodo(evt.todo);
+                       model.addTodo(evt.todo);
                }
 
                public function handleItemChecked(event:TodoListEvent):void {
-                       var model: TodoListModel = app.model as TodoListModel;
                        model.toggleItemCheck(event.item);
                }
 
                public function handleItemRemove(event:TodoListEvent):void {
-                       var model: TodoListModel = app.model as TodoListModel;
                        model.removeItem(event.item);
                }
        }

Reply via email to