compress flash

For everything that's not in any way related to PureBasic. General chat etc...
effis
User
User
Posts: 42
Joined: Thu May 27, 2010 11:22 am

compress flash

Post 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)?
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Re: compress flash

Post 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)
Last edited by Joakim Christiansen on Sun Jan 30, 2011 4:50 pm, edited 1 time in total.
I like logic, hence I dislike humans but love computers.
effis
User
User
Posts: 42
Joined: Thu May 27, 2010 11:22 am

Re: compress flash

Post by effis »

hummm... how?
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Re: compress flash

Post 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)
I like logic, hence I dislike humans but love computers.
User avatar
codewalker
Enthusiast
Enthusiast
Posts: 331
Joined: Mon Mar 27, 2006 2:08 pm
Location: Spain

Re: compress flash

Post 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
There is a difference between knowing the code and writing the code.
May the code be strong in your projects.
effis
User
User
Posts: 42
Joined: Thu May 27, 2010 11:22 am

Re: compress flash

Post by effis »

thanks
but when i'm commpressing its still 3 mega
i'll speak with him that he will do it
Post Reply