Previous - dirCastLibDetach Section Home - Director Miscellaneous Next - dirMemImport


dirMemExport ( )

Exports a cast member in binary form onto the hard disk

Usage:

dirMemExport (object me, object memberRef, string filePath)

Parameters:

memberRef (cast member reference ) - member reference to a bitmap cast member

filePath (string) - The file path to save into binary form

Returns:

(integer) - The success code

Example:

-- example shows exporting every cast member in the internal cast library.
--  these binary files are then encrypted and compressed.
xtRose = xtra("Rosetta").new( )

strTmpFolder = xtRose.sysFolderTemp( )
strLstFiles = []

-- use MD5 to create a really long unique key
strKey = xtRose.md5String("example")

repeat with i = 1 to the number of members of castlib 1
  If ( member( i, 1 ).type <> #EMPTY ) Then
    -- make temp file
    strTmpFilePath = xtRose.sysFileTemp( strTmpFolder, "caluRose" )
    
    -- store cast member onto temp file
    If ( xtRose.dirMemExport( member( i, 1), strTmpFilePath) > 0 ) Then
      -- encrypt cast member
      strTmpFilePathSecure = xtRose.sysFileTemp( strTmpFolder, "caluRose" )
      xtRose.aesEncryptFile( strKey, strTmpFilePath, strTmpFilePathSecure)
      
      -- store the filename into a list
      strLstFiles.addAt( strTmpFilePathSecure )
    End IF
    
    xtRose.sysFileDelete( strTmpFilePath )
    
  End If
End Repeat

-- create a new zip file
nFilesCount = strLstFiles.count
If ( nFilesCount > 0 ) Then
  xtRose.zipCreate( the moviepath & "UserSaveData.zip" )
  Repeat with i = 1 to nFilesCount
    strFilePath = strLstFiles[i]
    
    -- extract file name from path
    nLen = strFilePath.length
    Repeat with j = nLen down to 1
      If ( strFilePath.char[j] = "\" ) Then
        strFileName = strFilePath.char[(j+1)..nLen]
        
        -- add to zip file
        xtRose.zipAdd( strFilePath, strFileName )
        Exit Repeat
      End If
    End Repeat
    
    -- delete the secure temp file
    xtRose.sysFileDelete( strFilePath )
    
  End Repeat
  
  -- close the zip file
  xtRose.zipClose( )
End If

Notes:

Cast members containing linked media such as video or audio members may not export.

OLE cast members are not supported.

For cast member xtras, it is up to the individual xtra developer to implement their load and save method. If you plan on exporting cast members that are xtras, you should thoroughly test for compatibility problems. The recommendation is to export only native Director cast member types.


Previous - dirCastLibDetach Section Home - Director Miscellaneous Next - dirMemImport