Flex to read binary file
Advertisements
Flex to read binary file
Flex can be used to read binary file class has four: ByteArray, FileStream, Socket, URLStream. They all realized IdataInput interfaces, which are located flash.utils, flash.filesystem, flash.net, flash.net package. Be noted that, FileStream only applies AIR project.
Details of the four classes and the use of methods, please refer to the official Adobe documentation: ActionScript3.0 Language and Components Reference: http://www.adobe.com/livedocs/flex/3_cn/ .
URLStream read with the attached format ESRI's shapfile example, this sample is based on Adobe Flash Builder4 development environment for ActionScript projects.
package
{
import flash.display.Sprite;
import flash.errors.IOError;
import flash.events.*;
import flash.net.URLRequest;
import flash.net.URLStream;
import flash.utils.Endian;
public class ShapeReader extends Sprite
{
private var _stream:URLStream;
public function ShapeReader()
{
this._stream = new URLStream();
this.readfile("http://localhost/data/regionprov_Clip.shp");
}
private function readfile(urlPath:String):void
{
var request:URLRequest = new URLRequest(urlPath);
this._stream.addEventListener(Event.COMPLETE,onComplete);
try
{
this._stream.load(request);
}
catch (error:Error)
{
trace("Unable to load requested URL.");
}
}
private function onComplete(event:Event):void
{
try
{
//.........................Begin of FileHeader
var code:int = this._stream.readInt();//File Code
this._stream.readUTFBytes(5*4);//skip int bytes in number of 5
var length:int = this._stream.readInt();//File Length
this._stream.endian = Endian.LITTLE_ENDIAN;//change byte order
var version:int = this._stream.readInt();//Version
var type:int = this._stream.readInt();//Shape Type
var xMin:Number = this._stream.readDouble();//Xmin
var yMin:Number = this._stream.readDouble();//Ymin
var xMax:Number = this._stream.readDouble();//Xmax
var yMax:Number = this._stream.readDouble();//Ymax
this._stream.readUTFBytes(4*8);// skip double bytes in number of 4
//.........................End of FileHeader
this._stream.close();// close stream
}
catch(error:IOError)
{
trace(error.toString());
}
}
}
}
LookAtYou 2010.8.25
Related Posts of Flex to read binary file
-
ActiveMQ practice the road (four) ActiveMQ 4.x + JBoss 4.x MDP actual articles
Keyword: ActiveMQ ActiveMQ practice the road (four) ActiveMQ 4.x + JBoss 4.x MDP actual articles At <<ActiveMQ Practice ( Three ) ActiveMQ 4.x +JBoss 4.x Consolidating articles >> which we compare in detail the ActiveMQ with JBoss integration
-
Rails source code analysis (1): RailsFCGIHandler
In accordance with the sequence starting from the beginning CGI Ruby CGI Doc: The Common Gateway Interface ( CGI ) Is a simple protocol for passing an HTTP request from a web server to a standalone program, and returning the output to the web browser ...
-
extjs development environment set up and practice
1, download and extract the extjs 2, download eclipse and Eclipse AJAX Toolkit Framework (ATF) I have been accustomed to using eclipse as a development environment, a variety of open-source plugin so that eclipse has all-around performance, operating effi
-
JS menu
JS menu
-
Answer: After 2.2 upgrade mysql question-driven
windows installed after the mysql gem error, error is approximately: ArgumentError (NULL pointer given): (eval): 3: in `each_hash ' (eval): 3: in `all_hashes' This is feeling under the windows of the question if the mysql gem version libmysql ...
-
log4j easy application in java
JAVA development, frequently used the log output, in a so-called most of the software company will have its own set of configuration style, re-read the configuration file to initialize property of the log, it will be good, but sometimes may not need to fu
-
In the Spring to configure Service
JTA in Spring Development Environment: JDK1.5 (sun) + Myeclipse6.0 + Tomcat5.5 + ant 1.7.1 + MySql5.0.4 Framework version: JSF1.2 (sun) + hibernate3.3.1.GA + spring2.5.6 JTA (Java Transaction API) Only supports the standard EJB Persistence (JTA) transacti
-
JDBC example of a long time do not have JDBC forgot
A back-up here to stay. The first: The second:
-
JAVA interview questions
JAVA interview questions 1, object-oriented features of what has 1. Abstract 2. Inheritance 3. Packaging 4. Polymorphisms 2, String data types are the most basic right? Basic data types include byte, int, char, long, float, double, boolean and short. java
-
Struts2 + hibernate + spring problem user log in
dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q












