Last active
March 21, 2016 13:51
-
-
Save olafkrueger/8c4b94817fde72202231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Main.mxml --> | |
<?xml version="1.0" encoding="utf-8"?> | |
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:local="*" | |
xmlns:js="library://ns.apache.org/flexjs/basic" | |
applicationComplete="onApplicationComplete()"> | |
<fx:Script> | |
<![CDATA[ | |
import com.undo_redo_demo.core.TestClass; | |
private function onApplicationComplete():void { | |
var testClass:TestClass = new TestClass(myView); | |
// Works as expected: | |
myView.setData("First call of setData()"); | |
// Works only with swf version: | |
testClass.view.setData("Call of setData() using an Interface"); | |
// Works only with swf version: | |
// (Seems that all code after the previous call isn't executed with the js version | |
// cause of the interface issue) | |
// myView.setData("Second call of setData()"); | |
} | |
]]> | |
</fx:Script> | |
<js:valuesImpl> | |
<js:SimpleCSSValuesImpl /> | |
</js:valuesImpl> | |
<js:initialView> | |
<local:MyInitialView id="myView" /> | |
</js:initialView> | |
</js:Application> | |
<!-- MyInitialView.mxml --> | |
<js:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:js="library://ns.apache.org/flexjs/basic" | |
implements="com.undo_redo_demo.core.interfaces.IViewMyInitialView"> | |
<fx:Script> | |
<![CDATA[ | |
public function setData(data:String):void { | |
btntest.text = data; | |
} | |
]]> | |
</fx:Script> | |
<js:Container> | |
<js:beads> | |
<js:VerticalLayout /> | |
</js:beads> | |
<js:TextButton id="btntest" text="Test it..." width="200" /> | |
</js:Container> | |
</js:ViewBase> | |
<!-- IViewMyInitialView.as --> | |
package com.undo_redo_demo.core.interfaces | |
{ | |
public interface IViewMyInitialView | |
{ | |
function setData(data:String):void; | |
} | |
} | |
<!-- TestClass.as --> | |
package com.undo_redo_demo.core | |
{ | |
import com.undo_redo_demo.core.interfaces.IViewMyInitialView; | |
public class TestClass | |
{ | |
private var _view:IViewMyInitialView; | |
public function TestClass(view:IViewMyInitialView) { | |
_view = view; | |
} | |
public function get view():IViewMyInitialView { | |
return _view as IViewMyInitialView; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment