Exemplo n.º 1
0
 def get_data_stub(self):
     bits = BitStream()
     bits += Rect(XMax=self.width, YMax=self.height)
     bits.flush()
     bits.write(self.fps, FIXED8)
     bits.write(self.num_frames, UI16)
     return bits.serialize()
Exemplo n.º 2
0
    def parse_inner(cls, bits):
        CharacterID = bits.read(UI16)
        Bounds = Rect.from_bitstream(bits)
        bits.skip_flush()

        HasText = bits.read(Bit)
        WordWrap = bits.read(Bit)
        Multiline = bits.read(Bit)
        Password = bits.read(Bit)
        ReadOnly = bits.read(Bit)
        HasColor = bits.read(Bit)
        HasMaxLength = bits.read(Bit)
        HasFont = bits.read(Bit)

        HasFontClass = bits.read(Bit)
        AutoSize = bits.read(Bit)
        HasLayout = bits.read(Bit)
        NotSelectable = bits.read(Bit)
        HasBorder = bits.read(Bit)
        WasStatic = bits.read(Bit)
        IsHTML = bits.read(Bit)
        HasOutlines = bits.read(Bit)

        FontID = None
        FontClass = None
        FontSize = None

        Color = None
        MaxLength = None
        Layout = None
        Text = None

        if HasFont: FontID = bits.read(UI16)
        if HasFontClass: FontClass = bits.read(CString)
        if HasFont: FontSize = bits.read(UI16)

        if HasColor: Color = RGB.from_bitstream(bits)
        if HasMaxLength: MaxLength = bits.read(UI16)
        # if HasLayout:    Layout    = NonExistant.parse(bits)

        Variable = bits.read(CString)
        if HasText: Text = bits.read(CString)

        inst = cls(Bounds, Variable, Text, ReadOnly, IsHTML, WordWrap,
                   Multiline, Password, AutoSize, not NotSelectable, HasBorder,
                   Color, MaxLength, Layout, FontID, FontSize, FontClass,
                   CharacterID)
        inst.wasstatic = WasStatic
        inst.outlines = HasOutlines
        return inst
Exemplo n.º 3
0
    def parse_inner(cls, bits):
        CharacterID = bits.read(UI16)
        Bounds      = Rect.from_bitstream(bits)
        bits.skip_flush()

        HasText       = bits.read(Bit)
        WordWrap      = bits.read(Bit)
        Multiline     = bits.read(Bit)
        Password      = bits.read(Bit)
        ReadOnly      = bits.read(Bit)
        HasColor      = bits.read(Bit)
        HasMaxLength  = bits.read(Bit)
        HasFont       = bits.read(Bit)

        HasFontClass  = bits.read(Bit)
        AutoSize      = bits.read(Bit)
        HasLayout     = bits.read(Bit)
        NotSelectable = bits.read(Bit)
        HasBorder     = bits.read(Bit)
        WasStatic     = bits.read(Bit)
        IsHTML        = bits.read(Bit)
        HasOutlines   = bits.read(Bit)

        FontID    = None
        FontClass = None
        FontSize  = None

        Color     = None
        MaxLength = None
        Layout    = None
        Text      = None

        if HasFont:      FontID    = bits.read(UI16)
        if HasFontClass: FontClass = bits.read(CString)
        if HasFont:      FontSize  = bits.read(UI16)

        if HasColor:     Color     = RGB.from_bitstream(bits)
        if HasMaxLength: MaxLength = bits.read(UI16)
        # if HasLayout:    Layout    = NonExistant.parse(bits)

        Variable         = bits.read(CString)
        if HasText: Text = bits.read(CString)

        inst = cls(Bounds, Variable, Text, ReadOnly, IsHTML, WordWrap,
                   Multiline, Password, AutoSize, not NotSelectable,
                   HasBorder, Color, MaxLength, Layout, FontID, FontSize,
                   FontClass, CharacterID)
        inst.wasstatic = WasStatic
        inst.outlines  = HasOutlines
        return inst
Exemplo n.º 4
0
    def from_bitstream(cls, bitstream):
        header = bitstream.read(ByteString[3])
        if header not in ("CWS", "FWS"):
            raise ValueError("Unrecognizable header. Are you sure this is a SWF file?")
        compressed = header[0] == "C"

        version = bitstream.read(UI8)
        length  = bitstream.read(UI32)
        if compressed:
            bitstream.decompress()

        rect = Rect.from_bitstream(bitstream)
        bitstream.skip_flush()
        fps = bitstream.read(FIXED8)
        frame_count = bitstream.read(UI16)
        inst = cls(rect.XMax, rect.YMax, fps, compressed, version)
        inst.frame_count = frame_count
        inst.bitstream = bitstream
        return inst
Exemplo n.º 5
0
    gen.emit('add')
    gen.store_var("S")
    gen.call_method("appendText", tracer, [Local("S")])
    gen.call_function("trace", [Local("S")])

class Main(INode(flash.display.MovieClip)):
    tracer = Slot(flash.text.TextField)
    def __iinit__(self, gen):
        # Standard prologue
        gen.emit('getlocal0')
        gen.emit('constructsuper', 0)

        dump(gen, Chain(This, Field("root"), Field("loaderInfo"), Field("parameters")), self.tracer)

gen.add_node(Main)
gen.add_node(dump)
gen.add_node(ktrace)
gen.render_nodes()
gen.finish()

swf.add_tag(tags.FileAttributes())
swf.add_tag(tags.DoABC("Main", abc))
swf.add_tag(tags.SymbolClass({0:"Main"}))
swf.add_tag(tags.DefineEditText(Rect(0, 0, 600, 400), "tracer", "", color=RGBA(0x000000)))
swf.add_tag(tags.PlaceObject2(0, 1, name="tracer"))
swf.add_tag(tags.ShowFrame())
swf.add_tag(tags.End())

with open("tracer.swf", "wb") as f:
    f.write(swf.serialize())