Pete, Thanks a lot. This should keep me busy learning and experimenting. Gilbert
--- In [email protected], Peter Farland <pfarl...@...> wrote: > > Although not FLV, I wrote a sample AMF 0/AMF 3 client based on > flash.utils.ByteArray and flash.net.URLLoader. See my blog entry > http://blogs.adobe.com/pfarland/2008/06/using_amf_with_flashneturlload.html > which mentions the ActionScript source which was submitted to BlazeDS as an > attachment to BLZ-209. See amf.zip at: > https://bugs.adobe.com/jira/browse/BLZ-209 > > For FLV, the key is to understand the Type column for each field. I took a > quick look at the spec and it seems to use conventions similar to the SWF > format. > > private function onComplete(e:Event):void > { > var ba:ByteArray = loader.data as ByteArray; > > if (ba != null && ba.length > 9) > { > // Peek at the first 3 bytes to check for 'F' 'L' 'V' > if (ba.readUnsignedByte() == 0x46 && ba.readUnsignedByte() == 0x4C > && ba.readUnsignedByte() == 0x56) > { > ba.position = 0; > decodeFLV(ba); > } > } > } > > i.e. For UI8, use readUnsignedByte() to get a uint > For UB[n], use readUnsignedByte() and then shift to find the relevant bit(s) > for each flag. > For UI32, use readUnsignedInt() to get a uint > For UI24, use 3 successive readUnsignedBytes() and shift values appropriately > to form a uint from the 24bits. > etc... > > Pete > > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of gilbert_mizrahi > Sent: Wednesday, March 18, 2009 6:44 PM > To: [email protected] > Subject: [flexcoders] Re: Where I can examples of how to use ByteArray > > Alex, Thanks. Yes I have seen that, but there is noting similar for what I > want, that is to read the flv content to get its tags according to FLV spec > from http://www.adobe.com/devnet/flv/. > > Pete, that is a good starting point, thank you. However, I need more help to > be able to "read" the data from the FLV. readByte() returns an int and > readBytes expects at least one parameter of type ByteArray which I have no > clue what to put in there. And readObject(0 throws an ouf of bounds error. > > Gilbert > > --- In [email protected], Peter Farland <pfarland@> wrote: > > > > You may want to have loader as a member variable so that you can access it > > in other contexts or make subsequent requests without using init() > > > > private var loader:URLLoader; > > > > > > Also, you should set the loader.dataFormat to URLLoaderDataFormat.BINARY > > before loading binary data. See: > > http://livedocs.adobe.com/flex/3/langref/flash/net/URLLoader.html#dataFormat > > > > Finally, in the complete event, you can cast loader.data to a ByteArray: > > > > private function onComplete(e:Event):void > > { > > var byteArr:ByteArray = loader.data as ByteArray; > > // ... > > } > > > > Pete > > > > -----Original Message----- > > From: [email protected] [mailto:[email protected]] On > > Behalf Of gilbert_mizrahi > > Sent: Wednesday, March 18, 2009 11:22 AM > > To: [email protected] > > Subject: [flexcoders] Where I can examples of how to use ByteArray > > > > I have searched everywhere and I can't find useful examples of how to use > > the ByteArray class and the Flex 3 documentation does not include much. > > > > I want to read and FLV file with ByteArray, but I don't know how. > > > > I tried: > > > > private function init():void > > { > > var request:URLRequest = new URLRequest("assets/street.flv"); > > var loader:URLLoader = new URLLoader(); > > try { > > loader.load(request); > > } catch (error:ArgumentError) { > > trace("An ArgumentError has occurred."); > > } catch (error:SecurityError) { > > trace("A SecurityError has occurred."); > > } > > loader.addEventListener(Event.COMPLETE, onComplete); > > } > > > > private function onComplete(e:Event):void > > { > > var byteArr:ByteArray = new ByteArray (); > > byteArr.readByte(); //???? > > trace("byteArr "+byteArr); > > } > > > > the ByteArray readByte method accept 0 parameters, so what should I do? > > > > > > > > ------------------------------------ > > > > -- > > Flexcoders Mailing List > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > Alternative FAQ location: > > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > > Search Archives: > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links > > > > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links >

