예제 #1
0
		/// <summary>
		/// constructor.
		/// </summary>
		/// <param name="header">header data</param>
		/// <param name="tags">list of inner tags</param>
		public DefineSpriteTag(byte[] header, BaseTag[] tags, long size) {
			
			this.header = header;
			this.tagList = tags;
            this.size = size;
			
			_tagCode = (int)TagCodeEnum.DefineSprite;
			
			_actionCount = 0;			
			foreach (BaseTag b in tagList) {
				_actionCount += b.ActionRecCount;
			}
			
			tagForAction = new int[_actionCount];
			tagOffset = new int[tagList.Length];
			
			int actionIdx = 0;
			for (int i=0; i<tagList.Length; i++) {				
				
				tagOffset[i] = actionIdx;
				int count = ((BaseTag)tagList[i]).ActionRecCount;
				if (count>0) {					
					for (int j=0; j<count; j++) {
						tagForAction[actionIdx+j]=i;						
					}
					actionIdx+=count;					
				}
			}
		}
		/// <summary>
		/// see <see cref="SwfOp.Data.Tags.BaseTag">base class</see>
		/// </summary>
		public override void UpdateData(byte version) {			
			
			// update inner tags
			int len = 0;
			for (int i=0; i<tagList.Length; i++) {
				BaseTag tag = (BaseTag) tagList[i];
				tag.UpdateData(version);
				len += tag.Data.Length;				
			}				
			
			MemoryStream m = new MemoryStream();
			BinaryWriter w = new BinaryWriter(m);
						
			RecordHeader rh = new RecordHeader(TagCode, len + header.Length ,true);
			
			rh.WriteTo(w);
			w.Write(header);
			for (int i=0; i<tagList.Length; i++) {
				BaseTag tag = (BaseTag) tagList[i];
				w.Write(tag.Data);
			}
			
			// update data
			_data = m.ToArray();
		}			
예제 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public Swf(SwfHeader header,BaseTag[] tagList) {
     
     this.Header = header;
     this.tagList = tagList;
     
     // count actions
     _actionCount = 0;
     foreach (BaseTag b in tagList) {
         _actionCount+=b.ActionRecCount;
     }
 }
예제 #4
0
 public TagEnumerator(BaseTag[] tagList) {
     this.tagList = tagList;
     this.index = -1;
 }   
예제 #5
0
 /// <summary>
 /// constructor. internal, since only used by BaseTag class
 /// </summary>
 /// <param name="tag">the BaseTag, who´s bytecode is being held</param>
 internal BytecodeEnumerator(BaseTag tag) {
     this.tag = tag;
     this.index = -1;
 }   
 private void ParseAttributes(BaseTag tag)
 {
     BitArray ba = BitParser.GetBitValues(tag.Data);
     FileAttributes.UseDirectBlit = (bool)ba[16 + 1];
     FileAttributes.UseGPU = (bool)ba[16 + 2];
     FileAttributes.HasMetaData = (bool)ba[16 + 3];
     FileAttributes.Actionscript3 = (bool)ba[16 + 4];
     FileAttributes.UseNetwork = (bool)ba[16 + 7];
 }
예제 #7
0
 /// <summary>
 /// constructor. internal, since only used by BaseTag class
 /// </summary>
 /// <param name="t">the BaseTag, who´s bytecode is being held</param>
 internal BytecodeHolder(BaseTag t) {
     tag = t;
 }
예제 #8
0
		/// <summary>
		/// Read swf (header and tags), this is the only public method of <see cref="SwfOp.IO.SwfReader">SwfReader</see>
		/// </summary>
		public Swf ReadSwf() {
			
			// compressed swf?
			if (br.PeekChar()=='C') {
				inflate();
			}
			
			SwfHeader header = ReadHeader();
			this.version = header.Version;			

			ArrayList tagList = new ArrayList();
			
			while (br.BaseStream.Position<br.BaseStream.Length) {
				BaseTag b = this.ReadTag();	
				tagList.Add(b);
			};	
			
			BaseTag[] tags = new BaseTag[tagList.Count];
			tagList.CopyTo(tags,0);
			br.Close();
			
			return new Swf(header,tags);
		}
예제 #9
0
		/// <summary>
		/// Read and parse DefineSpriteTag, into inner tags and raw byte-array header data
		/// </summary>
		protected DefineSpriteTag ReadDefineSpriteTag() {
			
			RecordHeader rh = ReadRecordHeader();	

			// inner tags
			ArrayList tagList = new ArrayList();			
			long endPos = br.BaseStream.Position + rh.TagLength;

			// stuff before inner tags, just read it and dont look any further
			byte[] header = br.ReadBytes(4);
			
			while (br.BaseStream.Position<endPos) {
				BaseTag b = this.ReadTag();
				tagList.Add(b);		
			}
			
			BaseTag[] tags = new BaseTag[tagList.Count];
			tagList.CopyTo(tags,0);
			
			return new DefineSpriteTag(header,tags);			
		}
예제 #10
0
 /// <summary>
 /// constructor. internal, since only used by BaseTag class
 /// </summary>
 /// <param name="tag">the BaseTag, who´s bytecode is being held</param>
 internal BytecodeEnumerator(BaseTag tag)
 {
     this.tag   = tag;
     this.index = -1;
 }
예제 #11
0
 /// <summary>
 /// constructor. internal, since only used by BaseTag class
 /// </summary>
 /// <param name="t">the BaseTag, who´s bytecode is being held</param>
 internal BytecodeHolder(BaseTag t)
 {
     tag = t;
 }
예제 #12
0
        /// <summary>
        /// Read swf (header and tags), this is the only public method of <see cref="SwfOp.IO.SwfReader">SwfReader</see>
        /// </summary>
        public Swf ReadSwf() {
            
            // compressed swf?
            if (br.PeekChar()=='C') {
                inflate();
            }
            else if (br.PeekChar() == 'Z') {
                inflateLZMA();
            }
            
            SwfHeader header = ReadHeader();
            this.version = header.Version;          

            ArrayList tagList = new ArrayList();

            try
            {
                streamEnd = br.BaseStream.Length;
                while (br.BaseStream.Position < streamEnd)
                {
                    BaseTag b = this.ReadTag();
                    tagList.Add(b);
                };
            }
            catch (Exception eos)
            {
                Console.WriteLine("-- Error: Tag reader error: [" + eos.Message + "]");
            }
            
            BaseTag[] tags = new BaseTag[tagList.Count];
            tagList.CopyTo(tags,0);
            br.Close();
            
            return new Swf(header,tags);
        }