Math.sin(Math.PI)

It's a circular pre-loader. When I add the "SecondHalf" the preloader doesn't work and gives an error saying the script is causing the flash player to run slowly. How can I fix this?
This code is in:  _root.first_mc._second_mc
previewImage.onLoadProgress = function(targetMC, lBytes, tBytes) {
//FirstHalf
//This works only without "SecondHalf"
          percentDone=Math.round((lBytes / tBytes) * 100);
          _root.loaderPsnt_tx.percentDisplay.text = percentDone + "%";
//SecondHalf
//This is not working
      _root.mc_mask.clear();
      _root.mc_mask.beginFill(0xff0000, 100);
      _root.mc_mask.lineStyle(1, 0xff0000, 80);
      for (i=0; i>=c; i--) {
         x = Math.sin(Math.PI/90*i)*mask_ra;
         y = Math.cos(Math.PI/90*i)*mask_ra;
         _root.mc_mask.lineTo(x, y);
      _root.mc_mask.endFill();
      c = Math.round(percentDone * (-1.84));
previewImage.onLoadStart = function(targetMC) {
          _root.loaderPsnt_tx._visible = _root.circle._visible = _root.mc_mask._visible = true;
          _root.circle.setMask(_root.mc_mask);
          var mask_ra:Number = (_root.circle._width / 1) * -1;
          var c:Number = 0;
          var percentDone:Number = 0;
previewImage.onLoadComplete = function(targetMC) {
          _root.loaderPsnt_tx._visible = _root.circle._visible = _root.mc_mask._visible = false;

mask_ra is undefined in onLoadProgress.
use:
var mask_ra:Number;
previewImage.onLoadProgress = function(targetMC, lBytes, tBytes) {
//FirstHalf
//This works only without "SecondHalf"
          percentDone=Math.round((lBytes / tBytes) * 100);
          _root.loaderPsnt_tx.percentDisplay.text = percentDone + "%";
//SecondHalf
//This is not working
      _root.mc_mask.clear();
      _root.mc_mask.beginFill(0xff0000, 100);
      _root.mc_mask.lineStyle(1, 0xff0000, 80);
  c = Math.round(percentDone * (-1.84));
      for (i=0; i>=c; i--) {
         x = Math.sin(Math.PI/90*i)*mask_ra;
         y = Math.cos(Math.PI/90*i)*mask_ra;
         _root.mc_mask.lineTo(x, y);
      _root.mc_mask.endFill();
previewImage.onLoadStart = function(targetMC) {
          _root.loaderPsnt_tx._visible = _root.circle._visible = _root.mc_mask._visible = true;
          _root.circle.setMask(_root.mc_mask);
         mask_ra = (_root.circle._width / 1) * -1;
          var c:Number = 0;
          var percentDone:Number = 0;
previewImage.onLoadComplete = function(targetMC) {
          _root.loaderPsnt_tx._visible = _root.circle._visible = _root.mc_mask._visible = false;

Similar Messages

  • Math.sin() problem

    Hi!
    I need calculating sin in java but i need it in degrees and java doing it in rads. Anybody knows what can i do?
    Thanx!!!
    Max

    Maybe you should look through the API at that Math class. You're already using Math.sin() ... how could you have missed Math.toDegrees() and Math.toRadians() ???

  • Math.cos Math.sin = Math.HELP

    Hello Everyone,
    I was hoping to create a JS script to move objects away from common center based upon their current position. I was thinking to use a single selected path item as the center based on its position x/y and width/height. Using this reference point the script would then move away all other path items from this center point based on a desired amount and with uniform increments given their current location from this center. I was thinking cos and sin would be my friend in this case, however they seem to have become my foe instead. ;-)
    Does this sound doable? What am I missing, doing wrong, misinterpreting? Below is a non-working attempt, I can't seem to sort things out, perhaps I was close and missed it or maybe I am super way off and its more complex than I thought. However at this point I am confused across my various failed attempts this only being one of them.
    Thanks in advance for any assistance and sanity anyone 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 one way to do what I think you want to do, I commented out the step increment so all items will "explode" the same distance, not sure if that's what you need.
    first I'd move the calculation of the Selected object's center out of the loop, you only need to make the math once.
    also, (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 thru all items 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're going to skip calculating the distance from the selection's center to each item's center, we don't need it for this method, other methods could use this info.
    now, your actual question about Sin/Cos
    xn = Math.cos(Number(dx) * Math.PI / 180)+stepNum;
    sin(angle) and cos(angle) expect angles in Radians, you are not providing any angles in the formula above. We need to calculate the angle between Selection's center and each path's center
            // get the angle formed between selection's center and current path's center
            var angle = get2pointAngle ([cx,cy], [px,py]);
    once we have the angle we can apply it to our "Explosion" variable, I'm assuming is stepNum, and get its x and y distance it needs to move away from 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
    all is left to do is move the paths, here's 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;

  • Math.sin

    I am asked to create a program that takes an angle in degrees convert it into radians and give the sin cos and tan of the angle
    I am unfamiliar with these methods and unsure how to set the method up
    I have looked up the method details for all methods such as
    sin
    {code}public static double sin(double a){code}
    I still do not have any clue, I do not want just an answer, I would rather be guided somewhere that I can figure this out on my own.
    I try to look up the classes and methods on java but i just dont understand, this is my second java class and it still seems like a different lanuguage.
    THanks for any help

    a couple of corrections but I think this is perfect
    the last code i posted after i converted to radians i still used my degree varible to detrimine my cos, sin, and tan
    so i fixed it to use the converted radians
         public static void main(String[] args) {
              // Initialize variables
              double angdeg = 0;
              double csin = 0;
              double ccos = 0;
              double ctan = 0;
              double rad = 0;
              // User Input
              Scanner kb = new Scanner(System.in);
              System.out.print("Enter The Angle in Degrees");
              angdeg = kb.nextDouble();
              // Calculations
              rad = Math.toRadians(angdeg);
              csin = Math.sin(rad);
              ccos = Math.cos(rad);
              ctan = Math.tan(rad);
              // Output
              System.out.printf(" Angle (degs): %4.4f\n Angle (rads):  %6.4f\n Sine: %15.4f\n Cosine: %13.4f\n Tangent: %12.4f\n", angdeg, rad, csin, ccos, ctan);
    }

  • Using java.lang.Math.sin/tan/cos  to make an arc - very simple

    hi all,
    i'm trying to dynamically create an set of numbers in an arch pattern -- going left to right (counter clockwise) --- from 0 degrees to 180 degrees. -- similar to an upside down U
    Any ideas on how i would do a simple loop to put the number 1 in a semicircle.
    I'm guessing that it might look like this
    while(x < 181)
    g.drawString(Integer.toString(x) , java.lang.Math.sin(..), java.lang.Math.cos(...) )
    how may I ask does that work again ?
    s

    The coordinates of the unit circle are given by
    x = cos(t)
    y = sin(t)
    where 0 < t <= 2pi
    You'll want to scale and translate that... Here's a code fragment; play with it a little:for (double t=Math.PI/2; t < 2*Math.PI, t += .05) {
        double x = 100*Math.cos(t) + 100;
        double y = 100*Math.sin(t) + 100;
        g.drawLine((int) x, (int) y, (int) x, (int) y);
    }

  • Math library not generating errno values or SIGFPE on Intel!!

    Hello. I posted this a long while back and got no responses, so I decided to ask again. I am writing a calculator, and it is not very nice for testing if I have to wind up with this:
    <pre style="width: 600px; background-color: #F0F0F0">$ hoc
    sqrt(-4)
    nan
    atan2(0,0)
    0
    pow(-4, 1/2)
    nan
    1e4000 * 1e4000
    inf
    (-1e4000) * (1e40000)
    -inf
    1e-40000
    0
    </pre>
    My program handles SIGFPE and there is a function errcheck() that checks the value of errno. It seems like the atan2(), pow(), and sqrt() functions do not assign to errno like they should. I'm running on an Intel Mac, and it makes making sure this calculator works right a big pain. Does anyone PLEASE know how to fix this? THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    What x-bc does is: convert long function names (sin(), ...) to the short ones (s(), ...), save the final result in a temporary file, and just pipe bc -lq (include math library, no GNU bc banner) redirecting standard input to that temporary file over to their GTK+ text box. There's something that has to do with GNU bc then, and that results in a weird value (1) in my testing...
    PS - The file is src/main_window.cc; function int main_window::executeBc() - on version 2.0: lines 376 through 408. The code that does converting long to short is unknown to me.
    Message was edited by: andlabs
    Message was edited by: andlabs

  • Math power function in script logic

    Hello all!
    Can anybody help me how  I can do math "power" function in BPC 5.1 Script Logic?
    Thanks

    Let's say you have a source account FOO and you want to calculate FOO to the 5th power, posting the result to FOOFIVE.
    In BPC SQL scripting, there are no mathematical functions to play with (powers, roots, sine, cosine, etc.) except for add, subtract, multiply and divide -- plus you can round results in your Factor or Expression. So that means, we must use multiplication.
    You could certainly do this using a bunch of intermediate accounts, one each for foo squared, foo cubed, foo to the 4th, and foo to the 5th. That would require *GO in between each *WHEN/REC block, and could be slow.
    I haven't tried this, but I think this should work, all in one statement:
    *XDIM_ACCOUNT = FOO
    *WHEN *
    *IS *
    REC(Factor=GET(Account="FOO")GET(Account="FOO")GET(Account="FOO")GET(Account="FOO")*GET(Account="FOO"),Account=FOOFIVE)
    *ENDWHEN
    If you want FOO to the 50th power, copy & paste.
    If you want square root of FOO, that could be a real challenge. I think to use straight BPC SQL logic it wouldn't be possible. I would probably write a stored procedure using SQL's SQRT(), and call that from the BPC logic file. Likewise for any other geometric functions, complex algebra, etc.
    There also may be a way to calculate powers in MDX -- that's more mathematically straightforward -- but as a BPC on MS person, I really never ever use MDX due to performance.
    Regards,
    Tim

  • Is Edge a good tool to build math/science simulations

    We are building math and science simulations for dept of Edu and wonder if Edge will be a good tool for us or not. Our simulations include creating graphs from math formulas, or draw a sine wave by following a fixed point on a rotating circle, or depict a law of action-reaction in physics. And most of our simulation require pixel drawing. In Flash it's easy to draw the and create any object path. but don't know how to do that with Edge.
    Thanks
    D.

    Hi, folks-
    Right now, there is no way to do custom motion path animation natively in Edge Animate.  As resdesign mentioned, you can use Canvas as an external tag, though there are certainly things you can do with linear motion as a part of educational material.
    Hope this helps,
    -Elaine

  • Math for looking up and down in 3d world

    Hello,
    I have a float called "heading" which is how much the player has turned (around the y axis) and a float called "verticalLook" which is how much the player has started to turn his head upward towards the sky.
    I call
    gl.glRotatef(360.0f - heading,0,1.0f,0);//this correctly rotates the user about the y-axis.Then, I call:
    gl.glRotatef(verticalLook,(float)(Math.cos(heading*TO_RADIANS)*TO_DEGREES),0,
                     (float)(Math.sin(heading*TO_RADIANS)*TO_DEGREES));This produces weird results. I tried switching the sin and cos and it still didnt work. I know that to vertically look up, it will have to be rotated about a combination of the x and z axis, but I'm trying to figure out the formula.
    Thanks

    hello Datta,
    thanks for you quick reply, these one you sent me are for allowing the end user to actually be able to use the scroll track ball in a mouse, just the same way it works in Excel or Word?
    thanks again, i will test them shortly.
    JD

  • How to use some math functions?

    Hey everyone,
    In this days i building a calculator and i need to use so
    Trigo functions, how can i use them? have some table
    with all the math library functions?
    Thanks so much for the helpers!!

    To do trig in Objective-C you use the standard C trig functions. 
    double sin()
    double cosin()
    etc.

  • Graphs and Maths

    not got a clue about this probably very easy thing so pleeeeeease help me.
    i have to make a graph which displays "y=A*sin(x)+B*cos(X)" where i can select diferent values for a and b. how am i supposed to do this? what do i use? i dont even know where to start so even the basics will do. cheers 4 any help.

    This topic is absolutelly not for a java begginer. It should match more to a somewhat advanced "computer graphics in java" course. Anyway, you need a component to draw into (a Canvas for example). Its paint method should look something like this:
    public void paint(Graphics g){
    //draw the label
    g.setColor(Color.black);
    Dimension d = this.getSize();
    String lab = " y = "+a+"*sin(x) + "+b+"*cos(x)";
    g.drawString(lab,50,20);
    //draw the axes
    g.drawString("y",60,45);
    g.drawString("x",d.width-60,d.height-40);
    g.drawLine(50,50,50,d.height-50);
    g.drawLine(50,d.height/2,d.width-50,d.height/2);
    double maxx = d.width-140;
    //draw the curve
    g.setColor(Color.red);
    for(x=0.0; x<2*Math.PI; x+=0.01){
         y = a*Math.sin(x) + b*Math.cos(x);
         int x1 = (int)((x*maxx/(2*Math.PI))+50);
         int y1 = (int)(d.height/2 - y*125);
         g.drawLine(x1,y1,x1,y1);
    .....assuming that you have initialized somehow the values of a and b...
    Good luck....

  • Math Functions in SAP

    What are the math functions in SAP?

    Hi,
    This is what u want may be
    Mathematical Functions
    ABAP contains a range of built-in functions that you can use as mathematical expressions, or as part of a mathematical expression:
    [COMPUTE] <n> = <func>( <m> ).
    The blanks between the parentheses and the argument <m> are obligatory. The result of calling the function <func> with the argument <m> is assigned to <n>.
    Functions for all Numeric Data Types
    The following built-in functions work with all three numeric data types (F, I, and P) as arguments.
    Functions for all numeric data types
    Function
    Result
    ABS
    Absolute value of argument.
    SIGN
    Sign of argument:                      1 X > 0
                                                  SIGN( X) = 0 if X = 0
                                                                   -1 X < 0
    CEIL
    Smallest integer value not smaller than the argument.
    FLOOR
    Largest integer value not larger than the argument.
    TRUNC
    Integer part of argument.
    FRAC
    Fraction part of argument.
    The argument of these functions does not have to be a numeric data type. If you choose another type, it is converted to a numeric type. For performance reasons, however, you should use the correct type whenever possible. The functions itself do not have a data type of their own. They do not change the numerical precision of a numerical operation.
    DATA N TYPE P DECIMALS 2.
    DATA M TYPE P DECIMALS 2 VALUE '-5.55'.
    N = ABS( M ).   WRITE:   'ABS:  ', N.
    N = SIGN( M ).  WRITE: / 'SIGN: ', N.
    N = CEIL( M ).  WRITE: / 'CEIL: ', N.
    N = FLOOR( M ). WRITE: / 'FLOOR:', N.
    N = TRUNC( M ). WRITE: / 'TRUNC:', N.
    N = FRAC( M ).  WRITE: / 'FRAC: ', N.
    The output appears as follows:
    ABS:              5.55
    SIGN:             1.00-
    CEIL:             5.00-
    FLOOR:            6.00-
    TRUNC:            5.00-
    FRAC:             0.55-
    DATA: T1(10),
    T2(10) VALUE '-100'.
    T1 = ABS( T2 ).
    WRITE T1.
    This produces the following output:
    100
    Two conversions are performed. First, the contents of field T2 (type C) are converted to type P. Then the system processes the ABS function using the results of the conversion. Then, during the assignment to the type C field T1, the result of the function is converted back to type C.
    Floating-Point Functions
    The following built-in functions work with floating point numbers (data type F) as an argument.
    Functions for floating point data types
    Function
    Meaning
    ACOS, ASIN, ATAN; COS, SIN, TAN
    Trigonometric functions.
    COSH, SINH, TANH
    Hyperbolic functions.
    EXP
    Exponential function with base e (e=2.7182818285).
    LOG
    Natural logarithm with base e.
    LOG10
    Logarithm with base 10.
    SQRT
    Square root.
    For all functions, the normal mathematical constraints apply (for example, square root is only possible for positive numbers). If you fail to observe them, a runtime error occurs.
    The argument of these functions does not have to be a floating point field. If you choose another type, it is converted to type F. The functions themselves have the data type F. This can change the numerical precision of a numerical operation.
    Regards

  • Math functions not sure how to work with them

    Im trying to work out the math functions into my program, but I'm not sure where is the mistake. This is what I have now:
    (a) y = ax^2 + bc + c
    (b) y = a*sin(x) + b*cos(x) + cx);Especially I'm not sure how to format the sin and cos functions
    Thanks !

    jordan755 wrote:
    Im trying to work out the math functions into my program, but I'm not sure where is the mistake. This is what I have now:
    (a) y = ax^2 + bc + c
    (b) y = a*sin(x) + b*cos(x) + cx);
    Java != algebra.
    (a) says: Take the variable called 'ax', perform a bitwise XOR on its value with the number 2, add that result to the value of the variable 'bc', add that result to the variable 'c' and put the result in variable 'y'.
    (b) is trying to call sin() and cos() methods defined in the current class and add the to variable cx.
    In your other thread, you had variable names 'keyboard' and 'character'. Given that, why would you expect 'bc' to mean "b times c" rather than "variable named 'bc'"? If you want multiplication, you have to use the multiply operator, ***.
    If you want to call a method that's defined outside your current class, you have to use the class name or a reference to an object of that class. The methods sin and cos are defined in the Math class. I advise you to read their docs before using them.

  • X^2 to Math.pow(x,2)

    I am writing a program that takes an argument equation and calculates a Riemann sum. I've got the bulk of the coding written. I have no problem converting any type of trig functions in the argument to their proper string representations of the java.lang.Math class and method, ie if user enters sin(x)/cos(x), the program converts it to a string of Math.sin(x)/Math.cos(x). However, when I try to convert x^2 (x squared) to Math.pow(x,2), the computer just leaves it as it is. This is the code i've tried so far:
    args[0] = sin(x)/cos(x)  // user input at command line
    args[0].replaceAll("sin","Math\u002Esin");
    args[0].replaceAll("cos","Math\u002Esin");However, when I try the same with x^2 as input, even with the unicode instead of a carat, the output is still just x^2. Any idea how I can get a string of x^2 converted to Math.pow(x,2) ?

    then you're going to need a regular expression
    something
    like.replaceAll("(.*)x\\^([0-9]).*(.*)", "\\1
    Math.pow(x, \\2) \\3")
    Solved the problem with
    for(int i = 0; i < 10000; i++){
       s = s.replaceAll(String.format("x\\^"+i),String.format("Math\u002Epow("+i+")") );
    }covers integer exponents up to 10000, and barely noticeable increase in calculation time. thanks to all for the help!

  • Add the Math functions

    Hello there
    Can any one tell what the syntax is for adding the Math.Sin(),Math.Cos()and Math.Tan() functions to an interface as buttons.
    I tried key[] = new Button("Cos");
                   key[].addActionListener(this);
                   key[].setBounds(150,250,BWIDTH + 5,BHEIGHT);
                   key[].setBackground(Color.lightGray);
                   frame.add(key[]);
                   frame.setVisible(true);
    Just to add the button without functionality.
    There were no compilatiion error with this but the button is not visible
    Anyone see why?
    Do you use a registered name
    eg
    Math.cos = new Button("Cos");
    Thanks in advance

    Uhhhhh... Frankly, I didn't understand what do you want to do here. Do you want to make the button calculate the value of the Math methods? Any chance I get to see more code?

Maybe you are looking for

  • Does 10.6.8 support HP Photosmart D7260

    My iMac recently stopped working with my HP Photosmart D7260 printer.  (Cannot honestly remember if this was linked to a software upgrade, but is definitely not linked to the initial upgrade to Mac OS X 10.6.8 which was loaded a long time ago.) The p

  • Imac 21.5" or 24"led+mini

    I do a lot of photo editing using Photoshop cs4 as a hobby, currently using an old PC monitor calibrated by Eye-one Display 2, thinking about getting into a mac system. Due to my budget--max $1200, I am thinking either getting a refurbished 21.5" ima

  • Hi, bought Photoshop Elements 5.0 (money problems) its windows version need mac?

    Help, bought the windows version by mistake or didn't notice ... anyway, I have a Mac and not enough money to buy anything else right now, can anyone help get a Mac version running.  Would really appreciate any help!!!

  • Images locked by default.

    Whenever I open a new image in Photoshop It is locked by default. So my question is. how can I disable this?

  • Blind Network

    Hey everyone, I work on a mac (OS X, 10.4, G4.) in windows environment. Recently I needed to connect to the shared network first time, but when connected, the network seems empty, not a file insight. When I tryed to upload files, it didn't work eithe