🎞️ ACTIONSCRIPT WARD DIFFICULTY: Adept Creational

The Prototype

Cloning entities from the ByteArray crypt to rapidly populate the display list.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Necromancy // Object Cloning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ACTIONSCRIPT PATTERN //
package arcana.prototype {
    import flash.utils.ByteArray;

    public interface ICloneableSoul {
        function clone():ICloneableSoul;
    }

    public class CursedMemoryFragment implements ICloneableSoul {
        public var memoryName:String;
        public var traumaLevel:int;

        public function CursedMemoryFragment(name:String, trauma:int) {
            this.memoryName = name;
            this.traumaLevel = trauma;
        }

        public function clone():ICloneableSoul {
            // Using ByteArray deep cloning - a classic ActionScript necromancy technique
            var crypt:ByteArray = new ByteArray();
            crypt.writeObject(this);
            crypt.position = 0;
            var resurrected:CursedMemoryFragment = crypt.readObject() as CursedMemoryFragment;

            trace("Cloned memory fragment: " + resurrected.memoryName);
            return resurrected;
        }
    }
}
Runic Tags: #prototype #actionscript #flash #bytearray-cloning