Professional Web Applications Themes

Updating components when data changes - Macromedia Flex General Discussion

I am having trouble getting a set of components to update when data is modified by another set of components. A com.adobe.cairngorm.model.IModelLocator is used to hold the model data; the concrete class is called ViewModelLocator. Code that needs to access the data does so via the following declaration in the relevant ActionScript files: private static var app:ViewModelLocator = ViewModelLocator.getInstance(); One of the data members of the model is a rather complex class called Species, defined in com.micronauticsresearch.ewConfig.model.empathyWor ks.Species.as. An instance of the Species class is used by composition in another class called an Individual, defined in com.micronauticsresearch.ewConfig.model.empathyWor ks.Individual.as I have ...

  1. #1

    Default Updating components when data changes

    I am having trouble getting a set of components to update when data is modified
    by another set of components.

    A com.adobe.cairngorm.model.IModelLocator is used to hold the model data; the
    concrete class is called ViewModelLocator. Code that needs to access the data
    does so via the following declaration in the relevant ActionScript files:
    private static var app:ViewModelLocator = ViewModelLocator.getInstance();

    One of the data members of the model is a rather complex class called Species,
    defined in com.micronauticsresearch.ewConfig.model.empathyWor ks.Species.as. An
    instance of the Species class is used by composition in another class called an
    Individual, defined in
    com.micronauticsresearch.ewConfig.model.empathyWor ks.Individual.as

    I have created a set of custom components that provides editing support for a
    Species instance. These components are defined in MXML and referred to as
    TripleSlider components by the following namespace:
    xmlns:TripleSlider="com.micronauticsresearch.ewCon fig.view.tripleSlider.*"

    TripleSliders generate a 'change' event whenever a user adjusts their
    controls. I have reused SliderEvent for this purpose:
    <mx:Metadata>
    [Event(name="change", type="mx.events.SliderEvent")]
    </mx:Metadata>

    Species are rendered from
    com.micronauticsresearch.ewConfig.view.prlEditor.S peciesTendencies.mxml as
    follows:
    <fc:FlowContainer
    height="100%"
    horizontalCenter="true"
    width="100%" >
    <mx:Repeater id="rp" dataProvider="{app.species.tendencies.keys()}">
    <TripleSlider:tripleSlider
    attributeName="{rp.currentItem}"
    clusterValue="{tendencyClusterValue(rp.currentItem )}"
    defValue="{attributeDefaultValue(rp.currentItem)}"
    minValue="{attributeMinValue(rp.currentItem)}"
    maxValue="{attributeMaxValue(rp.currentItem)}"
    showLimits="false"
    change="valueCommit(event)" />
    </mx:Repeater>
    </fc:FlowContainer>

    I wrote some custom collection classes; app.species.tendencies is a TreeMap
    (patterned after Java's TreeMap.) Individuals are rendered from
    com.micronauticsresearch.ewConfig.view.virtualWorl d.IndividualAttribures.mxml
    as follows:
    <FlowContainer:FlowContainer
    height="100%"
    horizontalCenter="true"
    width="100%" >
    <mx:Repeater id="rp" dataProvider="{app.individual.attributes.keys()}">
    <TripleSlider:tripleSlider
    showLimits="true"
    attributeName="{rp.currentItem}"

    minLimit="{app.individual.species.tendencies.getIt em(rp.currentItem as
    String).minValue}"

    maxLimit="{app.individual.species.tendencies.getIt em(rp.currentItem as
    String).maxValue}"
    defValue="{app.individual.limits.getItem(rp.curren tItem as
    String).defValue}"
    minValue="{app.individual.limits.getItem(item as
    String).minValue}"
    maxValue="{app.individual.limits.getItem(item as
    String).maxValue}}" />
    </mx:Repeater>
    </FlowContainer:FlowContainer>

    app.individual.attributes is also a TreeMap. The attributes are recomputed
    when the Species is edited so the Individual's TripleSliders can be updated.
    Unfortunately my choice of an iterator for rendering Individual attributes
    appears to be unhelpful because the keys do not change; the values change
    instead. Seems like my choices are:
    1) Modify app.individual.attributes to be an ArrayList (another Flex class I
    created which models a Java collection); the data binding for Individuals
    should then trigger a refresh.
    2) Set up one or more listeners in IndividualAttributes.mxml, listening for
    the 'change' event dispatched by the Species TripleSlider; I'm unsure of how I
    should approach this.
    3) ... any other approaches?

    Mike


    mslinn Guest

  2. #2

    Default Re: Updating components when data changes

    what is:
    app.individual.attributes.keys()

    is keys() a method? You can bind to methods, but they require some changing
    property in order to fire binding.

    Binding requires either an ArrayCollection, XMLListCollection, or XML. Array,
    and XMLList are not bindable.

    If you are bound to one of those, and use the appropriate API to do the
    update, then bound UI element will update.

    Tracy

    ntsiii Guest

Similar Threads

  1. Help with data components; get data into variable
    By drliebs in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: December 19th, 11:12 AM
  2. Updating XML file using components
    By James_3421 in forum Adobe Flash, Flex & Director
    Replies: 1
    Last Post: July 16th, 06:04 AM
  3. Automatic "updating adobe online components" on launch
    By Donald_Durs@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 9
    Last Post: May 6th, 12:51 PM
  4. Updating Adobe Online Components
    By George_Cassello@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 2
    Last Post: April 23rd, 06:50 PM
  5. Illustrator 10 Updating Adobe online components then quits
    By Joan_Duncan@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 2
    Last Post: April 11th, 05:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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