9 Replies Latest reply on Feb 4, 2010 10:14 AM by shahinyan

    conditional question

    shahinyan

      Dear friends,

       

      i have a problem with writing a conditional inline:

       

      <mx:Repeater id="buttons" dataProvider="{destinationListCollection}">

      <mx:Image x="{buttons.currentItem.x}" y="{buttons.currentItem.y}" width="10" height="10" toolTip="Address:{buttons.currentItem.title} {buttons.currentItem.number} Model: {buttons.currentItem.model_name}"
          source="({buttons.currentItem.isAvailable}=='true')? {available_icon}:{not_available_icon}" id="location_image" click=" showWindow(event);showPath(event)" />

          </mx:Repeater>

       

      i have set a variable for {available_icon} and not available_icon:

       


              public var available_icon:String="/assets/build_available.swf";

       

              public var not_available_icon:String="/assets/build_notavailable.swf";      

       

      It brings me broken image link.

       

      What i am doing wrong?

       

      Thanks!

       

      Mika

        • 1. Re: conditional question
          archemedia Level 4

          <mx:Repeater id="buttons" dataProvider="{destinationListCollection}">

          <mx:Image x="{buttons.currentItem.x}" y="{buttons.currentItem.y}" width="10" height="10" toolTip="Address:{buttons.currentItem.title} {buttons.currentItem.number} Model: {buttons.currentItem.model_name}"
              source="({buttons.currentItem.isAvailable}=='true')? {available_icon}:{not_available_icon}" id="location_image" click=" showWindow(event);showPath(event)" />

              </mx:Repeater>

           

          i have set a variable for {available_icon} and not available_icon:

           


                  public var available_icon:String="/assets/build_available.swf";

           

                  public var not_available_icon:String="/assets/build_notavailable.swf";

           

          - Don't enclose a boolean in quotes:

          true and not 'true' (this is a string and not a boolean), unless you stored them as strings 'true' and 'false' off course

           

          - Why are you setting the x & y properties of the images?

           

          - Don't enclose available_icon and not_available_icon into curly braces. They're just variables, they don't change so you needn't bind them.

           

          - Why do you use a repeater? Isn't it better to use a horizontalList or so?

           

          Dany

          • 2. Re: conditional question
            shahinyan Level 1

            Now i've got it like this:

             

            <mx:Image x="{buttons.currentItem.x}" y="{buttons.currentItem.y}" width="10" height="10" toolTip="Address:{buttons.currentItem.title} {buttons.currentItem.number} Model: {buttons.currentItem.model_name}"
                source="({buttons.currentItem.isAvailable}==true)? available_icon:not_available_icon" id="location_image" click=" showWindow(event);showPath(event)" />

             

            but this still didnt help.

             

            I am using Repeater to render images on map, thats why i need coordinates.

             

            Thanks!

            • 3. Re: conditional question
              archemedia Level 4

              Could you post the structure of your dataProvider?

               

              Dany

              • 4. Re: conditional question
                shahinyan Level 1

                Sure. It is a call to a remote CFC withquery params as follows:

                 

                <cfquery datasource="#application.dsn#" name="qMapObjects">
                SELECT  m.area, m.description as map_object_description, m.number, m.phase, m.x,
                m.y, m.isAvailable, s.title, h.title as model_name, h.description as model_description,
                h.first_floor_area, h.second_floor_area, h.shell_house_price, h.number_of_bedrooms,
                h.number_of_full_bathrooms, h.number_of_half_bathrooms,  h.full_house_price,
                h.garage_space, t.home_owner_fee,  t.title as housing_type_name,
                t.price_per_sqm, t.included_in_price, t.available_financing, t.payment_months,
                t.downpayment_percentage, t.closing_payment_percent, t.bFinancing,
                i.thumbnail, i.thumbnailImagePath

                 

                Thanks!

                • 5. Re: conditional question
                  archemedia Level 4

                  I know it's some work but could you HARDCODE an array with 2 or 3 example objects so I can test with it?

                   

                  Dany

                  • 6. Re: conditional question
                    shahinyan Level 1

                    Also you can see that map here (click on Phase III)

                    http://vahakni.win-dns.com/index.cfm?objectid=FFD8621D-FB05-72D6-4B5588B28815BA13

                     

                    Mika

                    • 7. Re: conditional question
                      shahinyan Level 1

                      I can post a full project to see, so you dont have to play with arrays.

                      Here is a proper link:

                      http://www.vahakni.com/index.cfm?objectid=FFD8621D-FB05-72D6-4B5588B28815BA13

                      Just make sure to have in compiler : -locale en_US -services "libs/services-config.xml"

                       

                      Thanks,

                      Mika

                      • 8. Re: conditional question
                        archemedia Level 4

                        ok, a few things:

                         

                        - In the dataProvider, the isAvailable property returns as '0' or '1'.  these are strings, so change this line:

                        source="{(buttons.currentItem.isAvailable=='1') ? available_icon : not_available_icon}"

                        Watch the diffrent binding braces! Your statement should be completely within the braces!

                         

                        - Change all properties where a boolean value is expected as such, for instance:
                        sold_item_details.visible="false"; >> REMOVE QUOTES!!

                        sold_item_details.visible=false;

                         

                        - Finally, change this: (remove the leading slashes)

                        [Bindable]
                        public var available_icon:String="assets/build_available.swf";
                        [Bindable]
                        public var not_available_icon:String="assets/build_notavailable.swf";

                         

                        This should do the trick

                         

                        Dany

                        1 person found this helpful
                        • 9. Re: conditional question
                          shahinyan Level 1

                          Thanks a lot Dany!

                          Really did the trick!!!!