Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9205709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:00:54+00:00 2026-06-18T00:00:54+00:00

I have flex mxml custom component(Graphic).According to requirement a need to copy them as

  • 0

I have flex mxml custom component(Graphic).According to requirement a need to copy them as copy or cut operation.but problem in the registerClassAlias() method,how it will work for custom graphic or Group(or UIComponents) components.

var className:String = getQualifiedClassName(zorder.getItemAt(0));
            _saveIn.clear();

            registerClassAlias(className, zorder.getItemAt(0) as Class);
            _saveIn   =     SharedObject.getLocal("save");
            _saveIn.data.value1 = new ByteArray();
            _saveIn.data.value1.writeObject(zorder.getItemAt(0));
            _saveIn.data.value1.position = 0;
            _saveIn.flush();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:00:55+00:00Added an answer on June 18, 2026 at 12:00 am

    It’s not possible to make a full copy of any display object via ByteArray with registerClassAlias->writeObject->readObject approach. It works only with simple objects, for example data objects (like TextFormat, value objects and so). In any case you have to test the copy method for each type of your object to be sure it works properly.

    Example of coping Shape, the simplest display object:

    package
    {
    import avmplus.getQualifiedClassName;
    
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.Shape;
    import flash.net.registerClassAlias;
    import flash.utils.ByteArray;
    import flash.utils.getDefinitionByName;
    
    
    public class astest extends MovieClip
    {
        public function astest()
        {
            init();
        }
    
        private function init():void
        {
            var sh:Shape = new Shape();
    
            sh.graphics.beginFill(0xFF0000);
            sh.graphics.drawEllipse(100, 100, 100, 70);
            sh.graphics.endFill();
    
            addChild(sh);
    
            registerObject(sh);
    
            var ba:ByteArray = new ByteArray();
            ba.writeObject(sh);
            ba.position = 0;
            var obj:Object = ba.readObject();
            var shCopy:DisplayObject = obj as DisplayObject;
    
            if(shCopy)
            {
                shCopy.x = shCopy.y = 100;
                addChild(shCopy);
            }
    
        }
    
        private function registerObject(obj:Object):void
        {
            try
            {
                var qname:String = getQualifiedClassName(obj);
                var cname:String = qname.split("::").join(".");
                var classs:Class = getDefinitionByName(cname) as Class;
                registerClassAlias(qname, classs);
            }catch(error:Error)
            {
                trace(error.message);
            }
        }
    }
    }
    

    Output:

       TypeError: Error #1034: Type Coercion failed: cannot convert Object@eae09b9 to flash.geom.Transform.
    

    So, you can try to register the flash.geom.Transform before coping:

    registerObject(sh.transform);
    

    but this lead to another error:

    ArgumentError: Error #1063: Argument count mismatch on flash.geom::Transform(). Expected 1, got 0
    

    Actually, DisplayObject coping is the old topic and you can google for lots of posts about this by errors I mentioned above (especially the last one), but the answer is: You can’t copy display objects in via ByteArray, you need to write custom methods for creating a copy of given TextField, Sprite or VBox and copy all the properties manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have the following custom component: <s:Group xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark xmlns:mx=library://ns.adobe.com/flex/mx> <fx:Script> <![CDATA[ [Bindable]
So I have a module in flex in which I add a custom component.
In my flex app I have various custom components done with mxml or actionscript.
I have a custom component called shopView which is an MXML skinnable component. I
I have a simple doubt. I have made a custom ActionScript mxml component, which
I have a custom component, GlassSkin.mxml : <?xml version=1.0 encoding=utf-8?> <s:Group xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark xmlns:mx=library://ns.adobe.com/flex/mx
I have a custom Flex 4.5 component (to be used in a List) -
I have a view like this in my Flex mobile Application: <s:View xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark
Please enlighten this flex noob. I have a remoteobject within my main.mxml. I can
I have Flex Builder Professional Ver 3 (Built with Eclipse) version. I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.