Home > Article > Web Front-end > Specific method for obtaining flash height and width using Java/JS
This article will introduce in detail how to obtain the height and width of flash using Java/JS. There is a good example below. Interested friends can refer to it. I hope it will be helpful to everyone.
JS:
Setting the embed height and width can change the height and width of the flash to obtain.
<!DOCTYPE HTML> <html> <body> <embed src="test550X400.swf" id="flash" width="550px" height="400px"/> <script type="text/javascript"> var flash = document.getElementById("flash"); alert("宽:"+flash.width+" 高:"+flash.height); </script> </body> </html>
JAVA:
Use java to parse the flash file header information to get the size of the flash. It is important to note that there are two types of flash: FWS and CWS. The data part of CWS is in the form of flash compressed by zlib and needs to be decompressed before parsing.
For FWS type flash, the header information contains size information. The parsing method is as follows:
The first three bytes identify the type of flash (FWS/CWS);
5 , 6, 7, and 8 bytes are the size of the flash file;
Read 5 bits from the 9th byte, and set the value to n. After n bits, read n bits, and set the value to x; Skip again n bits, read n bits, set the value to y. The width and height of the swf are x/20 and y/20 pixels respectively.
The above is the entire content of this chapter. For more related tutorials, please visit JavaScript Video Tutorial!