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

Invert Y axis

New Here ,
Jan 30, 2013 Jan 30, 2013

Hi everyone!

For some reason, the Y axis in flash is inverted, meaning positive values point down.

Is there anyway to flip it, so positive values will point up, like in every normal coordinate system? it's very wierd working like that...

Thank you!

TOPICS
ActionScript
1.5K
Translate
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 ,
Jan 30, 2013 Jan 30, 2013

It's likely because by default everything registers from the top left corner of the stage... if the values were inverted as you ask, then you'd usually be dealing with negative y values and would probably be asking for that to be changed.

Translate
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 ,
Jan 30, 2013 Jan 30, 2013

Yeah I realise that that top left corner is the default zero point for the axis, I ask if there is anyway to change it, or is it a fixed feature that can't be changed?

Translate
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
Guru ,
Jan 30, 2013 Jan 30, 2013

You could program a workaround for your needs:

say you have a MovieClip with As-Linkage "MC" in your Library;

write a class MC.as :

package

{

    import flash.display.MovieClip;

    import flash.events.Event;

    public class MC extends MovieClip

    {

        private var _numValue:Number;

        private var _stageHeight:Number;

        public function MC(_stH:Number)

        {

            // constructor code

            _stageHeight = _stH;

        }

        public function set y2(_yy:Number):void

        {

            this._numValue = _stageHeight - _yy;

            this.y = this._numValue;

        }

        public function get y2():Number

        {

            this._numValue = _stageHeight - this.y;

            return this._numValue;

        }

    }

}

Then in your Flash File write sth like:

import flash.display.MovieClip;

import flash.events.Event;

var _mc:MC = new MC(stage.stageHeight);

_mc.y2 = 0;

addChild(_mc);

addEventListener(Event.ENTER_FRAME, moveUp);

function moveUp(e:Event):void{

   //this moves the MovieClip upward from the bottom left corner to the top left corner

    _mc.y2 +=1;

}

-> you will notice your MovieClip has now a property y2, that behaves just like an inverted y-property

It will also work with a TweenFramework like TweenMax:

//this moves the MovieClip upward from the bottom left corner to the top left corner

TweenMax.fromTo(_mc,3,{y2:0},{y2:400});

Translate
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 ,
Jan 30, 2013 Jan 30, 2013

scaleY=-1;

y=stage.stageHeight;

Will work for code if everything you're doing is code based, but you will run into all other kinds of problems. And any artwork that you make on the timeline will need to be made upside down.

For the most part if you are going to work in Flash you just need to get used to it.

Translate
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 ,
Jan 30, 2013 Jan 30, 2013
LATEST

Thanks everyone!

Though it indeed works, I see that its more complicated to change Flash that to get used to it...so weird coord sys here I come

Translate
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