compress flash
Posted: Sun Jan 30, 2011 4:21 pm
				
				a friend made me a very nice flash for a program, but it weighs 3 mega
is it possible to do lighter (1 mega max)?
			is it possible to do lighter (1 mega max)?
Is it used within a PB program?effis wrote:a friend made me a very nice flash for a program, but it weighs 3 mega
is it possible to do lighter (1 mega max)?
Well, with PureBasics weird functions for handling compression the quickest solution I came up with is something like this:effis wrote:hummm... how?
Code: Select all
;run this once then comment it away
If CreatePack("compressedFlashfile.pak") 
  AddPackFile("yourFlashfile.swf") 
  ClosePack() 
EndIf
;-----------------
;include file inside your program (when compiling)
DataSection
  compressedFlashfile:
  IncludeBinary "compressedFlashfile.pak"
  endOfData:
EndDataSection 
;extract the file at runtime
file = CreateFile(#PB_Any,"compressedFlashfile.pak")
If file
  WriteData(file,?compressedFlashfile,endOfData-compressedFlashfile)
  CloseFile(file)
EndIf
;extract the flash file to memory
If OpenPack("compressedFlashfile.pak") 
  *memPointer = NextPackFile()
  memSize = PackFileSize()
  ClosePack()
  ;write the decompressed content to a file
  file = CreateFile(#PB_Any,"extractedFlashfile.swf")
  If file
    WriteData(file,*memPointer,memSize)
    CloseFile(file)
  EndIf
EndIf
;extractedFlashfile.swf is now the file you can use in your program