Explanation of function Math.atan2

Hello guys
It is a piece of code AS3 things do move
I tried to understand what atan2 actually does?

Please explain

If all goes well, I'll get help here :)

Thanks in advance

It's pretty accurate.

If you remember the trigonometry, the tangent of an angle (theta) formed by the x-axis, and a line from (0,0) to (x, y) is y / x. that is to say, tan (theta) = y / x.

and the arctan is just the opposite: given the number y / x, what's the angle? That is to say, y = theta.

MOS ' (dx, dy) code can be considered as a point on a Cartesian coordinate system. If you draw a line connecting the point (0,0) to (dx, dy) that line crosses the x axis and an angle with the x-axis. This angle is the inverse tangent (arctan) dy divided by dx (dy/dx).

Flash, in addition to having a function of Math.atan (y/x) also has a Math.atan2(y,x) atan2 function that accepts two parameters, so no division is necessary.

Tags: Adobe Animate

Similar Questions

  • Function Math cloud connector

    Hi all

    Can I use text fields and large text fields in the field of digital mathematics and function in string manipulation (find and replace) cloud connector?

    Thank you

    Rama

    I did a few tests, work of manipulation of String on Test, great text and numeric fields, but Math function only works on numeric fields.

    If anyone can confirm this?

  • function math Evaluating in RPN premium

    I saw above similar post and his response, but I still cannot find a way to use the beta function in the RPN.  When I put "CASE. "Beta (4.12)" on the stack, it just treats it as a text string and does not evaluate it.  Similarly for the "Beta (4.12).

    Any thoughts?

    BAF

    In RPN, type:

    4 entry

    12 entry

    Entered Beta (2)--> 1.83E - 4, the answer for Beta (4.12).

    In RPN, the arguments must be on the stack before executing the function.  Some functions need allows you to specify how many arguments to use. in this case, we want Beta to use two arguments, where Beta (2).

    Hope that helps!

  • Math.power Java script in Captivate 7 function

    I am trying to perform a complex calculation in a 7 Captivate tip action. I can get up now by using the user input and a series of expressions but stop trying to raise a number to a power, so I will try to use the function math.power Java [Math.pow(x,y)]; The problem is that the base number (x) is a variable of captivate (PR) calculated by the previous expression, the exponent (y) is a literal value (0,2857). The result will then return to the advanced Captivate in action for a final calculation, what I can do in a regular expression before being posted. Advice or guidance would be much appreciated. Please keep in mind, I'm an absolute novice with javascript. Thanks in advance.

    When you try to get or set of Captivate variables in combination with advanced Actions and JavaScript, you can run into problems of synchronization.  It is better to do everything in one or the other... or at least start in advanced actions and complete the action advanced with a final stage "execute JavaScript.  So I'll take the last expression in your advanced actrion and which combine in one final step of "Execute JavaScript":

    /* Get a reference to the Captivate DOM element */
    var objCp = document.Captivate;
    
    /* Get the PR Captivate Variable as a Number*/
    var pr = Number(objCp.cpEIGetValue('m_VarHandle.PR'));
    
    /* Do exponent calc */
    var pk = Math.pow(pr, 0.2857);
    
    /* Get the Init_Temp_K Captivate Variable */
    var initTempK = Number(objCp.cpEIGetValue('m_VarHandle.Init_Temp_K'));
    
    /* Calculate the final temp */
    var finalTemp = pk * initTempK;
    
    /* Set the Final_Temp_K Captivate Variable so the answer is visible inside of Cp */
    objCp.cpEISetValue('m_VarHandle.Final_Temp_K', finalTemp);
    

    I commented JavaScript code so hopefully he reads logically.

  • Normal to a line drawn during execution (incorrect math)?

    Hello.

    I have an equation that apparently restores normal (line segments) up to a line drawn with ActionScript and the mouse.

    If I posted less mouseX to a larger position mouseX it seems to work correctly.

    line1Arr [i] .rotation = 45 * Math.atan2 (mouseYArr [i] - mouseYArr [i - 1], mouseXArr [i] - mouseXArr [i-1]);

    line1Arr [i] is the instance of the normal line segment that is attached to the line and mouseXArr [i] and mouseXArr [i-1] is the most recent point and seizure.

    The problem is that after doing a search on the web, I think that my calculations is not correct calculate normal.  I found a thread somewhere that mentions use derived from x and y for calculating normals.  Another soldier in the assigned thread, we can also use sine and cosine to calculate this.

    It's the problematic equation I tried by going in the opposite direction mouseX

    line1Arr [i] =(-45) .rotation * Math.atan2 (mouseXArr [i-1]-[i - 0] mouseXArr, mouseYArr [i - 1] - mouseYArr [i-0]);

    Any help with this math problem is greatly appreciated.

    because you are using a series of lines, there is no need to use trig: Cartesian geometry of base is sufficient.

    for example, if you have an array of [x, y] points used in your drawing, calling normalsF will add perpendicular in the middle of these segments.  (for an example: http://www.kglad.com/Files/forums/normals.fla)

    function normalsF (): void {}

    for (var i = 0; i)<>

    normalF(curveA[i],curveA[i+1]);

    }

    }

    function normalF(p1:Array,p2:Array):void {}

    m =-(p1[0]-p2[0]) /(p1[1]-p2[1]);

    b = (p1 [1] + p2 [1]) / 2 - m * (p1 [0] + p2 [0]) / 2;

    drawnormalF (m, b, [(p1[0]+p2[0])/2, (p1 [1] + p2 [1]) / 2]);

    }

    function drawnormalF(m:Number,b:Number,pt:Array):void {}

    Len = Math.sqrt (400 /(4+4*m*m));

    {with (curveParent.Graphics)}

    moveTo (pt [0] - len, m *(pt[0]-len) + b);

    lineTo (pt [0] + m *(pt[0]+len) + b, len);

    }

    }

  • Math.COS, Math.sin = Math.HELP

    Hi all

    I was hoping to create a JS script to move objects from the common center based on their current location. I thought to use an element of single selected path as the center based on its position x / y and width/height. Using this reference point that the script would then move away all other elements of the path of this central point based on a desired amount and with uniform increases, account required to their current location of this Center. I was thinking about cos and sin would be my friend in this case, but they seem to have become my enemy instead. ;-)

    Does this sound feasible? What Miss me, hurt, misinterpretation? Here's an attempt at non-working, I can't fix things, maybe I was close and missed or maybe I am so far and its complex more than I thought. However at this point I'm confused through my various attempts which is only one of them.

    Thanks in advance for any help and health mental someone can provide.

    // Example failed code, nonworking concept
    var docID = app.activeDocument;
    var s0 = docID.selection[0];
    pID = docID.pathItems;
    var xn, yn;
    var stepNum = 20;
    for (var i = 0; i < pID.length; i++) {
        var p = pID[i];
        var dx = ((s0.position[0] + s0.width) / 2 - (p.position[0] + p.width) / 2);
        var dy = ((s0.position[1] + s0.height) / 2 - (p.position[1] + p.height) / 2);
        xn = Math.cos(Number(dx) * Math.PI / 180)+stepNum;
        yn = Math.sin(Number(dy) * Math.PI / 180)+stepNum;
        var moveMatrix = app.getTranslationMatrix(xn, yn);
        p.transform(moveMatrix);
        stepNum+=stepNum;
    }
    

    Hi W_J_T, here's a way to do what I think you want to do, I put comment the increment so everything will "explode" the same distance, do not know if it is you need.

    first of all, I suggest the calculation of the center of the object selected out of the loop, you only need to do the math once.

    In addition, (s0.position[0] + s0.width) / 2 has a problem, it will not give you the Center, check below

    // calculate Selection center position
    var cx = s0.position[0] + s0.width/2;
    var cy = s0.position[1] + s0.height/2;
    

    then we're going to loop through all the elements and calculate their Center

            // calculate pathItem's center position
            var px = p.position[0] + p.width/2;
            var py = p.position[1] + p.height/2;
    

    We will pass the calculation of the distance from the center of the selection in the center of each item, we don't need this method, other methods may use this information.

    now, your real question on Sin / Cos

    xn = Math.cos(Number(dx) * Math.PI / 180)+stepNum;

    Sin (angle) and cos (angle) expect angles in Radians, you not provide any angle in the formula above. We need calculate the angle between the selection and each path Center

            // get the angle formed between selection's center and current path's center
            var angle = get2pointAngle ([cx,cy], [px,py]);
    

    as soon as we have the angle we can apply to our variable 'Explosion', I guess is stepNum and get its x and is distance he needs to walk away selection

            // the distance to move is "stepNum" in the same direction as the angle found previously, get x and y vectors
            var dx = stepNum*Math.cos(angle);// distance x
            var dy = stepNum*Math.sin(angle);// distance y
    

    everything remains to be done is to move the paths, here is the whole thing

    // Explosion, AKA move all items away from selection
    // carlos canto
    // http://forums.adobe.com/thread/1382853?tstart=0
    
    var docID = app.activeDocument;
    var s0 = docID.selection[0];
    pID = docID.pathItems;
    
    var stepNum = 20; // this is the distance to "explode"
    
    // calculate Selection center position
    var cx = s0.position[0] + s0.width/2;
    var cy = s0.position[1] + s0.height/2;
    
    for (var i = 0; i < pID.length; i++) {
        var p = pID[i];
    
        // skip selected item
        if (!p.selected) {
            // calculate pathItem's center position
            var px = p.position[0] + p.width/2;
            var py = p.position[1] + p.height/2;
    
            // get the angle formed between selection's center and current path's center
            var angle = get2pointAngle ([cx,cy], [px,py]);
    
            // the distance to move is "stepNum" in the same direction as the angle found previously, get x and y vectors
            var dx = stepNum*Math.cos(angle);// distance x
            var dy = stepNum*Math.sin(angle);// distance y
    
            var moveMatrix = app.getTranslationMatrix(dx, dy);
            p.transform(moveMatrix);
            //stepNum+=stepNum;
        }
    }
    
    // return the angle from p1 to p2 in Radians. p1 is the origin, p2 rotates around p1
    function get2pointAngle(p1, p2) {
        var angl = Math.atan2(p2[1] - p1[1], p2[0] - p1[0]);
        if (angl<0) {   // atan2 returns angles from 0 to Pi, if angle is negative it means is over 180 deg or over Pi, add 360 deg or 2Pi, to get the absolute Positive angle from 0-360 deg
            angl = angl + 2*Math.PI;
        }
      return angl;
    }
    
  • Pointing to the mouse using Atan2

    When I try to use atan2 for the object with the mouse, you get still a little weird.

    package

    {

    import flash.display.MovieClip

    import flash.events.KeyboardEvent

    import flash.events.MouseEvent

    import flash.events.Event

    import flash.ui.Keyboard

    SerializableAttribute public class player extends MovieClip

    {

    var xdiff:Number; declares the variables

    var ydiff:Number;

    public void Player()

    {

    This.x = stage.stageWidth / 2; Put it in the Middle

    This.y = stage.stageHeight / 2;

    addEventListener (Event.ENTER_FRAME, EnterFrame);

    }

    function EnterFrame(event:Event):void

    {

    xdiff = mouseX - this.x; modifies the variables each enter_frame

    ydiff = mouseY - this.y;

    This.rotation = Math.atan2 (ydiff, xdiff) * (180 / Math.PI); the (180 / Math.PI) transforms the radians into degrees.

    }

    }

    }

    Here is the result - the faces of lighter arrow right in symbol, with the darkest arrow Editor to the left. If when facing to the right of the object = 0 degrees, probably the lightest arrow must always deal with the mouse?

    Thanks in advance.

    I use the x / y of the arrow_mc in my example and you are so when you use 'this.x"/"this.y ':

    It's yours:

    xdiff = mouseX - this.x; modifies the variables each enter_frame

    ydiff = mouseY - this.y;

    That's fine because you use this code "to the inside of your arrow", I'm not though. I get my parent mouseX/mouseY. I make it to the scene that is the parent of arrow_mc in my example. You get this from "mouseX', i.e. 'this.mouseX" or the location X of the mouse as opposed to the arrow, not the parent.

    I don't know how your display hierarchy, but it could be as simple a fix as applicant mouseX of the parent.

    for example:

    xdiff = parent. mouseX - this.x;

    ydiff = parent. mouseY - this.y;

    Yet I know not your display hierarchy, but I think you understand that the code is not the same between the two.

  • Flash Math and angles

    I don't know enough about math flash functions it's just that I don't know the formula of working on the angles in a triangle, if I have three lengths in a triangle with a right angle. I have the hypotenuse, the vertical and the base, I want to work on the angle between the base and the hypotenuse, I created a little tool that displays an arrow of dimension between two points and I need to turn it acurately to get the form in joinign point to point. My video clip of dimension is called lineBox, and its alignment is to the left most part of the line (so basically nothing has a negative x value so it can be placed in either a rotated adjustment and scale to the point y and x)

    Thanks in advance!

    for the angle in degrees try
    degrees = Math.atan2 (verticallength, trianglebaselength) * 180/Math.PI

    Search Math.atan2!

  • Using trigonometric (sine, cosine) functions in Acrobat Scripting

    Hello

    I inherited a form of a colleague and would like to make some changes in one of the fields of output using a formula that includes arc sine and cosine functions. All scripts that are attached to the form fields use FornCalc but I couldn't find the arc sine and cosine functions in FormCalc. The manual mentions that the scripts associated with the form fields can also be written in javascript and research online, I found that this javascript has a function math.cos() and Math.asin (). My problem is that I don't know anything about javascript programming (and very little about FormCalc and XML) and would appreciate much help on how to write a script JS using Math.cos and Math.asin. The script is associated with the form field and the values used in the trigonometric functions are declared global variables and form using modified elsewhere FormCalc scripts. I use adobe acrobat 9 pro Presentation.

    Thank you

    Documentation of the designer LIiveCycle omitted some mathematical objects present in the whole XFA FormCalc spécification.

    FormCalc undocumented scientific functions

  • Rotations and movements,

    Hey,.

    Thanks in advance for any answers or advice.

    I'm doing a game where the user must "jump" from planet to planet. A rough explanation of the gameplay would be that the user needs to 'move' around a planet, align itself on the next planet and jumping to it. Hold the up arrow key move the user 'far' of the planet and release would be:

    • Let them be pulled back down by gravity if they are in the range of the planet,
    • Send them darting off in outer space due to lack of everything.
    • Or in the future make connected by a gravity of planets, prompting so partly through the level.

    Currently, I make my character to move around the planet. I can then blow. While in the air, I can do a test to see whether or not they are close enough to a planet or not and act accordingly sending either the character forward at the same speed or decisions her land on the planet.

    Arrises them question once I landed. I'm able to jump again and 'results' continuous work perfect, but I'm unable to turn around the planet, according to the needs.

    addEventListener (Event.ENTER_FRAME, updateGame);

    stage.addEventListener (KeyboardEvent.KEY_UP, KeyUp);

    stage.addEventListener (KeyboardEvent.KEY_DOWN, KeyDown);

    var keys: Array = [];

    var currentPlayerState:String = "landed";

    var walkSpeed:uint = 2;

    var currentAngle:Number = 90;

    var currentRadius:uint = planet.width/2;

    var currentOrbitX:uint = planet.x;

    var currentOrbitY:uint = planet.y;

    var distanceX:Number;

    var distanceY: number;

    var distance: Number;

    var dx:Number;

    var dy:Number;

    var newX:Number;

    var newY:Number;

    function KeyDown(e:KeyboardEvent):void {}

    Keys [e.keycode] = true;

    }

    function KeyUp(e:KeyboardEvent):void {}

    Keys [e.keycode] = false;

    }

    function updateGame(evt:Event) {}

    checkKeyPresses();

    Movement();

    }

    function checkKeyPresses() {}

    {if (Keys [Keyboard.up])}

    If (currentPlayerState == "landed") {}

    currentPlayerState = "Skip";

    }

    }

    If (keys [Keyboard.UP] == false) {}

    If (distance > 100 + planet.width/2) {}

    currentPlayerState = "drifting."

    } else {}

    currentPlayerState = 'falling ';

    }

    }

    If (currentPlayerState == "landed") {}

    rotateCharacter();

    {if (Keys [Keyboard.Left])}

    trace ("works of left")

    currentAngle = walkSpeed;

    }

    If (keys [Keyboard.RIGHT] == true) {}

    trace ("works of right");

    currentAngle += walkSpeed;

    }

    }

    }

    function movement() {}

    Switch (currentPlayerState) {}

    case "jump":

    checkDistance();

    If (currentPlayerState == 'jump') {}

    Agree = distanceX / distance;

    y = distanceY / distance;

    DX = - agree;

    DY = - y;

    Player.x += dx;

    Player.y += dy;

    }

    break;

    case 'falling ':

    checkDistance();

    if(distance > currentRadius) {}

    Agree = distanceX / distance;

    y = distanceY / distance;

    DX = agree;

    DY = y;

    Player.x += dx;

    Player.y += dy;

    } else {}

    currentPlayerState = "landed";

    }

    break;

    'landed ': case

    break;

    case 'drifting ':

    Player.x += dx;

    Player.y += dy;

    break;

    }

    }

    function rotateCharacter() {}

    var rad:Number = currentAngle * (Math.PI / 180);

    Player.x = currentOrbitX + currentRadius * Math.cos (rad);

    Player.y = currentOrbitY + currentRadius * Math.sin (rad);

    Player.rotation =-(Math.atan2 (player.x-currentOrbitX,))

    Player.y - currentOrbitY) * 180 / Math.PI);

    }

    function checkDistance() {}

    distanceX = planet.x - player.x;

    distanceY = planet.y - player.y;

    distance = Math.sqrt (distanceX * distanceX + distanceY * distanceY);

    }

    In my real file the only funds I have are two movieclips. The two are already on the scene, one named 'planet', 150 x 150 and the orientation is in the Center. An other named 'player' which is around 20hx50w, orientation to the feet "power plants" of the movieclip.

    Any matter or information which I'll get back to you as soon as POSSIBLE.

    Thanks again.

    You are checking if the button upwards and always set your status to fall. Check if you have landed in order to not accidentally put it:

    If ((currentPlayerState == 'jump') & (keys [Keyboard.UP] == false))

    {

    If (distance > planet.width / 2 + 100)

    {

    currentPlayerState = "drifting."

    } else {}

    currentPlayerState = 'falling ';

    }

    }

    Without checking if you jump, when UP is more pressed this continually sets your status as 'drifting' or 'falling', even if you "fell" and finally reached the planet and set. It would crush him. By checking if I was currently jumping, then just set the State so when I land it does not work.

    Also one thing, you may want to consider is only under ENTER_FRAME keyDown and stopping the ENTER_FRAME, once you no longer need (e.g. landed).

    Small example, at the top of your code to delete:

    addEventListener (Event.ENTER_FRAME, updateGame);

    Then add it when you really need:

    function KeyDown(e:KeyboardEvent):void

    {

    Keys [e.keycode] = true;

    addEventListener (Event.ENTER_FRAME, updateGame);

    }

    Delete if landed:

    in the switch statement

    'landed ': case

    trace ("Landed, removing enterFrame");

    removeEventListener (Event.ENTER_FRAME, updateGame);

    It adds a very short deadline to keypress initial but you get the idea, it will save tons of unnecessary treatment.

  • How to use multitouch in Webworks app?

    Hello!

    After my first problems in the development of the app for BB in Webworks I still made my app. I have to use multitouch now, but I have no idea how. I did find samples with multitouch. I found only this: http://developer.blackberry.com/html5/apis/touchevent.html#targetTouches but I don't know how to use this function. Can you help me?

    PS. Sorry for my bad English

    And that's that

    The following example is an implementation of filling of touch

    I decided to leave the bind to the mouse in that it is probably useful to others

    It is a living example of an ePub with blow gettures reader and touch

    The code is a little complex, so I will answer any other than Gregs Qs

    Basically what this did that target an iFrame and control

    Anywhere you see a reference to my target frame - ignore it and replace with what you want to do

    The hardest things to understand for the novice, here are the angle and the time (both are included)

    Without much explain this sets @ high tell the manager what to do

    A call to bindtouch (target) does what it says but is native, you must pass the name of the div tag

    A binding triggers all important events

    Angles and timing are still developing

    Timing is crucial if you need one no doubt

    Angle is optional and depends on how the finger is moved, but requires a JS call very expensive Math.atan2 (point1, point2)

    Basically Angle you indicate where you moved your finger after the first touch so you can probably kill such things

    The County touch gets the correct contact and doing what it takes with it based on defines it

    Look - I told you it was very complicated

    Oh - bind it to the mouse allows you to transfer the call to a mouse event - I thought it might be useful for other readers

    The target an iFrmae is also very convenient as it is scrolling

    I leave you for that suit your needs

    function bindtouch (target) {}
    var TOUCH_TAP_DIST = 30;
    var TOUCH_TAP_TIME = 150;
    var TOUCH_DRAG_DIST = 50;
    var TOUCH_DRAG_TIME = 500;
    var TOUCH_DRAG_VELOCITY = 50;
    var TOUCH_SWIPE_DIST = 50;
    var TOUCH_SWIPE_TIME = 500;
    var TOUCH_SWIPE_VELOCITY = 75;

    var SWIPE_NONE = 0;
    var SWIPE_RIGHT = 1;
    var SWIPE_UP = 2;
    var SWIPE_LEFT = 4;
    var SWIPE_DOWN = 8;

    var _TOUCH_DRAG_VELOCITY = TOUCH_DRAG_VELOCITY * TOUCH_DRAG_VELOCITY;
        
    var touch = [];

    var el = target;

    function squangle (p1, p2) {}
    ((p2.y-p1.y) return math.atan2, (p2.x - p1.x));
    }

    el.addEventListener ('touchend', Function {}
    e.preventDefault ();
    var TB = e.changedTouches;
    for (var i = 0; i)
    CTI var is ct [i] .identificateur;.
    CTO var = ct [i];
    {if (CTO. ClientX)}
    Touch [sic] = {sx: cto.clientX,}
    SY: cto.clientY,
    TX: cto.clientX,
    Ty: cto.clientY,
    BX: cto.clientX,
    by: cto.clientY,
    PV: 0,
    {TM: e.timeStamp};
    var id = "#tch" + ct;
                    
    evt var = document.createEvent ("MouseEvents");
    evt.initMouseEvent ("mousedown", true, true, window,
    0, cto.screenX, cto.screenY,.
    cto.clientX, cto.clientY, false, false, false, false, 0, null);
    e.srcElement.dispatchEvent (evt);
    }
    }
    });

    el.addEventListener ('touchmove', Function {}
    e.preventDefault ();
    var TB = e.changedTouches;
    for (var i = 0; i)
    CTO var = ct [i];
    TCO var = touch [cto.identifier];
    var ms = e.timeStamp - tco.tm;
    {if (CTO. ClientX)}
    TCO. TX = cto.clientX;
    TCO. Ty = cto.clientY;
    TCO. PV = Math.sqrt (((tco.sx-tco.tx) * (tco.sx - tco.tx)))
    + ((tco.sy-tco.ty) * (tco.sy - tco.ty)));
    if(e.touches.Length == 2) {}
    dreadful var = e.touches.length;
    }
    if(e.touches.Length == 1) {}
    var dx = Math.abs(tco.bx-tco.sx);
    var dy = Math.abs(tco.by-tco.sy);

    If (tco.pv< _touch_drag_velocity)="">
    If ((smode == SCALE_ZOOM) & (fsize > 1.00)) {}
    $(frames['appframe'].document).scrollLeft ($(frames['appframe'].document).scrollLeft () + (tco.sx - tco.tx));
    //                            }
    EB var = $(frames['appframe'].document);
    St var = eb.scrollTop ();
    $(frames['appframe'].document).scrollTop (st + (tco.sy - tco.ty));
    .SX Touch [i] = e.touches [i] .clientX;
    .Sy Touch [i] = e.touches [i] .clientY;
    }
    }
                    
    TCO. SX = cto.clientX;
    TCO. Sy = cto.clientY;
    }
    }
    });
                
    el.addEventListener ('touchstart', Function {}
    e.preventDefault ();
    var TB = e.changedTouches;
    for (var i = 0; i)
    CTO var = ct [i];
    TCO var = touch [cto.identifier];
    var ms = e.timeStamp - tco.tm;
    var dx = Math.abs(tco.bx-tco.sx);
    var dy = Math.abs(tco.by-tco.sy);
    evt var = document.createEvent ("MouseEvents");

    If ((dx< touch_tap_dist)="" &&="" (dy="">< touch_tap_dist)="" &&="" (ms=""><= touch_tap_time))="">
    evt.initMouseEvent ("click", true, true, window,
    0, tco.sx, tco.sy, tco.sx, tco.sy, false, false, false, false, 0, null);
    e.srcElement.dispatchEvent (evt);
    }
    ElseIf (((dx > TOUCH_SWIPE_DIST) |)) (dy > TOUCH_SWIPE_DIST)) & (Mrs.<= touch_swipe_time))="">
    if(DX > TOUCH_SWIPE_DIST) {}
    If (TCO. BX > TCO. SX) {}
    swipex = SWIPE_RIGHT;
    }
    else {}
    swipex = SWIPE_LEFT;
    }
    }
    else {}
    swipex = SWIPE_NONE;
    }
                        
    if(dy > TOUCH_SWIPE_DIST) {}
    if(TCO.by > TCO.) SY) {}
    swipey = SWIPE_UP;
    }
    else {}
    swipey = SWIPE_DOWN;
    }
    }
    else {}
    swipey = SWIPE_NONE;
    }
                        
    If ((swipey == SWIPE_NONE) & (swipex == SWIPE_RIGHT))
    {
    switchPage (1);
    }
    If ((swipey == SWIPE_NONE) & (swipex == SWIPE_LEFT))
    {
    switchPage(-1);
    }

    evt.initMouseEvent ("mouseup", true, true, window,
    0, tco.sx, tco.sy, tco.sx, tco.sy, false, false, false, false, 0, null);
    e.srcElement.dispatchEvent (evt);
    }
    else {}
    evt.initMouseEvent ("mouseup", true, true, window,
    0, tco.sx, tco.sy, tco.sx, tco.sy, false, false, false, false, 0, null);
    }

    }
    });
    }

  • Communicate with SOUL

    Using the HTML/JS, not the SDK panels.

    Is there an access API to communicate with Media Encoder by AFX? Events, methods, something?

    I've looked through the app connection in ESTK and see nothing.

    I want to communicate reliably, and not just say "send to Media Encoder".

    I would like to connect on a job ID specific SOUL that I could have, get the status and perform an action when this task is completed.


    Is this possible?

    Todd gave an answer official here a little more than a year, saying:

    Scripts from Adobe Media Encoder is not a supported feature.

    Adobe Media Encoder & ExtendScript Toolkit

    There is also script tools like AEmpeg that will make output render customized by using ffmpeg.

    AEmpeg - aescripts + aeplugins - aescripts.com

    However, my guess is that you have a pipe already in place using the SOUL, so it would be a better solution if you had direct access to the SOUL well ExtendScript. Unfortunately, it may be some time before any control ExtendScript soul comes to light.

    That said, I've tried a few things and found a code ExtendScript SOUL, BUT, as the "ExtendScript Toolkit ReadMe.pdf" under the 3.1 Cross-Suite Script Debugging not supported section:

    Although it is possible to target a non creative application and run it from the ESTK CC, such a cross-suite scripting workflow is not supported. The script may or may not run as expected in the target application.

    So although you are able to target SOUL in ESTK, it may or may not work as you wish. Also, these are undocumented by Adobe, so they can disappear at any time and will never be supported by Adobe. IF you are not going to find a lot of help from them on either.

    I ran the object of reflection alerts to collect methods and possible properties of TEA CC2014. There could be more than what I found. I have not tested these, nor do any responsibility for them. !!!!! USE at YOUR OWN RISK!
    METHODS AND BASIC PROPERTIES

    NaN

    Infinite

    undefined

    App

    $

    Math

    encodeURI()

    encodeURIComponent()

    decodeURI()

    decodeURIComponent()

    Escape()

    eval()

    uneval()

    isFinite()

    isNaN()

    parseInt()

    parseFloat()

    unescape()

    Localize()

    isXMLName()

    setDefaultXMLNamespace()

    Alert()

    confirm()

    prompt()

    Object()

    Function()

    File()

    Folder()

    Array()

    Boolean()

    Date()

    Error()

    Number()

    RegExp()

    String]

    METHODS AND PROPERTIES OF THE APP

    app.launchTime

    app.assertToConsole)

    app.renderFrameSequence)

    app.getEncoderHost)

    app.getExporter)

    App.Quit)

    app.getBuildNumber)

    app.simulateUIEvents)

    app.scheduleTask)

    app.cancelTask)

    App.Wait)

    app.getWatchFolder)

    app.getFrontend)

    app.toLocaleString)

    app.hasOwnProperty)

    app.propertyIsEnumerable)

    app.isPrototypeOf)

    app.toSource)

    App.unwatch)

    App.Watch)

    METHODS AND PROPERTIES TO SUPPORT

    .error $

    .version $

    .build $

    $.buildDate

    .global $

    .stack $

    level of $

    .flags $

    $.strict

    .locale $

    .localize $

    $.decimalPoint

    $.memCache

    $.appEncoding

    $.screens

    .OS $

    . Filename $

    .line $

    $.hiresTimer

    .Dictionary $

    $.engineName

    $.includePath

    $. about()

    $. toString()

    $. write()

    $. writeln()

    $. bp()

    $. getenv()

    $. setenv()

    $. sleep()

    $. colorPicker()

    $. evalFile()

    $. list()

    $. listLO()

    $. summary()

    $. gc()

    METHODS AND PROPERTIES OF MATHEMATICS

    Math.E

    Math.LN10

    Math.LN2

    Math.LOG2E

    Math.LOG10E

    Math.PI

    Math.SQRT1_2

    Math.SQRT2

    Math.ABS)

    Math.Acos)

    Math.Asin)

    Math.ATAN)

    Math.atan2)

    Math.ceil)

    Math.COS)

    Math.exp)

    Math.Floor

    Math.log

    Math.Max)

    Math.min)

    Math.Pow)

    Math.Random)

    Math.Round)

    Math.Sin)

    Math.sqrt)

    Math.Tan)

  • Capture mouse click, rotation of symbol-to-Mouse &amp; mouse-symbol drawing

    Hello

    I am a student creating a game in Flash with ActionScript 3. However, I don't know what I got and I'm faced with a number of things in my game. I need only, which seems to be a certain number of simple things, but I can't understand how they work. Mainly because I'm new to AC3. These are the things I need that I fight with:

    • Rotate a Clip based on the location of the mouse. The Clip is moving or motionless elsewhere on the stage at any time. (Movie Clip has an instance name of "tnkChieftainTurret")
    • Draw a Clip at the location of the mouse cursor. I am familiar with rendering a new variable and sprite and doing AC3 draw form via code, but it would be easier to call an existing symbol to draw.
    • I need a way to capture the event with a click of the mouse. Previous I only use keyboard KeyCode events, so I am new on this.

    I looked online and I found a tutorial for the rotation of a clip, but it was in AC1 so I don't think it would work.

    Any help is appreciated.

    Thank you

    Lewis.

    • Rotate a Clip based on the location of the mouse. The Clip is moving or motionless elsewhere on the stage at any time. (Movie Clip has an instance name of "tnkChieftainTurret")

    this.addEventListener (Event.ENTER_FRAME, loopF);

    function loopF(e:Event):void {}

    tnkChieftainTurret.rotation = 180 * Math.atan2 (mouseY - tnkChieftainTurret.y, mouseX-tnkChieftain Turrent.x)/Math.PI;)

    }

    • Draw a Clip at the location of the mouse cursor. I am familiar with rendering a new variable and sprite and doing AC3 draw form via code, but it would be easier to call an existing symbol to draw.

    this.addEventListener (Event.ENTER_FRAME, loopF);

    function loopF(e:Event):void {}

    whatever_mc.x = MouseX;

    whatever_mx.y = MouseY;

    }

    • I need a way to capture the event with a click of the mouse. Previous I only use keyboard KeyCode events, so I am new on this.

    stage.addEventListener (MouseEvent.CLICK, clickF);

    function clickF(e:MouseEvent):void {}

    No matter what

    }

  • Follower of the mouse of rotation with easing

    I'm terrible at math and having a problem to reach my goal.

    http://www.newgrounds.com/dump/item/6e5cde6c6b94de74119aac82c43312d2 - example

    It works just fine, but what I want to do is have each object to follow the rotation at different speeds. I want that every MC having "Acceleration".

    I can't understand how to run a little slower than the mouse itself. As a result, just dead on, same speed as the mouse moves, it moves.

    Related to mcMouseFollower.as MovieClip class.

    I have my main class the following:

    package {}

    import flash.display. *;

    import flash.events.Event;

    SerializableAttribute public class MAIN extends MovieClip {}

    public var follower: mcMouseFollower;

    public void MAIN () {}

    the constructor code

    Tracker = new mcMouseFollower();

    Follower.x = stage.stageWidth / 2;

    Follower.y = stage.stageHeight / 2;

    stage.addChild (follower);

    stage.addEventListener (Event.ENTER_FRAME, frameLoop);

    }

    public function frameLoop (event: Event): void {}

    Check out the coordinates of the mouse to discover the angle

    var cy:Number = stage.mouseY - follower.y;

    var cx:Number = stage.mouseX - follower.x;

    var Radians: Number = Math.atan2 (cx, cy); / / Find the angle

    var degrees: Number = Radians * 180 / Math.PI;// convert to degrees of rotation

    Rotate

    Follower.rotation = degrees;

    }

    }

    }

    To do this manually, you need to find the change in rotation between the follower.rotation and the degrees of calculated. Then, you apply some of this difference. So if you want to have the rotation of the rod move 1/10 of the path to the destination of your choice each image, calculate the change in the rotation needed to point to the mouse, then multiply by 0.1 and apply this rotation changed to follower.rotation. This does not exactly work as tweens that you configure in Flash because it will not have an exact end time. Instead, each image rotation reduces the difference in new rotation of half. It will resemble an ease of exit. You can check when it is thin enough (for example, the difference is less than 1 degree) and just snap to your final rotation rather than continue to settle for halfway.

    You'll want to know how to work the degrees of rotation. Pointing to the right is 0 degrees, rotation to the right there is positive, go to 180 that points to the left. From 0 degrees and rotating timer causes the downward rotation value, entering negative numbers, from 0 to-180 (pointing to the left). So when you try to interpolate a value through the left direction you have a problem, since the numbers of jump from-180 to 180 at that time here.

    To solve this * West * problem, you detect if the rotation must be changed by more than 180 and you adjust accordingly for the direction of rotation moves the shortest distance to the rotation of the target rather than the long way around. The calculation in the SmartRotationPlugin of the packaging of GTween is a good way to handle this:

    https://code.Google.com/p/Pipoca/source/browse/trunk/classes/com/gskinner/motion/plugins/S martRotationPlugin.as? r = 9

    Here's the corrected code (starting after your calculation of degrees):

    var deltaDegrees:Number = degrees - follower.rotation;

    deltaDegrees % = 360;

    If (deltaDegrees > 180)

    {

    deltaDegrees-= 360;

    }

    ElseIf (deltaDegrees<>

    {

    deltaDegrees += 360;

    }

    Rotate

    Follower.rotation = degrees;

    Follower.rotation += deltaDegrees * 0.1;

    You can also consider using a tween as GTween for your tween engine: http://www.gskinner.com/libraries/gtween/

  • Convert points "almost smooth" and actually "sharp" in real

    Sometimes in my work I see points-liars of two kinds:

    1 the point which seems to be smooth - the angle between the handles is very close to 180 degrees, but in fact, it is not. I guess there could be a (very slow) script, which passes through all the points of the selected objects and convert those among them who have the angle between the handles fit into the set value and turn in real smooth.

    2. the point which says that it is smooth, but seems strong. You really see the angle, the angle, but when you try to change a descriptor of one of them, the opposite handle instantly remembers it is smooth and is moving symmetrically, as should be a turning point. The problem is that you can't always check status of each point in the palette controls before tweaking! I would like to have a script that I have will bring up for each suspect path and get rid of those little bastards.

    something like that?

    // by Qwertyfly...   
    
    //this is not complete!  
    
    // angle tolerance for isSmooth function
    /*
        tolerance is in radians
        0.0174533 = apporx 1 degree
    */
    var t = 0.05;  
    
    function isSmooth(P){
        var angle = Math.abs(Math.atan2(P.leftDirection[1]-P.anchor[1],P.leftDirection[0]-P.anchor[0])
                           -Math.atan2(P.rightDirection[1]-P.anchor[1],P.rightDirection[0]-P.anchor[0]));
        if(angle==Math.PI){return "smooth";}else{return(angle > Math.PI - t && angle < Math.PI + t);}
    }  
    
    var doc = app.activeDocument;
    var sel = doc.selection;
    var pointArray = {};
    pointArray.a1 = [];
    pointArray.a2 = [];
    pointArray.a3 = [];
    pointArray.a4 = [];
    for(var i=0; i		   

Maybe you are looking for