By default, private properties are not written when an object is serialized : ByteArray « Development « Flash / Flex / ActionScript

Flash / Flex / ActionScript
1. Animation
2. Array
3. Class
4. Data Type
5. Development
6. Function
7. Graphics
8. Language
9. Network
10. Regular Expressions
11. Statement
12. String
13. TextField
14. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Flash / Flex / ActionScript » Development » ByteArray 
By default, private properties are not written when an object is serialized
 
package {
    import flash.display.Sprite;
    import flash.net.*;
    import flash.utils.ByteArray;

    public class CustomTypeExample extends Sprite {
        public function CustomTypeExample() {
            registerClassAlias("ExampleType", ExampleType);
            var example1:ExampleType = new ExampleType(12);
            var byteArray:ByteArray = new ByteArray();
            byteArray.writeObject(example1);
            byteArray.position = 0;
            var example2:ExampleType = byteArray.readObject() as ExampleType;
            trace(example2.getA());
            trace(example2.getB());
        }
    }
}


    class ExampleType implements flash.utils.IExternalizable {

        private var _a:Number;
        private var _b:Number;

        public function ExampleType(a:Number = -1, b:Number = -1) {
            if(a != -1) {
                _a = a;
            }
            if(b != -1) {
                _b = b;
            }
        }

        public function getA():Number {
            return _a;
        }

        public function getB():Number {
            return _b;
        }

        public function writeExternal(output:flash.utils.IDataOutput):void {
            output.writeFloat(_a);
            output.writeFloat(_b);
        }

        public function readExternal(input:flash.utils.IDataInput):void {
            _a = input.readFloat();
            _b = input.readFloat();
        }
    }

        
Related examples in the same category
1. Creating a Byte Array
2. Write array to ByteArray
3. Embedding Files as Binary Data
4. Embedding XML at compile time
5. Common Uses of Byte Arrays
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.