0
A
回答
1
因此,要獲得這樣的味道,你可以試試這段代碼:
function test(){
var bytes:ByteArray = new ByteArray();
bytes.writeInt(0x00DDAA99); //create my byte array with int 14527129
bytes.position = 0; //move the postion to the start
var newInt:int = bytes.readInt(); //read the bytes from starting position
trace("new num: "+newInt); //print out the number
}
此代碼將首先創建一個字節數組,並把一個int進去。這大概是你需要啓動代碼的地方。這就假定在我設置爲0的起始位置之後有4個字節要讀取。然後它將字節數組中的4個字節讀入隊列。請注意,如果您的ByteArray中沒有4個字節,或者位置設置不正確,則代碼將失敗。確保你爲這些場景添加了檢查。
此代碼還假定字節數組是Big Endian。確保如果你有一個來自另一個系統的字節數組,那麼你知道int值具有哪個endian-ness。如果需要,更改您的字節數組的末端值。
相關問題
- 1. Flex處理圖像(轉換爲Bytearray)
- 2. 在javascript中將值轉換爲bytearray
- 3. 將System.Windows.Media.ImageSource轉換爲ByteArray
- 4. 將MovieClip轉換爲ByteArray
- 5. 將ByteArray轉換爲NSData
- 6. 將負值轉換爲bytearray
- 7. 將BinaryString轉換爲ByteArray - Java
- 8. 將bytearray轉換爲整數
- 9. .net將bytearray轉換爲double []
- 10. 如何將文件轉換爲Flex中的ByteArray?
- 11. Java轉換爲Integer?
- 12. 爲什麼PHP將String轉換爲Integer?
- 13. 如何將ActionScriptObject轉換爲ByteArray?
- 14. 如何將python str轉換爲bytearray
- 15. 使用Apache POI將byteArray轉換爲XSSFWorkbook
- 16. 如何將bytearray轉換爲zip文件
- 17. 將位圖轉換爲byteArray android
- 18. 將ByteArray轉換爲文件對象
- 19. 如何將字符串轉換爲Bytearray
- 20. 將api httpresponse bytearray轉換爲文件
- 21. 如何將bytearray轉換爲圖像或圖像bytearray?
- 22. 轉換PIL圖像爲bytearray
- 23. 將代碼轉換爲Array .....在Flex中
- 24. 在Flex 4.5中將ArrayCollection轉換爲ArrayLIst?
- 25. 如何將IBAN轉換爲Integer?
- 26. 將yyyymm-integer轉換爲日期
- 27. Ruby - 將Integer轉換爲字符串
- 28. BeanUtils.copyProperties將Integer null轉換爲0
- 29. 如何(有效)將int []轉換爲Integer []?
- 30. 將java.lang.object轉換爲Integer的問題