Ask a Question related to Macromedia Flash, Design and Development.

  1. #21

    Default Re: Variables

    sorry, forgot to add code for previous post

    thanks

    Chris



    **** index.mxml ****

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
    xmlns:comp="components.*" xmlns:screen="OCRScreens.*"
    pageTitle="CMS Oral Complaint Review" initialize="cmsReviewWS.getDeptList()"
    height="100%">

    <mx:Script>
    <![CDATA[

    import mx.validators.*;
    import mx.controls.Alert;

    public var radioSelected:String; //variable to hold value of selected Radion
    Button

    function getLastYear() {
    var now = new Date();
    var lastYear = new Date(now.getFullYear(),now.getMonth(),now.getDate( )-14);
    return lastYear ;
    }

    function restrictFromDate() {
    fromDate.selectableRange = { rangeStart: new Date(getLastYear()), rangeEnd:
    new Date()};
    }

    function restrictToDate() {
    toDate.selectableRange = { rangeStart: new Date(getLastYear()), rangeEnd: new
    Date()};
    }

    function validateForm(validator, value)
    {
    if(searchByDateModel.fromDate != null && searchByDateModel.toDate != null){
    mx.core.Application.application.reviewScreenVStack .selectedIndex=2
    }
    }

    function showSelected(sSelected:String)
    {
    if(sSelected == "Show All"){
    radioSelected = "All Oral Complaints";
    }
    else if (sSelected == "Show New"){
    radioSelected = "New Oral Complaints";
    }
    else{
    radioSelected = "Previously Reviewed Oral Complaints";
    }

    }


    ]]>
    </mx:Script>


    <!-- Invoke webservice -->
    <mx:WebService id="cmsReviewWS"
    wsdl="http://127.0.0.1:8102/components/cmsReviewWS.cfc?wsdl"
    showBusyCursor="true">
    <mx:operation name="getDeptList"/>
    </mx:WebService>


    <!-- Define Model for Validation -->
    <mx:Model id="searchByDateModel">
    <fromDate>{fromDate.text}</fromDate>
    <toDate>{toDate.text}</toDate>
    </mx:Model>

    <!-- Define Validation Fields -->
    <mx:Validator field="searchByDateModel.fromDate"/>
    <mx:Validator field="searchByDateModel.toDate" />

    <!-- Define the ViewStack and the child containers -->
    <mx:ViewStack id="reviewScreenVStack" width="100%" height="100%">

    <mx:Canvas id="logIn" label="Log in" width="100%" height="100%">
    <screen:login width="100%"/>
    </mx:Canvas>

    <mx:Canvas id="oralCompSearhForm" label="Search for Complaint" width="100%"
    height="100%">

    <!-- <screen:oralCompSearhForm id="resultsInstance" width="100%"/> -->
    <mx:Panel title="Search Criteria" horizontalAlign="center" >
    <mx:VBox>
    <mx:Label text="Enter Search Criteria Below"></mx:Label>

    <mx:Form id="seachForm" verticalGap="15">
    <mx:HBox>
    <mx:Label text="Dates:"></mx:Label>
    <mx:FormItem label="From" required="true">
    <mx:DateField id="fromDate" initialize="restrictFromDate();"/>
    </mx:FormItem>
    <mx:FormItem label="To" required="true">
    <mx:DateField id="toDate" initialize="restrictToDate();"/>
    </mx:FormItem>
    </mx:HBox>
    <mx:HBox>
    <mx:Label text="Department:"/>
    <mx:ComboBox id="dept_dsc"
    dataProvider="{cmsReviewWS.getDeptList.result}" labelField="DEPT_DSC" />
    </mx:HBox>
    <mx:HBox>
    <mx:RadioButton id="showAll" label="Show All"
    click="showSelected(event.target.label);"/>
    <mx:RadioButton id="showNew" label="Show New"
    click="showSelected(event.target.label);"/>
    <mx:RadioButton id="showPrev" label="Show Previously Reviewed"
    click="showSelected(event.target.label);"/>
    </mx:HBox>
    </mx:Form>
    <mx:HBox width="100%" horizontalAlign="right" marginRight="15">
    <mx:Button label="Search"
    click="{mx.validators.Validator.isStructureValid(t his, 'searchByDateModel'),
    validateForm()}"/>
    </mx:HBox>
    </mx:VBox>
    </mx:Panel>

    </mx:Canvas>

    <mx:Canvas id="oralComplaintResults" label="Oral Complaint Results"
    width="100%" height="100%">
    <screen:oralComplaintResults id="resultsInstance"
    toDate="{toDate.selectedDate}" fromDate="{fromDate.selectedDate}"
    complaints="{radioSelected}" width="100%" height="100%"/>
    </mx:Canvas>

    </mx:ViewStack>

    </mx:Application>


    **** oralComplaintResults.mxml ****

    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="http://www.macromedia.com/2003/mxml"
    xmlns:comp="components.*" horizontalAlign="left"
    initialize="cmsReviewWS.getOralComplaintResults()" height="100%" >

    <mx:Script>
    <![CDATA[
    public var toDate;
    public var fromDate;
    public var complaints:String;
    ]]>
    </mx:Script>

    <mx:DateFormatter id="dateformatter" formatString="DD MMMM YYYY"/>

    <mx:WebService id="cmsReviewWS"
    wsdl="http://127.0.0.1:8102/components/cmsReviewWS.cfc?wsdl"
    showBusyCursor="true">
    <mx:operation name="getOralComplaintResults"/>
    </mx:WebService>

    <mx:Panel title="Oral Complaints Review Screen" height="100%">
    <mx:Label id="Complaints" text="{complaints}"/>
    <mx:Label text="Date Range: {dateformatter.format(fromDate)} to
    {dateformatter.format(toDate)}"/>

    <mx:DataGrid dataProvider="{cmsReviewWS.getOralComplaintResults .result}"
    textAlign="left" height="100%"
    variableRowHeight="true" wordWrap="true" editable="true">
    <mx:columns>
    <mx:Array>
    <mx:DataGridColumn headerText="Change to N to exclude" columnName=""
    editable="true"/>
    <mx:DataGridColumn headerText="Complaint Received Date"
    columnName="CMPL_RECVD_DT" editable="false"/>
    <mx:DataGridColumn headerText="Complaint (Caller) Name" columnName="NAME"
    editable="false"/>
    <mx:DataGridColumn headerText="Relationship" columnName="CTCT_ROLE_DSC"
    editable="false"/>
    <mx:DataGridColumn headerText="Account Policy Number" columnName="POL_NBR"
    editable="false"/>
    <mx:DataGridColumn headerText="Policy Holder Name" columnName=""
    editable="false"/>
    <mx:DataGridColumn headerText="Complaint ID" columnName="CMPL_ID"
    editable="false"/>
    <mx:DataGridColumn headerText="Product Type" columnName=""
    editable="false"/>
    <mx:DataGridColumn headerText="Department ID" columnName=""
    editable="false"/>
    <mx:DataGridColumn headerText="Producer/Broker Name" columnName=""
    editable="false"/>
    <mx:DataGridColumn headerText="User Name" columnName="" editable="false"/>
    <mx:DataGridColumn headerText="Complaint Function" editable="false"/>
    <mx:DataGridColumn headerText="Key Words" columnName="" editable="false"/>
    <mx:DataGridColumn headerText="Responsible Party/Department 1"
    columnName="" editable="false"/>
    <mx:DataGridColumn headerText="Responsible Party/Department 2"
    columnName="" editable="false"/>
    <mx:DataGridColumn headerText="Action Taken" columnName=""
    editable="false"/>
    <mx:DataGridColumn headerText="Resolution" columnName="" editable="false"/>
    </mx:Array>
    </mx:columns>
    </mx:DataGrid>

    </mx:Panel>

    </mx:HBox>

    Kris Kros Guest

  2. Similar Questions and Discussions

    1. #39833 [NEW]: Session variables overwritten by local variables (register_globals=off)
      From: sup1382 at accedo dot es Operating system: OpenBSD 3.9 PHP version: 5.2.0 PHP Bug Type: Session related Bug...
    2. #39447 [NEW]: Want to optionally handle apc_upload_progress variables using session variables
      From: krudtaa at yahoo dot com Operating system: All PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug...
    3. Global variables - application variables vs include file
      What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include...
    4. Replacing code based on static variables to variable variables.
      Can anyone give me some help or tips in converting this code to take 2 variables that will specify the number of Pack type lines and the number of...
    5. variables that change session variables
      Hi, I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between...
  3. #22

    Default Re: Variables

    Ahh, I bet I know what is happening. ViewStack uses deferred instantiation by
    default. This means that "resultsInstance" literally does not exist until the
    user first navigates to that view. So any attempt to access variables or
    anything else in that component will cause an error if it has never been viewed.

    The quick fix is to set creationPolicy="all" on the view stack.

    The purpose of the default deferred instantiation is to imporve the users
    perception of speed when the app initializes; you take a small hit the first
    time you nav to a view, but the app loads much faster.

    You can do a lot with creation policy, but save that for later.

    Tracy

    ntsiii Guest

  4. #23

    Default Re: Variables

    Also, when referencing components, you do need to travel the hierarchy. so if
    you wanted to access a variable in one child from a sibling, you would do this,
    it is the long form:

    var complaints:String =
    mx.core.Application.application.resultsInstance.co mplaints;

    If you pass a reference to the application into each child, which I recommend:
    var complaints:String = app.resultsInstance.complaints;

    And if you pass in a ref to the sibling:
    var complaints:String = ri.complaints;

    ntsiii Guest

  5. #24

    Default variables

    Instead of using Cookies what i want to do in Flex is have a global variable
    that will be avaiable anywhere in the application. So when a user logs in the
    userID variable will have the value of 2 and can be accessed anywhere in the
    application is this possible?

    Thanks...

    realtime158 Guest

  6. #25

    Default Re: variables

    There are several ways to do this. The simplest is to create apublic variable
    in the main application scope(not in a function), use
    Application.application.myVar to reference that var. that reference will work
    from anywhere, including apps loaded using swfLoader. Import
    mx.core.Application into each component where you need that. I create a var in
    each component, _app:application, and assign it in an init function. Just
    saves some typing.

    Another way is to use a singleton data model class. It is a more flexible
    solution than global vars.

    Tracy

    ntsiii Guest

  7. #26

    Default Re: variables

    Thanks for the help :)
    realtime158 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139