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 668797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:04:50+00:00 2026-05-14T00:04:50+00:00

I need to animate a lable movement between 2 canvases… The mxml example of

  • 0

I need to animate a lable movement between 2 canvases…

The mxml example of the code is:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="main()" frameRate="1">

<mx:Script>
    <![CDATA[
        import mx.controls.Label;
        public function main():void
        {

            onEnd();
        }

        private function onEnd():void
        {
            (canv1.getChildAt(0) as Label).move(canv2.x, canv2.y);
        }

    ]]>
</mx:Script>
<mx:Panel x="208" y="0" width="190" height="200" layout="absolute" title="Panel2" id="d">
</mx:Panel>
<mx:Panel width="200" height="200" id="c"  title="Panel 1">
    <mx:Canvas width="135" height="56" id="canv1" label="c1" themeColor="#79B4DA" backgroundColor="#65D565">
        <mx:Label text="Move me after event" y="10"/>
    </mx:Canvas>
    <mx:Canvas width="135" height="79" id="canv2" label="C2" backgroundColor="#E4CACA">
    </mx:Canvas>
</mx:Panel>
</mx:Application>

Currently the problem is that the label actually do not leave borders of the first canvas (I see scrollbars instead of it).
I think this is related to globalToLocal conversion problems, but do not understand how to use it.

Also another question is how to animate the movement corretly, because move function performs movement without any visible action.
(The movement happens seamlessly).

  • 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-05-14T00:04:50+00:00Added an answer on May 14, 2026 at 12:04 am

    I don’t think the move function will solve this for you since it will only move the label within it’s parent, just as Robusto has commented above.

    The way to go about this would perhaps be to see to it that you first detach the label from its parent. Then move it, and add it as a child to the other canvas. Manipulating x,y coordinates will not implicitly change the parent for you. That will always have to be done explicitly, which is good…

    So for example, to actually switch parent you would need to do something like this (pseudo code):

    /**
     * This function only switches the parent.
     */
    private function moveLabel(label:Label) {
        label.parent.removeChild(label);
        canv2.addChild(label);
    }
    

    If you want this action to be animated you would first have to detach the label from the canvas and see to it that it is added to the parent of the canvas, in your case, the panel with id “c”. Then you can tween it into position and add it to the correct canvas.

    TweenLite is a great library for tweening. http://www.greensock.com/tweenlite/

    But I guess the main lesson here is that manipulating coordinates will never result in a new parent for the component you are moving.

    Update: Here’s a complete example of how you could solve this, take into account that the code is not very nice looking, but it contains a simple example of animation.

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="main()">
    
    <mx:Script>
    <![CDATA[
        import mx.controls.Label;
        import flash.geom.Point;
        import gs.TweenLite;
        import gs.easing.Expo;
    
        public function main():void
        {
    
            onEnd();
        }
    
        private function onEnd():void
        {
            var label:Label = canv1.getChildAt(0) as Label;
            var originX:int = label.localToGlobal(new Point(label.x, label.y)).x;
            var originY:int = label.localToGlobal(new Point(label.x, label.y)).y;
            label.parent.removeChild(label);
            stage.addChild(label);
            label.x = originX;
            label.y = originY;
            TweenLite.to(label, 1.5, {y: "80", ease:Expo.easeOut, onComplete:onFinishTween, onCompleteParams:[label]});
    
        }
    
        private function onFinishTween(label:Label):void {
            stage.removeChild(label);
            label.x = canv2.globalToLocal(new Point(label.x, label.y)).x;
            label.y = canv2.globalToLocal(new Point(label.x, label.y)).y;
            canv2.addChild(label);
    
        }
    
    ]]>
    </mx:Script>
    <mx:Canvas width="135" height="56" id="canv1" label="c1" themeColor="#79B4DA" backgroundColor="#65D565" y="-1" x="9">
        <mx:Label text="Move me after event" y="10"/>
    </mx:Canvas>
    <mx:Canvas width="135" height="79" id="canv2" label="C2" backgroundColor="#E4CACA" y="90" x="8">
    </mx:Canvas>
    
    </mx:Application>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 366k
  • Answers 366k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SELECT a.IDArticle FROM ( SELECT IDCar , MAX(createddate) as max_date… May 14, 2026 at 4:40 pm
  • Editorial Team
    Editorial Team added an answer ejabberd doesn't handle audio/video natively. Audio and video is handled… May 14, 2026 at 4:40 pm
  • Editorial Team
    Editorial Team added an answer I’d keep things simple. ALuint is some kind of int,… May 14, 2026 at 4:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.