-->

Saturday, 14 July 2012

Getting Data From Flash Files with Transform SWF (Part 2)

When we left in Part 1 we had figured out how to get the statistics when both sides were non-zero. Since we have eliminated all avenues in DefineTextField and there is nothing suitable in TextSettings, we will begin to explore DefineMorphShape. I begin this by outputting DefineMorphShape.toString(), which gives a very long result. I do, however, notice a mention of a start colour. I check for red and blue:

  • red -> fillStyles=[MorphSolidFill: { start=Color: { red=92; green=49; blue=13; alpha=255}
  • blue -> fillStyles=[MorphSolidFill: { start=Color: { red=18; green=77; blue=127; alpha=255}
I will now intersperse 'red' and 'blue' into the output of the previous method

private static void printDefineTextFieldsAndDefineMorphShape(final List<movietag> objects) {

  for(MovieTag object : objects){
    if (object instanceof DefineTextField) {
    DefineTextField d = (DefineTextField) object;
    String initialText = removeHtmlTags(d.getInitialText());

    if (Character.isDigit(initialText.charAt(0))){
      System.out.print(initialText + " ");
    } else {
      System.out.print("\n" + initialText + " "); 
    }

  }
   
 if (object instanceof DefineMorphShape){
   DefineMorphShape dms = (DefineMorphShape)object;
   MorphSolidFill fill = (MorphSolidFill)dms.getFillStyles().get(0);
   String colour = "unknown";
    
   if (fill.getEndColor().getBlue() == 13){
     colour = "red";
   }
    
   if (fill.getEndColor().getBlue() == 127){
     colour = "blue";
   }
   
   System.out.print(colour + "-");
 }

This produces the following output:


0 0
Shots (SH) red-1 blue-1 red-1 1 1 blue-1 red-2 1 2 0 0
Shots (on target) red-1 1 0 0
Shots (off target) red-1 0 0
Shots (woodwork) blue-1 1 blue-1 red-1 1 0 0
Shots (blocked) blue-1 0 1 0 0 0
Attacks (AT) red-1 blue-1 red-1 blue-1 red-2 blue-2 red-2 2 2 blue-2 red-3 2 3 blue-2 red-3 3 3 blue-2 red-4 2 4 0 0
Dangerous Attacks 0 0 red-1 1 blue-1 red-1 1 1 blue-1 red-1 1 1

This brings us very close to a result. For the three results that finished 1-0 we can see that there is only one morph:

  • Shots (on target) red-1 1
  • Shots (off target) red-1
  • Shots (blocked) blue-1 0 1 0

Now all we have to do is figure out Shots (woodwork). blue-1 1 blue-1 red-1 1 0 0. I can see two possibilities. What I have done below is insert semicolons in the natural breaks. When the first event causes a change it only affects one side, that colour goes to 100%. When an event happens on the other side it causes two changes. The 100% side goes to 50% and the 0% goes to 50%. In the example below Shots (woodwork) is the only one that starts with blue and evens out. 

0 0
Shots (SH) red-1; blue-1 red-1 1 1;  blue-1 red-2 1 2; 0 0
Shots (on target) red-1 1; 0 0
Shots (off target) red-1; 0 0
Shots (woodwork) blue-1 1; blue-1 red-1 1; 0 0
Shots (blocked) blue-1 0; 1 0; 0 0
Attacks (AT) red-1; blue-1 red-1; blue-1 red-2; blue-2 red-2 2 2; blue-2 red-3 2 3; blue-2 red-3 3 3; blue-2 red-4 2 4; 0 0
Dangerous Attacks 0 0 red-1 1; blue-1 red-1 1 1; blue-1 red-1 1 1;

From here I can see three possibilities:
  • Shots (woodwork) is the only one that starts with blue and then evens out. This only makes sense if updates are asynchronous - even then why make an exception for 0-0 except to be friendly to me.
  • Shots (woodwork) has the only pair morph that is followed by a single number:  blue-1 red-1 1 - it is also the only line with a pair morph that ends with a single number (the pair of zeros belong to the next line).
  • Shots (woodwork) has the only one that starts with blue followed by a 1

Now we need to get more files to test our hypotheses.




Arrow Key Nav