예제 #1
0
 private void parseHeader(Element headerElement) {
   if (RecordXMLReader.getBooleanAttribute("omitbinarydata", headerElement)) {
     throw new IllegalArgumentException(
         "XML files with omitbinarydata flag set cannot be transformed back to SWF!");
   }
   short swfVersion = RecordXMLReader.getShortAttribute("swfversion", headerElement);
   swfDocument.setVersion(swfVersion);
   swfDocument.setCompressed(RecordXMLReader.getBooleanAttribute("compressed", headerElement));
   Element framesElement = RecordXMLReader.getElement("frames", headerElement);
   swfDocument.setFrameCount(RecordXMLReader.getIntAttribute("count", framesElement));
   swfDocument.setFrameRate(RecordXMLReader.getShortAttribute("rate", framesElement));
   Element sizeElement = RecordXMLReader.getElement("size", framesElement);
   swfDocument.setFrameSize(RecordXMLReader.readRect(sizeElement));
   Element backgroundColorElement = RecordXMLReader.getElement("bgcolor", headerElement);
   swfDocument.setBackgroundColor(RecordXMLReader.readRGB(backgroundColorElement));
   if (swfVersion >= 8) {
     String access = RecordXMLReader.getStringAttribute("access", headerElement);
     if (access.equals("local")) {
       swfDocument.setAccessMode(SWFDocument.ACCESS_MODE_LOCAL);
     } else if (access.equals("network")) {
       swfDocument.setAccessMode(SWFDocument.ACCESS_MODE_NETWORK);
     }
     Element metadata = headerElement.element("metadata");
     if (metadata != null) {
       swfDocument.setMetadata(Base64.decodeString(metadata.getText()));
     }
   }
 }
예제 #2
0
 /** Modify the specified swf. */
 protected static boolean modifySWF(SWFDocument doc, String before, String after) {
   @SuppressWarnings("unchecked")
   List<Tag> tags = doc.getTags();
   for (int ii = 0, nn = tags.size(); ii < nn; ii++) {
     Tag tag = tags.get(ii);
     if (tag instanceof UnknownTag) {
       Tag replacement = modifyTag((UnknownTag) tag, before, after);
       if (replacement != null) {
         tags.set(ii, replacement);
         return true;
       }
     }
   }
   return false;
 }
예제 #3
0
 /**
  * Returns the SWF document generated from the parsed XML.
  *
  * @return SWF document
  */
 public SWFDocument getDocument() {
   swfDocument.addTags(tags);
   return swfDocument;
 }