• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Moving object

Community Beginner ,
Jul 31, 2022 Jul 31, 2022

Copy link to clipboard

Copied

I have two objects. I want to move object1 to the right, if object1 is clicked. Then, I want to move object2 to the right, if object2 is clicked, with the condition: object2 cannot move before object1 moved.

TOPICS
ActionScript , Download and install

Views

128

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 31, 2022 Jul 31, 2022

Copy link to clipboard

Copied

How to write actionscript for that?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

I don't know if this code will help but you can try this tutorial. https://www.youtube.com/watch?v=yVB85hKohmY

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

Ok, thank you, i will try that

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

Hi.

 

A tween approach could be like this:

import flash.events.MouseEvent;
import fl.motion.easing.Cubic;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;

function enableFirstInstance():void
{
	instance1.addEventListener(MouseEvent.CLICK, moveFirstInstance);
}

function enableSecondInstance(e:TweenEvent):void
{
	instance2.addEventListener(MouseEvent.CLICK, moveSecondInstance);
}

function moveFirstInstance(e:MouseEvent):void
{
	var tween:Tween = new Tween(e.currentTarget, "x", Cubic.easeInOut, e.currentTarget.x, e.currentTarget.x + 100, 1, true);
	tween.addEventListener(TweenEvent.MOTION_FINISH, enableSecondInstance);
}

function moveSecondInstance(e:MouseEvent):void
{
	var tween:Tween = new Tween(e.currentTarget, "x", Cubic.easeInOut, e.currentTarget.x, e.currentTarget.x + 100, 1, true);
}

enableFirstInstance();

 

I hope it helps.

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

thank you, it works.
And morequestion, what kind of script should I write if I just wanna move
the object up to a certain point on the x?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

You can use Math.min in the 5th argument (destination value) when a new Tween is created. Like this:

// in this way the instance will move 100 pixels to the right from the current position
// but it will never go beyond 500 pixels in the parent's coordinate system
var tween:Tween = new Tween(e.currentTarget, "x", Cubic.easeInOut, e.currentTarget.x, Math.min(e.currentTarget.x + 100, 500), 1, true);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

LATEST
i will make abacus like this, but move horizontally. I'm confused with
actionscript. Can u help me?
VID20220804104619.mp4
<>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines