1 Reply Latest reply on Jul 21, 2008 9:37 AM by Newsgroup_User

    Member copying performance

    TJW-dev Level 1
      Hi,

      As part of a program, I have the need to copy a large amount of bitmap cast members between 2 casts.
      (MX2004)

      I was hoping someone would know the performance implications, and which one of the following were better:

      Option 1: Create the bitmap member, then copy the image of the member

      repeat with foo = 1 to numOfImagesInCast
      new(#bitmap, member(foo, "destinationCast"))
      member(foo, "destinationCast").image = member(foo, "originalCast").image
      end repeat

      Option 2: Just copy the member

      repeat with foo = 1 to numOfImagesInCast
      member(foo, "destinationCast") = member(foo, "originalCast")
      end repeat


      If option 2 is better, that should I also be using duplicate() i.e. member(foo, "destinationCast") = duplicate(member(foo, "originalCast"))

        • 1. Re: Member copying performance
          Level 7
          In the first case, the player has to:
          - read the original member data
          - decompress the data, if compressed
          - set the data as the content of an image object
          - create the new member, and set it's image data to a copy of the new image.

          In the second case you just duplicate the original member data (header +
          {compressed} image data)
          Creating 'empty' cast members on the fly should be a light process - not
          very slower than from creating sprites. Haven't benchmared it, hence the
          'should'.

          For duplicating the member, according to the above, the second method should
          be faster, since it performs a data copy rather than read/decompress/write.
          It also uses less ram, and retains the original format.


          "TJW-dev" <webforumsuser@macromedia.com> wrote in message
          news:g629bd$cuk$1@forums.macromedia.com...
          > Hi,
          >
          > As part of a program, I have the need to copy a large amount of bitmap
          > cast
          > members between 2 casts.
          >
          > I was hoping someone would know the performance implications, and which
          > one of
          > the following were better:
          >
          > Option 1: Create the bitmap member, then copy the image of the member
          >
          > repeat with foo = 1 to numOfImagesInCast
          > new(#bitmap, member(foo, "destinationCast"))
          > member(foo, "destinationCast").image = member(foo,
          > "originalCast").image
          > end repeat
          >
          > Option 2: Just copy the member
          >
          > repeat with foo = 1 to numOfImagesInCast
          > member(foo, "destinationCast") = member(foo, "originalCast")
          > end repeat
          >
          >
          > If option 2 is better, that should I also be using duplicate() i.e.
          > member(foo, "destinationCast") = duplicate(member(foo, "originalCast"))
          >
          >
          >