Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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});
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now