def repl_sprite(swf, offset, define_tags, frame_count, control_tags)
      swf.force_encoding("ASCII-8BIT") if swf.respond_to? :force_encoding
      define_tags.force_encoding("ASCII-8BIT") if define_tags.respond_to? :force_encoding
      control_tags.force_encoding("ASCII-8BIT") if control_tags.respond_to? :force_encoding
      record_header = swf[offset, 2].unpack("v").first
      # tag check
      raise ReplaceTargetError if (record_header >> 6) & 1023 != 39
      # error for short header (not implemented yet.)
      raise ReplaceTargetError if record_header & 63 < 63
      # rewrite frame count
      swf[offset+8, 2] = [frame_count].pack("v")
      # rewrite control tag and length
      sprite_len = swf[offset+2, 4].unpack("i").first # without recordheader
      old_control_tags_len = sprite_len - 4
      delta_control_tags_len = control_tags.length - old_control_tags_len
      swf[offset+10, old_control_tags_len] = control_tags
      swf[offset+2, 4] = [sprite_len + delta_control_tags_len].pack("V")
      # insert define tags before define sprite
      swf[offset, 0] = define_tags
      # rewrite swf header
      swf[4, 4] = [swf[4, 4].unpack("V").first + define_tags.length + delta_control_tags_len].pack("V")
      swf
    end
def repl_sprite(swf, offset, define_tags, frame_count, control_tags)
      swf.force_encoding("ASCII-8BIT") if swf.respond_to? :force_encoding
      define_tags.force_encoding("ASCII-8BIT") if define_tags.respond_to? :force_encoding
      control_tags.force_encoding("ASCII-8BIT") if control_tags.respond_to? :force_encoding
      record_header = swf[offset, 2].unpack("v").first
      # tag check
      raise ReplaceTargetError if (record_header >> 6) & 1023 != 39
      # error for short header (not implemented yet.)
      raise ReplaceTargetError if record_header & 63 < 63
      # rewrite frame count
      swf[offset+8, 2] = [frame_count].pack("v")
      # rewrite control tag and length
      sprite_len = swf[offset+2, 4].unpack("i").first # without recordheader
      old_control_tags_len = sprite_len - 4
      delta_control_tags_len = control_tags.length - old_control_tags_len
      swf[offset+10, old_control_tags_len] = control_tags
      swf[offset+2, 4] = [sprite_len + delta_control_tags_len].pack("V")
      # insert define tags before define sprite
      swf[offset, 0] = define_tags
      # rewrite swf header
      swf[4, 4] = [swf[4, 4].unpack("V").first + define_tags.length + delta_control_tags_len].pack("V")
      swf
    end
対象オフセット位置にあるDefineSpriteを指定したControlTags文字列で置換.
 新しいSprite含むDefineTagsは、DefineSpriteの直前に挿入する.