starting with flex - please let me know if the direction is right (ActionScript vs MXML separation) -


I have already started learning Flex through "programming flex 3.0". After completing three chapters and completing the fourth (action script), I have started practicing if there is not enough patience to wait until I complete chapter 22

About a bit about me Most concerns are dual coding mode (MXML vs. Action Script)

Please see your code below (it compiles it through mxmlc design.mxml , second file 'code. As' should be in the same directory) Advises that if I visual design and proper separation went to use the code.

Besides - If a smart person can show me how to read an example with a class file [.as with package], then it would be highly appreciated I was lost with the directory structure for the package - and it did not get the most intuitive, especially for small projects which are two files like my example


code: design.mxml

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Mx: application xmlns: mx = "http://www.adobe.com/2006/mxml" & gt; & Lt; Mx: script source = "code.as" /> & Lt; Mx: VBox & gt; & Lt; Mx: text input outputTransform = "initialize collector ()" id = "TCTSin" /> & Lt; Mx: hbox & gt; & Lt; Mx: button click = "('7')" id = "btn7" label = "7" /> & Lt; Mx: button click = "('8')" id = "btn8" label = "8" /> & Lt; Mx: button click = "(9 ')" id = "btn9" label = "9" /> & Lt; Mx: button click = "click ('c')" id = "btn claire" label = "c" /> & Lt; / Mx: hbox & gt; & Lt; Mx: hbox & gt; & Lt; Mx: button click = "('4')" id = "btn4" label = "4" /> & Lt; Mx: button click = "(5 ')" id = "btn5" label = "5" /> & Lt; Mx: button click = "('6')" id = "btn6" label = "6" /> & Lt; Mx: button click = "('/')" id = "btnDivide" label = "/" /> & Lt; / Mx: hbox & gt; & Lt; Mx: hbox & gt; & Lt; Mx: button click = "('1')" id = "btn1" label = "1" /> & Lt; Mx: button click = "('2')" id = "btn2" label = "2" /> & Lt; Mx: button click = "('3')" id = "btn3" label = "3" /> & Lt; Mx: button click = "('*')" id = "btn multiply" label = "*" /> & Lt; / Mx: hbox & gt; & Lt; Mx: hbox & gt; & Lt; Mx: button click = "('0')" id = "btn0" label = "0" /> & Lt; Mx: button click = "('=')" id = "btnEqual" label = "=" /> & Lt; Mx: button click = "('-')" id = "btn min" label = "-" /> & lt; Mx: button click = "('+')" id = "btnPlus" label = "+" /> & Lt; / Mx: hbox & gt; & Lt; / Mx: VBox & gt; & Lt; / Mx: Applications & gt;  

code: code.as

  public var res: int = 0; Public Priority Past Operator: String = ""; Public Preferred Last Rage: Int = 0; Public Function Initialization (): Zero {txtScreen.text = res.toString (); } Click public function (code: string): zero {if (code == "1" || code == "2" || code == "3" || code == "4" || code == Code == "6" || code == "7" || code == "8" || code == "9" || code == "0") {res = res * 10 + integer (code ); TxtScreen.text = res.toString ();} and if (code == "C") {res = 0; last operator = ""; previous RSS = 0; TxtScreen.text = res.toString ();} Else { Calculation (code);}} Public function calculation (operator: string): zero {var tmpRes: int; if (last operator == "+") {tmpRes = previousRes + res;} and if (previous operator == " } {TmpRes = previousRes - res;} and if (last operator == "/") {tmpRes = previousRes / re S;} and if (previous operators == "*") {tmpRes = previousRes * res;} and {tmpRes = res;} previous operator = operator; previous RPS = TMPRS; TxtScreen.text = previousRes.toString (); res = 0; if (last operator == "=") {res = tmpRes; txtScreen.text = res.toString ();}}  

If you have a comment that this calculator is okay , They are also appreciated, nevertheless are commenting on the best practices in the most important Flex.

This is the code between your user interface and application logic when using a code-behind in a Flex application. It would be helpful to clean the link.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -