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

Click rotate, click go back.

New Here ,
Apr 21, 2014 Apr 21, 2014

Copy link to clipboard

Copied

I'm a beginner with AS3, I'm trying to create a program that when I click on a coloured ball it rotates 90° and when clicked again it goes back to it's starting position ie. -90°.

The code that I have here works already. I was just wondering does anyone know what code I would put in to get it to return to the starting position.

import flash.events.MouseEvent;

myColouredBall.addEventListener(MouseEvent.MOUSE_DOWN, doClick);

function doClick (e:MouseEvent):void

{

myColouredBall.rotation = 90;

}

Hope someone can help! Thanks.

TOPICS
ActionScript

Views

299

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

correct answers 1 Correct answer

Guide , Apr 21, 2014 Apr 21, 2014

function doClick(e:MouseEvent):void {

     if (myColouredBall.rotation > 0) {

          myColouredBall.rotation = 0;

     } else {

          myColouredBall.rotation = 90;

     }

}    

Votes

Translate

Translate
Guide ,
Apr 21, 2014 Apr 21, 2014

Copy link to clipboard

Copied

function doClick(e:MouseEvent):void {

     if (myColouredBall.rotation > 0) {

          myColouredBall.rotation = 0;

     } else {

          myColouredBall.rotation = 90;

     }

}    

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
New Here ,
Apr 21, 2014 Apr 21, 2014

Copy link to clipboard

Copied

Thank you so much! Works like a charm

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
Guide ,
Apr 21, 2014 Apr 21, 2014

Copy link to clipboard

Copied

LATEST

You're welcome

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
LEGEND ,
Apr 21, 2014 Apr 21, 2014

Copy link to clipboard

Copied

import flash.events.MouseEvent;

var hasMoved:Boolean = false;

myColouredBall.addEventListener(MouseEvent.MOUSE_DOWN, doClick);

function doClick (e:MouseEvent):void {

     if(!hasMoved) {

           myColouredBall.rotation = 90;

     } else {

          myColouredBall.rotation = 0;

     }

     hasMoved = !hasMoved;

}

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