• Home
  • About
  • Contact Us
  • Gallery
  • Video
  • Archives
  • Site Map
Grab the RSS feed

FlashBannerOnline

FlashBannerOnline
  • Home
  • FlashBannerOnline
  • Free Downloads
  • General
  • Tutorials
    • Adobe AIR
    • CSS
    • Fireworks
    • Flash
      • ActionScript
    • FLEX
    • Javascript
      • JQuery
      • MooTools
    • PHP

Deep Object Copies with ByteArray in AS3

  • ActionScript, Flash, Tutorials

    Posted on October 21st, 2009

    Written by Behrouz Pooladrag

    Related Posts

    • Advanced Flash AS3 Honeycomb Preloader
    • Flash Optimization – Activate & Deactivate Events
    • Flash Optimization – Freeing Memory

    Tags

    actionscript, actionscript 3 deep copy using bytearray, actionscript 3 создание object pool, actionscript 3.0 bytearray copy on write, actionscript bytearray duplicate, AS3, as3 bytearray, as3 bytearray clone, as3 bytearray copy, as3 clone array, as3 clone object, as3 clone object via bytearray, as3 copy array, as3 deep clone, as3 deep copy, as3 deep copy array, as3 deep copy object, as3 deepcopy bytearray speed, as3 duplicate bytearray, as3 write object to bytearray, as3 writeobject, ByteArray, bytearray as3 create copy, bytearray clone, bytearray copy flash, bytearray copy object as3, bytearray duplicate, bytearray flash, bytearray in as3, bytearray to object to bytearray as3, clone bytearray as3, clone objects flash as3, clone sprite as3, Copies, copy array or object as3, copy object as3, copy object bytearray actionscript, copy vector as3, copying using a bytearray in flash, Deep, duplicate using bytearray as3, flash as3, flash object to byte array, how to copy an array in as3, Object
    Deep Object Copies with ByteArray in AS3

    Using the new ByteArray (flash.utils.ByteArray) class in ActionScript 3, you can now easily create deep object copies. By deep, I mean being able to create copies not of just a single object and all its references, but also all the objects it references. This means if you use this method to copy an array which references an object, that object will also be copied as part of the copy procedure. Such a copy (clone) method would look like the following:

    function clone(source:Object):* {
    var copier:ByteArray = new ByteArray();
    copier.writeObject(source);
    copier.position = 0;
    return(copier.readObject());
    }

    Note: you may need to import flash.utils.ByteArray;

    To use this function simply say:

    newObjectCopy = clone(originalObject);

    Though this will make a deep copy of your objects, be aware that it does not retain class association. So, if you try to copy a MyClass instance, the copy will no longer be recognized as being of MyClass. This method is best used with generic objects.

    This entry was posted on Wednesday, October 21st, 2009 at 7:10 am and is filed under ActionScript, Flash, Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

    You might also like

    Tricks and Experiments , AS3 Tips As you read each of the following descriptions, consider opening Flash, pasting the code into timeline script and...
    Using Caurina Tweener Class AS3 I enjoy to use in my flash projects the caurina tweener class, because it’s simple, elegant and flexible. You...
    Using other types within ActionScript packages I was doing something, I forget what it was now, but it got me curious about functions defined in some of the...
    New templates Oval light added to flash banner online New template Oval Light Flash online banner added, you can now easily mold to your banner Select. An...
  • 0 Comments

    Take a look at some of the responses we've had to this article.

  • Post a Comment

    Let us know what you thought.

  • Name:

    Email (required):

    Website:

    Message:

  • Ad Ad

  • FlashBannerOnline.Com

  • Subscribe

    Enter your email address:

    | More

  • Blogroll
    • Random Flash Banner!
  • Tag Cloud

    • actionscript addChild addEventListener Adobe AIR Air Animation AS2 AS3 as3 preloader Banner beginFill BitmapData blog.flashbanneronline.com Class CSS Date Class draw Flash flash.net.URLLoader flash banner free flash banner generator flash banner happy new year flashbanneronline FlashBannerOnline.com flash banner online free flash player function game getChildIndex Javascript lightbox Loading Mysql new year flash banner Object Optimization package PHP Sprite tot Tweener URLLoader URLRequest web XML
  • Recent Comment
    • Behrouz Pooladrag on Flash Optimization – Freezing And Unfreezing Objects
    • Valerie on Flash Optimization – Freezing And Unfreezing Objects
    • FlashLord on RSS Reader for FlashBannerOnline Blog!
    • Behrouz Pooladrag on Using ActionScript 3.0 with PHP Loading External Variables
    • LUN on Using ActionScript 3.0 with PHP Loading External Variables
  • RSS FlashBannerOnline
    • Happy New Year 2012 & Gift!
    • New Templates Oval Light Added to Flash Banner Online
    • FlashBannerOnline started in Arabic language
    • Happy New Year 2011
    • New Templates Christmas 2011 Added at Christmas!
    • New Templates angel animate Added to Flash Banner Online
    • Added Tow New Preloader (Pro Preloader , Rotate Preloader)
    • Happy New Year , by new Theme (Christmas 2010)
  • Add to Technorati Favorites

    Subscribe
  • Google
    Custom Search

Copyright © 2009 FlashBannerOnline - Powered by Wordpress.

FBO by