<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>objectencoding &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/objectencoding/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Mon, 21 Jun 2010 10:27:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>objectencoding &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>AMFPHP issue referencing ByteArray</title>
		<link>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/</link>
					<comments>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 11 Jul 2008 17:08:49 +0000</pubDate>
				<category><![CDATA[amfphp]]></category>
		<category><![CDATA[amf3]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[netconnection]]></category>
		<category><![CDATA[objectencoding]]></category>
		<category><![CDATA[patch]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=258</guid>

					<description><![CDATA[Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field. But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error: The php file which was &#8230; <a href="https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/" class="more-link">Continue reading <span class="screen-reader-text">AMFPHP issue referencing ByteArray</span></a>]]></description>
										<content:encoded><![CDATA[<p>Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field.</p>
<p>But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error:</p>
<p><a href="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog.png"><img decoding="async" class="alignnone size-medium wp-image-1117" title="error_dialog" src="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog-300x126.png" alt="" width="300" height="126" srcset="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog-300x126.png 300w, https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog.png 658w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The php file which was generating this error was:<br />
<code lang="php"><br />
class Service<br />
{<br />
public function getArray( )<br />
{<br />
$GLOBALS['amfphp']['encoding'] = 'amf3';<br />
$a = new ByteArray("\x00\x10this is a string");<br />
$b = new ByteArray("\x00\x16this is another string");<br />
$c = $a;<br />
return array( $a, $b, $c );<br />
}<br />
}<br />
</code><br />
While the Actionscript test class was:<br />
<code><br />
package<br />
{<br />
    import flash.display.Sprite;<br />
    import flash.net.NetConnection;<br />
    import flash.net.ObjectEncoding;<br />
    import flash.net.Responder;<br />
    import flash.utils.ByteArray;</p>
<p>    public class test extends Sprite<br />
    {<br />
        private var nc: NetConnection;<br />
        private var rsp: Responder;</p>
<p>        public function test()<br />
        {<br />
            rsp = new Responder( onResult, null );<br />
            nc = new NetConnection();<br />
            nc.objectEncoding = ObjectEncoding.AMF3;<br />
            nc.connect( "http://localhost/amfphp/trunk/gateway.php" );<br />
            nc.call( "test.bytearray.Service.getArray", rsp );<br />
        }</p>
<p>        private function onResult( e: * ): void<br />
        {<br />
            if ( e is Array )<br />
            {<br />
                for each ( var b: ByteArray in( e as Array ) )<br />
                {<br />
                    trace( 'reading bytearray...' );<br />
                    b.position = 0;<br />
                    trace( b.readUTF() );<br />
                }<br />
            }<br />
        }<br />
    }<br />
}</p>
<p></code><br />
After some investigation I found that the error was into the AMFSerializer.php file in the writeAmf3ByteArray method which doesn&#8217;t reference correctly the bytearray objects.</p>
<p>Thus I made a little modification and after that I succeeded to retrieve correctly the bytearray list ( with the 3rd element as reference of the first one ).</p>
<p>Here you can <a title="bytearray.patch" href="https://blog.sephiroth.it/wp-content/uploads/2008/07/bytearray_patch.zip">download the patch file</a>, if you want to test the modification ( at your own risk 🙂 ). The patch has been created using the last svn version of amfphp and you can apply the patch with the following command:<br />
<code>patch -p0 -i bytearray.patch</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
