1 Reply Latest reply on Mar 3, 2009 7:48 AM by Newsgroup_User

    loading extenal SWF into AS project

    theErez Level 1
      hi,
      in my AS project i have a data class called 'ProductData', which has several properties (such as id, title, etc). i also have a SWF i created holding the product item's visuals (i'm using an external swf because probably in future projects i'll have different visuals). once i load the swf, i want to set its' data. so i created a document class for the swf, and in it have a 'setData' function which receives the data object:
      public function setData(productData:ProductData):void
      {
      title_txt.text = prodcutData.title;
      ....
      }
      and where the swf was loaded i have something like -
      var prodcutData:ProductData = currentProductData;
      productItem.setData(prodcutData);

      however, once i do that i get a 1034 error, saying -
      cannot convert com.data.datas.items::ProductData@1e486c39 to com.data.datas.items.ProductData
      the only way i can avoid it is if i set in the 'setData' function the parameter type to Object and DON'T cast it back to ProductData (if i do so i get the same error). the funny thing is that if i have the parameter's type to Object and then trace argument i get '[object ProductData]', and not surprisingly if i set the 'toString()' function indise the ProductData class, once traced i get what i put there.
      anybody can explain me what's going on here?
      hope i made myself clear. thanks in advance,
      eRez
        • 1. Re: loading extenal SWF into AS project
          Level 7

          "theErez" <webforumsuser@macromedia.com> wrote in message
          news:gojcq5$pgf$1@forums.macromedia.com...
          > hi,
          > in my AS project i have a data class called 'ProductData', which has
          > several
          > properties (such as id, title, etc). i also have a SWF i created holding
          > the
          > product item's visuals (i'm using an external swf because probably in
          > future
          > projects i'll have different visuals). once i load the swf, i want to set
          > its'
          > data. so i created a document class for the swf, and in it have a
          > 'setData'
          > function which receives the data object:
          > public function setData(productData:ProductData):void
          > {
          > title_txt.text = prodcutData.title;
          > ....
          > }
          > and where the swf was loaded i have something like -
          > var prodcutData:ProductData = currentProductData;
          > productItem.setData(prodcutData);
          >
          > however, once i do that i get a 1034 error, saying -
          > cannot convert com.data.datas.items::ProductData@1e486c39 to
          > com.data.datas.items.ProductData
          > the only way i can avoid it is if i set in the 'setData' function the
          > parameter type to Object and DON'T cast it back to ProductData (if i do so
          > i
          > get the same error). the funny thing is that if i have the parameter's
          > type to
          > Object and then trace argument i get '[object ProductData]', and not
          > surprisingly if i set the 'toString()' function indise the ProductData
          > class,
          > once traced i get what i put there.
          > anybody can explain me what's going on here?
          > hope i made myself clear. thanks in advance,

          Sounds a lot like Q 8
          http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf