Program: 61960
Project: 61960
Buggy source:
public void reload(boolean forceReload){
  Object tagObj=tagTree.getLastSelectedPathComponent();
  if (tagObj == null) {
    return;
  }
  if (tagObj instanceof TagNode) {
    tagObj=((TagNode)tagObj).tag;
  }
  if (tagObj instanceof TreeElement) {
    tagObj=((TreeElement)tagObj).getItem();
  }
  if (!forceReload && (tagObj == oldValue)) {
    return;
  }
  if (flashPanel != null) {
    flashPanel.specialPlayback=false;
  }
  swfPreviewPanel.stop();
  stopFlashPlayer();
  oldValue=tagObj;
  if (tagObj instanceof ScriptPack) {
    final ScriptPack scriptLeaf=(ScriptPack)tagObj;
    if (!Main.isWorking()) {
      Main.startWork(translate("String_Node_Str") + "String_Node_Str",new Runnable(){
        @Override public void run(){
          if (setSourceTask != null) {
            setSourceTask.cancel(true);
          }
          abcPanel.decompiledTextArea.setText("String_Node_Str" + AppStrings.translate("String_Node_Str"));
        }
      }
);
      FutureTask<Void> task=Helper.callAsync(new Callable<Void>(){
        @Override public Void call() throws Exception {
          int classIndex=-1;
          for (          Trait t : scriptLeaf.abc.script_info[scriptLeaf.scriptIndex].traits.traits) {
            if (t instanceof TraitClass) {
              classIndex=((TraitClass)t).class_info;
              break;
            }
          }
          abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setCode("String_Node_Str");
          abcPanel.navigator.setABC(abcList,scriptLeaf.abc);
          abcPanel.navigator.setClassIndex(classIndex,scriptLeaf.scriptIndex);
          abcPanel.setAbc(scriptLeaf.abc);
          abcPanel.decompiledTextArea.setScript(scriptLeaf,abcList);
          abcPanel.decompiledTextArea.setClassIndex(classIndex);
          abcPanel.decompiledTextArea.setNoTrait();
          return null;
        }
      }
,new Callback<AsyncResult<Void>>(){
        @Override public void call(        AsyncResult<Void> arg1){
          setSourceTask=null;
          Main.stopWork();
        }
      }
);
      setSourceTask=task;
    }
    showDetail(DETAILCARDAS3NAVIGATOR);
    showCard(CARDACTIONSCRIPTPANEL);
    return;
  }
 else {
    showDetail(DETAILCARDEMPTYPANEL);
  }
  if ((tagObj instanceof SWFRoot)) {
    if (miInternalViewer.isSelected()) {
      showCard(CARDSWFPREVIEWPANEL);
      swfPreviewPanel.load(swf);
      swfPreviewPanel.play();
    }
 else {
      showCard(CARDFLASHPANEL);
      parametersPanel.setVisible(false);
      if (flashPanel != null) {
        Color backgroundColor=View.DEFAULT_BACKGROUND_COLOR;
        for (        Tag t : swf.tags) {
          if (t instanceof SetBackgroundColorTag) {
            backgroundColor=((SetBackgroundColorTag)t).backgroundColor.toColor();
            break;
          }
        }
        if (flashPanel instanceof FlashPlayerPanel) {
          if (tempFile != null) {
            tempFile.delete();
          }
          try {
            tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
            tempFile.deleteOnExit();
            swf.saveTo(new FileOutputStream(tempFile));
            flashPanel.displaySWF(tempFile.getAbsolutePath(),backgroundColor,swf.frameRate);
          }
 catch (          IOException iex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,"String_Node_Str",iex);
          }
        }
      }
    }
  }
 else   if (tagObj instanceof DefineBinaryDataTag) {
    showCard(CARDEMPTYPANEL);
  }
 else   if (tagObj instanceof ASMSource) {
    showCard(CARDACTIONSCRIPTPANEL);
    actionPanel.setSource((ASMSource)tagObj,!forceReload);
  }
 else   if (tagObj instanceof ImageTag) {
    imageButtonsPanel.setVisible(((ImageTag)tagObj).importSupported());
    showCard(CARDIMAGEPANEL);
    imagePanel.setImage(((ImageTag)tagObj).getImage(swf.tags));
  }
 else   if ((tagObj instanceof DrawableTag) && (!(tagObj instanceof TextTag)) && (!(tagObj instanceof FontTag))&& (miInternalViewer.isSelected())) {
    showCard(CARDDRAWPREVIEWPANEL);
    previewImagePanel.setDrawable((DrawableTag)tagObj,swf,characters,50);
  }
 else   if ((tagObj instanceof FontTag) && (miInternalViewer.isSelected())) {
    showCard(CARDFLASHPANEL);
    previewImagePanel.setDrawable((DrawableTag)tagObj,swf,characters,50);
    showFontTag((FontTag)tagObj);
  }
 else   if (tagObj instanceof FrameNode && ((FrameNode)tagObj).isDisplayed() && (miInternalViewer.isSelected())) {
    showCard(CARDDRAWPREVIEWPANEL);
    FrameNode fn=(FrameNode)tagObj;
    List<Tag> controlTags=swf.tags;
    int containerId=0;
    RECT rect=swf.displayRect;
    int totalFrameCount=swf.frameCount;
    if (fn.getParent() instanceof DefineSpriteTag) {
      controlTags=((DefineSpriteTag)fn.getParent()).subTags;
      containerId=((DefineSpriteTag)fn.getParent()).spriteId;
      rect=((DefineSpriteTag)fn.getParent()).getRect(characters,new Stack<Integer>());
      totalFrameCount=((DefineSpriteTag)fn.getParent()).frameCount;
    }
    previewImagePanel.setImage(SWF.frameToImage(containerId,((FrameNode)tagObj).getFrame() - 1,swf.tags,controlTags,rect,totalFrameCount,new Stack<Integer>()));
  }
 else   if (((tagObj instanceof FrameNode) && ((FrameNode)tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
    ((CardLayout)viewerCards.getLayout()).show(viewerCards,FLASH_VIEWER_CARD);
    try {
      if (tempFile != null) {
        tempFile.delete();
      }
      tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
      tempFile.deleteOnExit();
      Color backgroundColor=View.swfBackgroundColor;
      if (tagObj instanceof FontTag) {
        backgroundColor=View.DEFAULT_BACKGROUND_COLOR;
      }
      int frameCount=1;
      int frameRate=swf.frameRate;
      HashMap<Integer,VideoFrameTag> videoFrames=new HashMap<>();
      DefineVideoStreamTag vs=null;
      if (tagObj instanceof DefineVideoStreamTag) {
        vs=(DefineVideoStreamTag)tagObj;
        swf.populateVideoFrames(vs.getCharacterId(),swf.tags,videoFrames);
        frameCount=videoFrames.size();
      }
      List<SoundStreamBlockTag> soundFrames=new ArrayList<>();
      if (tagObj instanceof SoundStreamHeadTypeTag) {
        SWF.populateSoundStreamBlocks(swf.tags,(Tag)tagObj,soundFrames);
        frameCount=soundFrames.size();
      }
      if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
        frameCount=100;
        frameRate=50;
      }
      if (tagObj instanceof DefineSoundTag) {
        frameCount=1;
      }
      try (FileOutputStream fos=new FileOutputStream(tempFile)){
        SWFOutputStream sos=new SWFOutputStream(fos,10);
        sos.write("String_Node_Str".getBytes());
        sos.write(swf.version);
        ByteArrayOutputStream baos=new ByteArrayOutputStream();
        SWFOutputStream sos2=new SWFOutputStream(baos,10);
        int width=swf.displayRect.Xmax - swf.displayRect.Xmin;
        int height=swf.displayRect.Ymax - swf.displayRect.Ymin;
        sos2.writeRECT(swf.displayRect);
        sos2.writeUI8(0);
        sos2.writeUI8(frameRate);
        sos2.writeUI16(frameCount);
        if (tagObj instanceof FrameNode) {
          FrameNode fn=(FrameNode)tagObj;
          if (fn.getParent() == null) {
            for (            Tag t : swf.tags) {
              if (t instanceof SetBackgroundColorTag) {
                backgroundColor=((SetBackgroundColorTag)t).backgroundColor.toColor();
                break;
              }
            }
          }
        }
        sos2.writeTag(new SetBackgroundColorTag(null,new RGB(backgroundColor)));
        if (tagObj instanceof FrameNode) {
          FrameNode fn=(FrameNode)tagObj;
          Object parent=fn.getParent();
          List<ContainerItem> subs=new ArrayList<>();
          if (parent == null) {
            subs.addAll(swf.tags);
          }
 else {
            if (parent instanceof Container) {
              subs=((Container)parent).getSubItems();
            }
          }
          List<Integer> doneCharacters=new ArrayList<>();
          int frameCnt=1;
          for (          Object o : subs) {
            if (o instanceof ShowFrameTag) {
              frameCnt++;
              continue;
            }
            if (frameCnt > fn.getFrame()) {
              break;
            }
            Tag t=(Tag)o;
            Set<Integer> needed=t.getDeepNeededCharacters(characters,new ArrayList<Integer>());
            for (            int n : needed) {
              if (!doneCharacters.contains(n)) {
                sos2.writeTag(classicTag(characters.get(n)));
                doneCharacters.add(n);
              }
            }
            if (t instanceof CharacterTag) {
              doneCharacters.add(((CharacterTag)t).getCharacterId());
            }
            sos2.writeTag(classicTag(t));
            if (parent != null) {
              if (t instanceof PlaceObjectTypeTag) {
                PlaceObjectTypeTag pot=(PlaceObjectTypeTag)t;
                int chid=pot.getCharacterId();
                int depth=pot.getDepth();
                MATRIX mat=pot.getMatrix();
                if (mat == null) {
                  mat=new MATRIX();
                }
                mat=(MATRIX)Helper.deepCopy(mat);
                if (parent instanceof BoundedTag) {
                  RECT r=((BoundedTag)parent).getRect(characters,new Stack<Integer>());
                  mat.translateX=mat.translateX + width / 2 - r.getWidth() / 2;
                  mat.translateY=mat.translateY + height / 2 - r.getHeight() / 2;
                }
 else {
                  mat.translateX+=width / 2;
                  mat.translateY+=height / 2;
                }
                sos2.writeTag(new PlaceObject2Tag(null,false,false,false,false,false,true,false,true,depth,chid,mat,null,0,null,0,null));
              }
            }
          }
          sos2.writeTag(new ShowFrameTag(null));
        }
 else {
          if (tagObj instanceof DefineBitsTag) {
            if (jtt != null) {
              sos2.writeTag(jtt);
            }
          }
 else           if (tagObj instanceof AloneTag) {
          }
 else {
            Set<Integer> needed=((Tag)tagObj).getDeepNeededCharacters(characters,new ArrayList<Integer>());
            for (            int n : needed) {
              sos2.writeTag(classicTag(characters.get(n)));
            }
          }
          sos2.writeTag(classicTag((Tag)tagObj));
          int chtId=0;
          if (tagObj instanceof CharacterTag) {
            chtId=((CharacterTag)tagObj).getCharacterId();
          }
          MATRIX mat=new MATRIX();
          mat.hasRotate=false;
          mat.hasScale=false;
          mat.translateX=0;
          mat.translateY=0;
          if (tagObj instanceof BoundedTag) {
            RECT r=((BoundedTag)tagObj).getRect(characters,new Stack<Integer>());
            mat.translateX=-r.Xmin;
            mat.translateY=-r.Ymin;
            mat.translateX=mat.translateX + width / 2 - r.getWidth() / 2;
            mat.translateY=mat.translateY + height / 2 - r.getHeight() / 2;
          }
 else {
            mat.translateX=width / 4;
            mat.translateY=height / 4;
          }
          if (tagObj instanceof FontTag) {
            int countGlyphs=((FontTag)tagObj).getGlyphShapeTable().size();
            int fontId=((FontTag)tagObj).getFontId();
            int sloupcu=(int)Math.ceil(Math.sqrt(countGlyphs));
            int radku=(int)Math.ceil(((float)countGlyphs) / ((float)sloupcu));
            int x=0;
            int y=1;
            for (int f=0; f < countGlyphs; f++) {
              if (x >= sloupcu) {
                x=0;
                y++;
              }
              List<TEXTRECORD> rec=new ArrayList<>();
              TEXTRECORD tr=new TEXTRECORD();
              int textHeight=height / radku;
              tr.fontId=fontId;
              tr.styleFlagsHasFont=true;
              tr.textHeight=textHeight;
              tr.glyphEntries=new GLYPHENTRY[1];
              tr.styleFlagsHasColor=true;
              tr.textColor=new RGB(0,0,0);
              tr.glyphEntries[0]=new GLYPHENTRY();
              tr.glyphEntries[0].glyphAdvance=0;
              tr.glyphEntries[0].glyphIndex=f;
              rec.add(tr);
              mat.translateX=x * width / sloupcu;
              mat.translateY=y * height / radku;
              sos2.writeTag(new DefineTextTag(null,999 + f,new RECT(0,width,0,height),new MATRIX(),rec));
              sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,true,false,1 + f,999 + f,mat,null,0,null,0,null));
              x++;
            }
            sos2.writeTag(new ShowFrameTag(null));
          }
 else           if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
            sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,true,false,1,chtId,mat,null,0,null,0,null));
            sos2.writeTag(new ShowFrameTag(null));
            int numFrames=100;
            for (int ratio=0; ratio < 65536; ratio+=65536 / numFrames) {
              sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,false,true,1,chtId,mat,null,ratio,null,0,null));
              sos2.writeTag(new ShowFrameTag(null));
            }
          }
 else           if (tagObj instanceof SoundStreamHeadTypeTag) {
            for (            SoundStreamBlockTag blk : soundFrames) {
              sos2.writeTag(blk);
              sos2.writeTag(new ShowFrameTag(null));
            }
          }
 else           if (tagObj instanceof DefineSoundTag) {
            ExportAssetsTag ea=new ExportAssetsTag();
            DefineSoundTag ds=(DefineSoundTag)tagObj;
            ea.tags.add(ds.soundId);
            ea.names.add("String_Node_Str");
            sos2.writeTag(ea);
            List<Action> actions;
            DoActionTag doa;
            doa=new DoActionTag(null,new byte[]{},SWF.DEFAULT_VERSION,0);
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            sos2.writeTag(new ShowFrameTag(null));
            if (flashPanel != null) {
              flashPanel.specialPlayback=true;
            }
          }
 else           if (tagObj instanceof DefineVideoStreamTag) {
            sos2.writeTag(new PlaceObject2Tag(null,false,false,false,false,false,true,true,false,1,chtId,mat,null,0,null,0,null));
            List<VideoFrameTag> frs=new ArrayList<>(videoFrames.values());
            Collections.sort(frs,new Comparator<VideoFrameTag>(){
              @Override public int compare(              VideoFrameTag o1,              VideoFrameTag o2){
                return o1.frameNum - o2.frameNum;
              }
            }
);
            boolean first=true;
            int ratio=0;
            for (            VideoFrameTag f : frs) {
              if (!first) {
                ratio++;
                sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,false,false,true,1,0,null,null,ratio,null,0,null));
              }
              sos2.writeTag(f);
              sos2.writeTag(new ShowFrameTag(null));
              first=false;
            }
          }
 else {
            sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,true,false,1,chtId,mat,null,0,null,0,null));
            sos2.writeTag(new ShowFrameTag(null));
          }
        }
        sos2.writeTag(new EndTag(null));
        byte[] data=baos.toByteArray();
        sos.writeUI32(sos.getPos() + data.length + 4);
        sos.write(data);
        fos.flush();
      }
       showCard(CARDFLASHPANEL);
      if (flashPanel != null) {
        if (flashPanel instanceof FlashPlayerPanel) {
          flashPanel.displaySWF(tempFile.getAbsolutePath(),backgroundColor,frameRate);
        }
      }
    }
 catch (    IOException|com.jpexs.decompiler.flash.action.parser.ParseException ex) {
      Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,null,ex);
    }
    if (tagObj instanceof TextTag) {
      parametersPanel.setVisible(true);
      previewSplitPane.setDividerLocation(previewSplitPane.getWidth() / 2);
      showDetailWithPreview(CARDTEXTPANEL);
      textValue.setText(((TextTag)tagObj).getFormattedText(swf.tags));
    }
 else     if (tagObj instanceof FontTag) {
      showFontTag((FontTag)tagObj);
    }
 else {
      parametersPanel.setVisible(false);
    }
  }
 else {
    showCard(CARDEMPTYPANEL);
  }
}

Fixed version (ground truth):
public void reload(boolean forceReload){
  Object tagObj=tagTree.getLastSelectedPathComponent();
  if (tagObj == null) {
    return;
  }
  if (tagObj instanceof TagNode) {
    tagObj=((TagNode)tagObj).tag;
  }
  if (tagObj instanceof TreeElement) {
    tagObj=((TreeElement)tagObj).getItem();
  }
  if (!forceReload && (tagObj == oldValue)) {
    return;
  }
  if (flashPanel != null) {
    flashPanel.specialPlayback=false;
  }
  swfPreviewPanel.stop();
  stopFlashPlayer();
  oldValue=tagObj;
  if (tagObj instanceof ScriptPack) {
    final ScriptPack scriptLeaf=(ScriptPack)tagObj;
    if (!Main.isWorking()) {
      Main.startWork(translate("String_Node_Str") + "String_Node_Str",new Runnable(){
        @Override public void run(){
          if (setSourceTask != null) {
            setSourceTask.cancel(true);
          }
          abcPanel.decompiledTextArea.setText("String_Node_Str" + AppStrings.translate("String_Node_Str"));
        }
      }
);
      FutureTask<Void> task=Helper.callAsync(new Callable<Void>(){
        @Override public Void call() throws Exception {
          int classIndex=-1;
          for (          Trait t : scriptLeaf.abc.script_info[scriptLeaf.scriptIndex].traits.traits) {
            if (t instanceof TraitClass) {
              classIndex=((TraitClass)t).class_info;
              break;
            }
          }
          abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setCode("String_Node_Str");
          abcPanel.navigator.setABC(abcList,scriptLeaf.abc);
          abcPanel.navigator.setClassIndex(classIndex,scriptLeaf.scriptIndex);
          abcPanel.setAbc(scriptLeaf.abc);
          abcPanel.decompiledTextArea.setScript(scriptLeaf,abcList);
          abcPanel.decompiledTextArea.setClassIndex(classIndex);
          abcPanel.decompiledTextArea.setNoTrait();
          return null;
        }
      }
,new Callback<AsyncResult<Void>>(){
        @Override public void call(        AsyncResult<Void> result){
          setSourceTask=null;
          if (result.error != null) {
            abcPanel.decompiledTextArea.setText("String_Node_Str" + result.error);
          }
          Main.stopWork();
        }
      }
);
      setSourceTask=task;
    }
    showDetail(DETAILCARDAS3NAVIGATOR);
    showCard(CARDACTIONSCRIPTPANEL);
    return;
  }
 else {
    showDetail(DETAILCARDEMPTYPANEL);
  }
  if ((tagObj instanceof SWFRoot)) {
    if (miInternalViewer.isSelected()) {
      showCard(CARDSWFPREVIEWPANEL);
      swfPreviewPanel.load(swf);
      swfPreviewPanel.play();
    }
 else {
      showCard(CARDFLASHPANEL);
      parametersPanel.setVisible(false);
      if (flashPanel != null) {
        Color backgroundColor=View.DEFAULT_BACKGROUND_COLOR;
        for (        Tag t : swf.tags) {
          if (t instanceof SetBackgroundColorTag) {
            backgroundColor=((SetBackgroundColorTag)t).backgroundColor.toColor();
            break;
          }
        }
        if (flashPanel instanceof FlashPlayerPanel) {
          if (tempFile != null) {
            tempFile.delete();
          }
          try {
            tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
            tempFile.deleteOnExit();
            swf.saveTo(new FileOutputStream(tempFile));
            flashPanel.displaySWF(tempFile.getAbsolutePath(),backgroundColor,swf.frameRate);
          }
 catch (          IOException iex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,"String_Node_Str",iex);
          }
        }
      }
    }
  }
 else   if (tagObj instanceof DefineBinaryDataTag) {
    showCard(CARDEMPTYPANEL);
  }
 else   if (tagObj instanceof ASMSource) {
    showCard(CARDACTIONSCRIPTPANEL);
    actionPanel.setSource((ASMSource)tagObj,!forceReload);
  }
 else   if (tagObj instanceof ImageTag) {
    imageButtonsPanel.setVisible(((ImageTag)tagObj).importSupported());
    showCard(CARDIMAGEPANEL);
    imagePanel.setImage(((ImageTag)tagObj).getImage(swf.tags));
  }
 else   if ((tagObj instanceof DrawableTag) && (!(tagObj instanceof TextTag)) && (!(tagObj instanceof FontTag))&& (miInternalViewer.isSelected())) {
    showCard(CARDDRAWPREVIEWPANEL);
    previewImagePanel.setDrawable((DrawableTag)tagObj,swf,characters,50);
  }
 else   if ((tagObj instanceof FontTag) && (miInternalViewer.isSelected())) {
    showCard(CARDFLASHPANEL);
    previewImagePanel.setDrawable((DrawableTag)tagObj,swf,characters,50);
    showFontTag((FontTag)tagObj);
  }
 else   if (tagObj instanceof FrameNode && ((FrameNode)tagObj).isDisplayed() && (miInternalViewer.isSelected())) {
    showCard(CARDDRAWPREVIEWPANEL);
    FrameNode fn=(FrameNode)tagObj;
    List<Tag> controlTags=swf.tags;
    int containerId=0;
    RECT rect=swf.displayRect;
    int totalFrameCount=swf.frameCount;
    if (fn.getParent() instanceof DefineSpriteTag) {
      controlTags=((DefineSpriteTag)fn.getParent()).subTags;
      containerId=((DefineSpriteTag)fn.getParent()).spriteId;
      rect=((DefineSpriteTag)fn.getParent()).getRect(characters,new Stack<Integer>());
      totalFrameCount=((DefineSpriteTag)fn.getParent()).frameCount;
    }
    previewImagePanel.setImage(SWF.frameToImage(containerId,((FrameNode)tagObj).getFrame() - 1,swf.tags,controlTags,rect,totalFrameCount,new Stack<Integer>()));
  }
 else   if (((tagObj instanceof FrameNode) && ((FrameNode)tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
    ((CardLayout)viewerCards.getLayout()).show(viewerCards,FLASH_VIEWER_CARD);
    try {
      if (tempFile != null) {
        tempFile.delete();
      }
      tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
      tempFile.deleteOnExit();
      Color backgroundColor=View.swfBackgroundColor;
      if (tagObj instanceof FontTag) {
        backgroundColor=View.DEFAULT_BACKGROUND_COLOR;
      }
      int frameCount=1;
      int frameRate=swf.frameRate;
      HashMap<Integer,VideoFrameTag> videoFrames=new HashMap<>();
      DefineVideoStreamTag vs=null;
      if (tagObj instanceof DefineVideoStreamTag) {
        vs=(DefineVideoStreamTag)tagObj;
        swf.populateVideoFrames(vs.getCharacterId(),swf.tags,videoFrames);
        frameCount=videoFrames.size();
      }
      List<SoundStreamBlockTag> soundFrames=new ArrayList<>();
      if (tagObj instanceof SoundStreamHeadTypeTag) {
        SWF.populateSoundStreamBlocks(swf.tags,(Tag)tagObj,soundFrames);
        frameCount=soundFrames.size();
      }
      if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
        frameCount=100;
        frameRate=50;
      }
      if (tagObj instanceof DefineSoundTag) {
        frameCount=1;
      }
      try (FileOutputStream fos=new FileOutputStream(tempFile)){
        SWFOutputStream sos=new SWFOutputStream(fos,10);
        sos.write("String_Node_Str".getBytes());
        sos.write(swf.version);
        ByteArrayOutputStream baos=new ByteArrayOutputStream();
        SWFOutputStream sos2=new SWFOutputStream(baos,10);
        int width=swf.displayRect.Xmax - swf.displayRect.Xmin;
        int height=swf.displayRect.Ymax - swf.displayRect.Ymin;
        sos2.writeRECT(swf.displayRect);
        sos2.writeUI8(0);
        sos2.writeUI8(frameRate);
        sos2.writeUI16(frameCount);
        if (tagObj instanceof FrameNode) {
          FrameNode fn=(FrameNode)tagObj;
          if (fn.getParent() == null) {
            for (            Tag t : swf.tags) {
              if (t instanceof SetBackgroundColorTag) {
                backgroundColor=((SetBackgroundColorTag)t).backgroundColor.toColor();
                break;
              }
            }
          }
        }
        sos2.writeTag(new SetBackgroundColorTag(null,new RGB(backgroundColor)));
        if (tagObj instanceof FrameNode) {
          FrameNode fn=(FrameNode)tagObj;
          Object parent=fn.getParent();
          List<ContainerItem> subs=new ArrayList<>();
          if (parent == null) {
            subs.addAll(swf.tags);
          }
 else {
            if (parent instanceof Container) {
              subs=((Container)parent).getSubItems();
            }
          }
          List<Integer> doneCharacters=new ArrayList<>();
          int frameCnt=1;
          for (          Object o : subs) {
            if (o instanceof ShowFrameTag) {
              frameCnt++;
              continue;
            }
            if (frameCnt > fn.getFrame()) {
              break;
            }
            Tag t=(Tag)o;
            Set<Integer> needed=t.getDeepNeededCharacters(characters,new ArrayList<Integer>());
            for (            int n : needed) {
              if (!doneCharacters.contains(n)) {
                sos2.writeTag(classicTag(characters.get(n)));
                doneCharacters.add(n);
              }
            }
            if (t instanceof CharacterTag) {
              doneCharacters.add(((CharacterTag)t).getCharacterId());
            }
            sos2.writeTag(classicTag(t));
            if (parent != null) {
              if (t instanceof PlaceObjectTypeTag) {
                PlaceObjectTypeTag pot=(PlaceObjectTypeTag)t;
                int chid=pot.getCharacterId();
                int depth=pot.getDepth();
                MATRIX mat=pot.getMatrix();
                if (mat == null) {
                  mat=new MATRIX();
                }
                mat=(MATRIX)Helper.deepCopy(mat);
                if (parent instanceof BoundedTag) {
                  RECT r=((BoundedTag)parent).getRect(characters,new Stack<Integer>());
                  mat.translateX=mat.translateX + width / 2 - r.getWidth() / 2;
                  mat.translateY=mat.translateY + height / 2 - r.getHeight() / 2;
                }
 else {
                  mat.translateX+=width / 2;
                  mat.translateY+=height / 2;
                }
                sos2.writeTag(new PlaceObject2Tag(null,false,false,false,false,false,true,false,true,depth,chid,mat,null,0,null,0,null));
              }
            }
          }
          sos2.writeTag(new ShowFrameTag(null));
        }
 else {
          if (tagObj instanceof DefineBitsTag) {
            if (jtt != null) {
              sos2.writeTag(jtt);
            }
          }
 else           if (tagObj instanceof AloneTag) {
          }
 else {
            Set<Integer> needed=((Tag)tagObj).getDeepNeededCharacters(characters,new ArrayList<Integer>());
            for (            int n : needed) {
              sos2.writeTag(classicTag(characters.get(n)));
            }
          }
          sos2.writeTag(classicTag((Tag)tagObj));
          int chtId=0;
          if (tagObj instanceof CharacterTag) {
            chtId=((CharacterTag)tagObj).getCharacterId();
          }
          MATRIX mat=new MATRIX();
          mat.hasRotate=false;
          mat.hasScale=false;
          mat.translateX=0;
          mat.translateY=0;
          if (tagObj instanceof BoundedTag) {
            RECT r=((BoundedTag)tagObj).getRect(characters,new Stack<Integer>());
            mat.translateX=-r.Xmin;
            mat.translateY=-r.Ymin;
            mat.translateX=mat.translateX + width / 2 - r.getWidth() / 2;
            mat.translateY=mat.translateY + height / 2 - r.getHeight() / 2;
          }
 else {
            mat.translateX=width / 4;
            mat.translateY=height / 4;
          }
          if (tagObj instanceof FontTag) {
            int countGlyphs=((FontTag)tagObj).getGlyphShapeTable().size();
            int fontId=((FontTag)tagObj).getFontId();
            int sloupcu=(int)Math.ceil(Math.sqrt(countGlyphs));
            int radku=(int)Math.ceil(((float)countGlyphs) / ((float)sloupcu));
            int x=0;
            int y=1;
            for (int f=0; f < countGlyphs; f++) {
              if (x >= sloupcu) {
                x=0;
                y++;
              }
              List<TEXTRECORD> rec=new ArrayList<>();
              TEXTRECORD tr=new TEXTRECORD();
              int textHeight=height / radku;
              tr.fontId=fontId;
              tr.styleFlagsHasFont=true;
              tr.textHeight=textHeight;
              tr.glyphEntries=new GLYPHENTRY[1];
              tr.styleFlagsHasColor=true;
              tr.textColor=new RGB(0,0,0);
              tr.glyphEntries[0]=new GLYPHENTRY();
              tr.glyphEntries[0].glyphAdvance=0;
              tr.glyphEntries[0].glyphIndex=f;
              rec.add(tr);
              mat.translateX=x * width / sloupcu;
              mat.translateY=y * height / radku;
              sos2.writeTag(new DefineTextTag(null,999 + f,new RECT(0,width,0,height),new MATRIX(),rec));
              sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,true,false,1 + f,999 + f,mat,null,0,null,0,null));
              x++;
            }
            sos2.writeTag(new ShowFrameTag(null));
          }
 else           if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
            sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,true,false,1,chtId,mat,null,0,null,0,null));
            sos2.writeTag(new ShowFrameTag(null));
            int numFrames=100;
            for (int ratio=0; ratio < 65536; ratio+=65536 / numFrames) {
              sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,false,true,1,chtId,mat,null,ratio,null,0,null));
              sos2.writeTag(new ShowFrameTag(null));
            }
          }
 else           if (tagObj instanceof SoundStreamHeadTypeTag) {
            for (            SoundStreamBlockTag blk : soundFrames) {
              sos2.writeTag(blk);
              sos2.writeTag(new ShowFrameTag(null));
            }
          }
 else           if (tagObj instanceof DefineSoundTag) {
            ExportAssetsTag ea=new ExportAssetsTag();
            DefineSoundTag ds=(DefineSoundTag)tagObj;
            ea.tags.add(ds.soundId);
            ea.names.add("String_Node_Str");
            sos2.writeTag(ea);
            List<Action> actions;
            DoActionTag doa;
            doa=new DoActionTag(null,new byte[]{},SWF.DEFAULT_VERSION,0);
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            actions=ASMParser.parse(0,0,false,"String_Node_Str" + "String_Node_Str",SWF.DEFAULT_VERSION,false);
            doa.setActions(actions,SWF.DEFAULT_VERSION);
            sos2.writeTag(doa);
            sos2.writeTag(new ShowFrameTag(null));
            sos2.writeTag(new ShowFrameTag(null));
            if (flashPanel != null) {
              flashPanel.specialPlayback=true;
            }
          }
 else           if (tagObj instanceof DefineVideoStreamTag) {
            sos2.writeTag(new PlaceObject2Tag(null,false,false,false,false,false,true,true,false,1,chtId,mat,null,0,null,0,null));
            List<VideoFrameTag> frs=new ArrayList<>(videoFrames.values());
            Collections.sort(frs,new Comparator<VideoFrameTag>(){
              @Override public int compare(              VideoFrameTag o1,              VideoFrameTag o2){
                return o1.frameNum - o2.frameNum;
              }
            }
);
            boolean first=true;
            int ratio=0;
            for (            VideoFrameTag f : frs) {
              if (!first) {
                ratio++;
                sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,false,false,true,1,0,null,null,ratio,null,0,null));
              }
              sos2.writeTag(f);
              sos2.writeTag(new ShowFrameTag(null));
              first=false;
            }
          }
 else {
            sos2.writeTag(new PlaceObject2Tag(null,false,false,false,true,false,true,true,false,1,chtId,mat,null,0,null,0,null));
            sos2.writeTag(new ShowFrameTag(null));
          }
        }
        sos2.writeTag(new EndTag(null));
        byte[] data=baos.toByteArray();
        sos.writeUI32(sos.getPos() + data.length + 4);
        sos.write(data);
        fos.flush();
      }
       showCard(CARDFLASHPANEL);
      if (flashPanel != null) {
        if (flashPanel instanceof FlashPlayerPanel) {
          flashPanel.displaySWF(tempFile.getAbsolutePath(),backgroundColor,frameRate);
        }
      }
    }
 catch (    IOException|com.jpexs.decompiler.flash.action.parser.ParseException ex) {
      Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,null,ex);
    }
    if (tagObj instanceof TextTag) {
      parametersPanel.setVisible(true);
      previewSplitPane.setDividerLocation(previewSplitPane.getWidth() / 2);
      showDetailWithPreview(CARDTEXTPANEL);
      textValue.setText(((TextTag)tagObj).getFormattedText(swf.tags));
    }
 else     if (tagObj instanceof FontTag) {
      showFontTag((FontTag)tagObj);
    }
 else {
      parametersPanel.setVisible(false);
    }
  }
 else {
    showCard(CARDEMPTYPANEL);
  }
}