Page 1 of 1

compress flash

Posted: Sun Jan 30, 2011 4:21 pm
by effis
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)?

Re: compress flash

Posted: Sun Jan 30, 2011 4:47 pm
by Joakim Christiansen
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)?
Is it used within a PB program?
If so you could include the compressed file and then decompress it at runtime.
(check out "Packer" in the help file)

Re: compress flash

Posted: Sun Jan 30, 2011 4:48 pm
by effis
hummm... how?

Re: compress flash

Posted: Sun Jan 30, 2011 5:06 pm
by Joakim Christiansen
effis wrote:hummm... how?
Well, with PureBasics weird functions for handling compression the quickest solution I came up with is something like this:

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
I hope this can guide you the right way. (I didn't test it though)

Re: compress flash

Posted: Mon Jan 31, 2011 1:28 am
by codewalker
Import your swf into the program sothink swf quicker and use it's compiler.
It has a high compression rate. Then use a swf compressor such as eltima.
cw

Re: compress flash

Posted: Mon Jan 31, 2011 1:45 pm
by effis
thanks
but when i'm commpressing its still 3 mega
i'll speak with him that he will do it