• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Problem with Source:Object and Output:File

New Here ,
Nov 09, 2011 Nov 09, 2011

Copy link to clipboard

Copied

Hello dear people,

i have been found example like FileCompressTool.

But i have been coded for conversors or decompilers.

I have got error of File and FileStream

Look at my picture

http://www.funpic.de/photos/5/7/3/4/7/574375_45b95ed909_e.jpg

I have been tried because my Adobe AIr Application has not error..

How do i fix this error? Or i must run Adobe Air as Administrator Right?

Code for Example:

<?xml version="1.0" encoding="utf-8"?>

<mx:WindowedApplication

          title="Half-Life Map Decompiler"

          xmlns:mx="http://www.adobe.com/2006/mxml"

          layout="absolute"

          showStatusBar="false">

 

          <mx:Script>

                    <![CDATA[

                              import com.valve.utils.mapEncorder;

 

                              import flash.filesystem.File;

 

                              private var bspSrc:File;

                              private var mapDes:File;

 

                              private function ChooseSrc():void

                              {

                                        if( bspSrc == null ) {

                                                  bspSrc = new File();

                                        }

                                        bspSrc.addEventListener(Event.SELECT,  sourceSelectHandler);

                                        bspSrc.browseForOpen("Choose Half-Life 1 Bsp File", [new FileFilter("Half-Life 1 *.bsp", "*.bsp")]);

                              }

 

                              private function sourceSelectHandler(event:Event):void

                              {

                                        bspSrcText.text = bspSrc.nativePath;

                                        StateLog.text = bspSrc.nativePath + " has been selected.";

 

                              }

 

                              private function ChooseDes():void

                              {

                                        if ( mapDes == null ) {

                                                  mapDes = new File();

                                        }

                                        mapDes.addEventListener(Event.SELECT, destinationSelectHandler);

                                        mapDes.browseForDirectory("Choose for decompiled Map file!");

                              }

 

                              private function destinationSelectHandler(event:Event):void

                              {

                                        mapDesText.text = mapDes.nativePath;

                                        StateLog.text = mapDes.nativePath + " has been selected.";

                              }

 

                              private function Decompile():void

                              {

                                        var bsp2map:mapEncorder = new mapEncorder();

                                        bsp2map.decompileBsp2map(bspSrc, mapDes);

                                        StateLog.text = "This Map File has been decompiled complety.";

                              }

 

                    ]]>

          </mx:Script>

 

          <mx:Label left="10" top="10" text="Choose your bsp ( used by Half-Life 1 ):"/>

          <mx:TextInput id="bspSrcText" left="15" right="63" top="36"/>

          <mx:Button right="15" top="36" label="..." click="ChooseSrc()"/>

          <mx:Label left="10" top="70" text="Choose your decompiled map in your directory:"/>

          <mx:TextInput id="mapDesText" left="15" right="63" top="96"/>

          <mx:Button right="15" top="96" label="..." click="ChooseDes()"/>

          <mx:Label left="10" top="130" text="View with decompiled details:"/>

          <mx:Button right="98" top="128" label="Decompile" click="Decompile()"/>

          <mx:Button right="192" top="128" label="Clean log"/>

          <mx:TextArea id="StateLog" left="15" right="15" top="156" bottom="15"/>

          <mx:Button right="15" top="128" width="75" label="About..."/>

 

</mx:WindowedApplication>

And com.valve.utils.mapEncorder.as

/*

          Valve Software

          Half-Life 1 - Maps

*/

package com.valve.utils

{

          import flash.filesystem.File;

          import flash.filesystem.FileMode;

          import flash.filesystem.FileStream;

          import flash.utils.ByteArray;

          public class mapEncorder

          {

                    public function decompileBsp2map(bspSrc:Object, mapDes:File):void

                    {

                              if( bspSrc == null || mapDes == null ){

                                        throw new ArgumentError("Half-LIfe Bsp File and Half-Life Map File cannot be null.");

                              }

 

                              var bspSrcByte:ByteArray;

                              var mapFileTarget:File = new File(mapDes.nativePath);

 

                              var fileTime:Date;

 

                              if(bspSrc is File){

                                        var bspSrcFile:File = new File;

                                        if(bspSrcFile.exists || bspSrcFile.isDirectory){

                                                  throw new ArgumentError("If your bsp File is current version.");

                                        }

 

                                        var bspFileStream:FileStream = new FileStream();

                                        bspFileStream.open(bspSrcFile, FileMode.READ);

                                        bspSrcByte = new ByteArray;

                                        bspFileStream.readBytes(bspSrcByte, bspFileStream.bytesAvailable);

                                        bspFileStream.close();

 

                                        if (mapFileTarget.isDirectory)

                                        {

                                                  mapFileTarget = mapFileTarget.resolvePath(bspSrcFile.name + ".map");

                                                  fileTime = bspSrcFile.modificationDate;

                                        }

                                        else if (bspSrc is ByteArray)

                                        {

                                                  bspSrcByte = bspSrc as ByteArray;

 

                                                  if (mapFileTarget.isDirectory)

                                                  {

                                                            mapFileTarget = mapFileTarget.resolvePath("_decompiled.map");

                                                  }

 

                                                  fileTime = new Date();

                                        }

                                        else

                                        {

                                                  throw new ArgumentError("Bsp File must be complety.");

                                        }

 

                                        var mapFileStream:FileStream = new FileStream();

                                        mapFileStream.open(mapFileTarget, FileMode.WRITE);

                                        mapFileStream.writeBytes(bspSrcByte);

                                        mapFileStream.close();

                              }

                    }

          }

}

Thank you for help - If you find an error than you can tell me. If it doesn't work than i will try Flash Builder with Running as Admin.

Regards J. Eckervogt

Views

578

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2011 Nov 09, 2011

Copy link to clipboard

Copied

LATEST

I have been found problem because i have been found issus of if (...) with !

It is okay. I have been forgotten. I am sorry. Thanks.. I have been fixed this..

It is true

But is worng code :

/*


          Valve Software


          Half-Life 1 - Maps
*/
package com.valve.utils
{
          import flash.filesystem.File;
          import flash.filesystem.FileMode;
          import flash.filesystem.FileStream;
          import flash.utils.ByteArray;


          public class mapEncorder
          {
                    public function decompileBsp2map(bspSrc:Object, mapDes:File):void
                    {
                              if( bspSrc == null || mapDes == null ){
                                        throw new ArgumentError("Half-LIfe Bsp File and Half-Life Map File cannot be null.");
                              }
 
                              var bspSrcByte:ByteArray;
                              var mapFileTarget:File = new File(mapDes.nativePath);
 
                              var fileTime:Date;
 
                              if(bspSrc is File){
                                        var bspSrcFile:File = new File;
                                        if(bspSrcFile.exists || bspSrcFile.isDirectory){
                                                  throw new ArgumentError("If your bsp File is current version.");
                                        }
 
                                        var bspFileStream:FileStream = new FileStream();
                                        bspFileStream.open(bspSrcFile, FileMode.READ);
                                        bspSrcByte = new ByteArray;
                                        bspFileStream.readBytes(bspSrcByte, bspFileStream.bytesAvailable);
                                        bspFileStream.close();
 
                                        if (mapFileTarget.isDirectory)
                                        {
                                                  mapFileTarget = mapFileTarget.resolvePath(bspSrcFile.name + ".map");
                                                  fileTime = bspSrcFile.modificationDate;
                                        }
                                        else if (bspSrc is ByteArray)
                                        {
                                                  bspSrcByte = bspSrc as ByteArray;
 
                                                  if (mapFileTarget.isDirectory)
                                                  {
                                                            mapFileTarget = mapFileTarget.resolvePath("_decompiled.map");
                                                  }
 
                                                  fileTime = new Date();
                                        }
                                        else
                                        {
                                                  throw new ArgumentError("Bsp File must be complety.");
                                        }
 
                                        var mapFileStream:FileStream = new FileStream();
                                        mapFileStream.open(mapFileTarget, FileMode.WRITE);
                                        mapFileStream.writeBytes(bspSrcByte);
                                        mapFileStream.close();
                              }
                    }
          }
}

Replace to:

/*

          Valve Software

          Half-Life 1 - Maps

*/

package com.valve.utils

{

          import flash.filesystem.File;

          import flash.filesystem.FileMode;

          import flash.filesystem.FileStream;

          import flash.utils.ByteArray;

          public class mapEncorder

          {

                    public function decompileBsp2map(bspSrc:Object, mapFile:File):void

                    {

                              if( bspSrc == null || mapFile == null ){

                                        throw new ArgumentError("Half-LIfe Bsp File and Half-Life Map File cannot be null.");

                              }

 

                              var bspSrcByte:ByteArray;

                              var mapFileTarget:File = new File(mapFile.nativePath);

 

                              var fileTime:Date;

 

                              if(bspSrc is File){

                                        var bspSrcFile:File = bspSrc as File;

                                        if(!bspSrcFile.exists || bspSrcFile.isDirectory){

                                                  throw new ArgumentError("If your bsp File is current version.");

                                        }

 

                                        var bspFileStream:FileStream = new FileStream();

                                        bspFileStream.open(bspSrcFile, FileMode.READ);

                                        bspSrcByte = new ByteArray();

                                        bspFileStream.readBytes(bspSrcByte, bspFileStream.bytesAvailable);

                                        bspFileStream.close();

 

                                        if (mapFileTarget.isDirectory)

                                        {

                                                  mapFileTarget = mapFileTarget.resolvePath(bspSrcFile.name + ".map");

                                                  fileTime = bspSrcFile.modificationDate;

                                        }

                                        else if (bspSrc is ByteArray)

                                        {

                                                  bspSrcByte = bspSrc as ByteArray;

 

                                                  if (mapFileTarget.isDirectory)

                                                  {

                                                            mapFileTarget = mapFileTarget.resolvePath("_decompiled.map");

                                                  }

 

                                                  fileTime = new Date();

                                        }

                                        else

                                        {

                                                  throw new ArgumentError("Bsp File must be complety.");

                                        }

 

 

 

                                        var mapFileStream:FileStream = new FileStream();

                                        mapFileStream.open(mapFileTarget, FileMode.WRITE);

 

                                        mapFileStream.writeBytes(bspSrcByte);

                                        mapFileStream.close();

                              }

                    }

          }

}

Now it is working. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines