0 Replies Latest reply on Sep 9, 2011 3:02 AM by kushpa

    Concatenating Data/Services data with Strings

    kushpa

      Hi, I'm new to FB and have a question regarding concatenating strings after a data/services call. I've got a very simple app where I have a database with 3 fields: id, caption, photofile. The database is listed in a datagrid, and when the user clicks on a datagrid entry, it populates 2 list components and loads a photo. The list components display the caption field and the text of the photofile field. Currently, I'm just calling a static graphic, but would like to populate the URL with the root URL + the name of the file selected in the grid. I'm trying to do this through a selectionChangeHandler GridSelectionEvent on the datagrid. Here is the code:

       

      ================================          

      protected function imgGrid_selectionChangeHandler(event:GridSelectionEvent):void

      {

           getPhotosByIDResult.token = photosService.getPhotosByID(imgGrid.selectedItem.id);

           loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);         

           loader.load(new URLRequest("assets/1974.jpg"));

      //     loader.load(new URLRequest("http://costinmultimedia.com/GregoryHyde-debug/" + RESULT_OF_SELECTED_ITEM));

           trace("started loading");

      }

      ================================

       

      Right now, it's correctly populating the list fields with the text data when you click on an entry, so the value for "getPhotosByIDResult.token" is correctly reflecting the user selection. This example shows loading a static image URL, which works fine, but what I would like to do is concatenate the URL string as shown in the commented line (which contains the RESULT_OF_SELECTED_ITEM), so the photo displayed is the one associated with the entry the user clicked. Make sense?

       

      I tried just assigning a variable and saying (photoURL = "http://mydomain.com/" + getPhotosByIDResult.token) as well as (photoURL = "http://mydomain.com/" + photosService.getPhotosByID(imgGrid.selectedItem.id);), but both return errors of trying to mix Flex with Spark strings or something like that. I'm sure I'm missing something very simple, but since I'm still learning FB, I just can't seem to put my finger on it. Any assistance or tips would be greatly appreciated. Or am I going about this in an incorrect manner? Should I be handling the photo loading in the MXML section instead of the AS3 section?

       

      Thanks,

       

      Kushpa