Upper/lower limits of Math.random

Hi,
I currently have applied a random range to my Mouse Cursor. So it fluctuates on the Y axis.
However it obviously takes any value between 0 and 10.
I would like it to either take 0 or 10.  I know you can use math.round / ceil, but does anyone know how I could achieve this?
Thanks.
var mouseposy = mouseY;
          var mouseposx = mouseX;
const DURATION:Number = 1;
const VERTICAL_RANGE:Number = 10;
var timer:Timer = new Timer( 50, DURATION * 20 );
timer.addEventListener( TimerEvent.TIMER, onTimer );
timer.addEventListener( TimerEvent.TIMER_COMPLETE, onTimerComplete );
timer.start();
function onTimer( $event:TimerEvent ):void
    myCursor.y = mouseposy - (VERTICAL_RANGE * ( Math.random() * 5 ));
          myCursor.x = mouseposx
          stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
          myCursor.visible = true;
function onTimerComplete( $event:TimerEvent ):void
    x = y = 0;
          stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

try replacing with these lines
const VERTICAL_RANGE:Number = 1
myCursor.y = mouseposy - ((VERTICAL_RANGE * Math.ceil( Math.random() * 2 ))* 10);

Similar Messages

  • Define upper/lower limits for shipment cost condition

    Hi people, help please!
    How can I define upper/lower limit for shipment cost conditions?.
    The transaction TK11 has the functionality for upper/lower limits, but I can't find how to define it in customizing.
    I follow the path Logistic Execution>Transportation>Pricing>Pricing Control>Define Condition Types, but is not like the transaction for pricing elements in condition types for sales.
    How can I do it?
    Regards.

    The problem is on the class condition import limits.
    I can’t customize upper and lower prices for the shipment cost class condition and i cant find how define it or what else can I do.
    The customizing transaction for shipment cost lass condition is not like sales price class condition, please look this:
    For the shipment cost class condition follow the path SPRO>Logistic Execution>Transportation>Shipment Cost>Pricing>Pricing Control>Define Condition Types.
    For the sales price class condition follow the path SPRO>Sales and Distribution>Basic Function>Pricing>Pricing Control>Define Condition Types, and take a look in Define upper/lower limits for conditions.
    So then, when I go to functional transaction VK11 for the sales price condition y can’t assign an import out of the limits defined. I need the same for shipment cost condition, transaction TK11, but I can’t find where define the limits, as result, user can load any import without limits.
    I hope the explanation is useful.

  • Generic delta - upper & lower limits

    Can someone explain the upper & lower limits in generic delta for all the 3 delta-fields - time-stamp, calday & num.pointer with examples?
    Points guaranteed for clear illustrations.
    Regards,
    R.Ravi

    Ravi,
    The detailed illustration has given below for all the delta mechanisms in Generic in a simpler way to understand... Please go through....
    1. If delta field is Date (Record Create Date or change date), then use Upper Limit of 1 day. This will load Delta in BW as of yesterday. Leave Lower limit blank.
    2. If delta field is Time Stamp, then use Upper Limit of equal to 1800 Seconds (30 minutes). This will load Delta in BW as of 30 minutes old. Leave Lower limit blank.
    3. If delta field is a Numeric Pointer i.e. generated record # like in GLPCA table, then use Lower Limit. Use count 10-100. Leave upper limit blank. If value 10 is used then last 10  records will be loaded again. If a record is created when load was running, those records may get lost. To prevent this situation, lower limit can be used to backup the starting sequence number. This may result in some records being processed more than once.
    For more information you can access to:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/3f/548c9ec754ee4d90188a4f108e0121/frameset.htm
    COPA timestamps vs Generic timestamps
    Re: process chains/partitioning in modeling
    Hope it helps...
    Assign Points if it helps...
    Regards,
    Gattu

  • Condition type upper lower limits

    Hello Experts,
    As we know, condition types can be set upper and lower limits.
    Lets say a condition type has 3 scales : 2% , 3% , 4% for discount, for example.
    And if the lower and upper limits are : 0% , 5% respectively, i do not see how effective these limits are.
    I mean, the condition will not derive a value for 0% or 5%. If the value is 0%, there is nothing in the scale matching 0% also.
    So, i do not understand what is the use of the upper and lower limit when the limits are not found in the scales.
    regards
    Tom

    Hi,
    The lower and upper limit does not have a significance, when you want only certain specific percentages as discounts. However when you want to provide a range of allowed percentage discount, then the limits are meaningful; e.g. if anything from 10% to 20% discount is allowed, you have to maintain 20% as lower limit and 10% as upper limit as discounts are negative; else you may get error message as "10.000 exceeds the limit 20.000 in the condition record".
    Kindly award points if you find the information useful.
    Thanks & Regards,

  • Amending the mic upper lower limits at the time of RR

    Hi, Please advise how to change the upper lower limit of the mic during resultts recording? Also advise how to cancel the recorded values of the results recording so that the lot status becomes REL? Can we change REL to CRTD status. Thank you every one supporting the beginners.

    please advise how to change the upper lower limit of the mic during resultts recording?
    Its really not possible
    Also advise how to cancel the recorded values of the results recording so that the lot status becomes REL?
    You can not cancel but change the values .This is possible if you declare all char as "Long term " char in control indicator.
    This will give status LTIN to char which allows you to change the RR values at any times
    Can we change REL to CRTD status.
    In QA02-->click on "Reset"-->save -->this will change status from REL to CRTD.
    but this is only possible when UD is not taken

  • Sales price upper/lower conditions

    hi,
    I would like to know if it's possible to set a warning message, if we set a sales prices upper or lower (in % or not) then a default value.
    I have already defined upper/lower limits for the sales conditions but does not work.
    Thank you very much
    Pedro Barros

    Hey Ines,
    LSMW is probably your best bet. The only tricky part is ensuring your key combination string e.g. Sales Area, Customer, Article is included for SAP to figure out which pricing table to update. If you create an LSMW object using a recording, it calls tcode VK15 (for what its worth...).
    The other option you could try is CATT (Computer Aided Test Tool). You can access that via transaction SCAT. That will do the trick for as well.
    Good luck!
    Cheers,
    Paul...

  • Graph of Multiple Numeric Result displaying measurements and upper and lower limits

    Is there a way with your graph control to show all the measured values against upper and lower limits in the same graph?. I can display individual lines, but would like to show all the data on the one graph. The woefully cryptic help files you provide with the graph control in TestStand seriously needs attention (Give examples!) also axis labelling, how is that achieved?

    Hey Brian,
    I'm not sure I understand what you're wanting to see with the data plotted on the graph--would it be possible for you to show us an example, even if it's just a drawn mockup of what the graph would look like? I'd like to look into it a bit and confirm that there is not a way to display the data.
    Also, could you provide a bit of detail about the problems you've run into with using external languages with the ATML and XML reports? I'd like to understand that issue a bit better as well to determine how we could address it.
    One thing you might be interested in is that we can currently embed images in the report by inserting HTML code linking to the image. I've seen cases where a LabVIEW VI plotted some data onto a custom graph, saved a picture of the control, and linked the image into the report. Here is a KnowledgeBase article which describes how the linking process works: http://digital.ni.com/public.nsf/allkb/D98A271E30431C9D86256C230079843A?OpenDocument
    I'll look forward to your reply about what you're hoping to see, and perhaps we can think of the best way to accomplish it with the reporting mechanism in TestStand. As Chiara mentioned, if there are features you would like to see that are not currently possible with our reports, the Idea Exchange will be a great place to post that. 
    Thanks!
    Daniel E.
    TestStand Product Support Engineer
    National Instruments

  • OMR6 upper and lower limits

    I am developer and this is not my area of expertise, so not sure if wording will be correct.  I believe We place payments blocks on invoices based on values set in OMR6.  This is where the configuration is done.  However I have been told that the system will not do this for lower limits.  Can this be done in OMR6 or is there another area we can do this without having to create a user exit?  I'm told that upper limits work fine but that the design of the system does not allow this for lower limits.  Anyone have any ideas of where configuration can be done for this?

    I had someone here walk me through what was in the setup.  For the the Tolerance key "PP" for this specific company there is an upper and lower limit entered and the "check limit" is selected for both upper and lower entries.  The upper limit check works but the lower limit check does not work.  They said, all SAP notes say you have to enable a specific user exit to get the lower limit to work for "PP".  This does not sound right but might be true.  Is there something special you have to do with the "PP" type to get it to work?  I cannot imagine SAP having the lower limit entry there but not using it, but like I said it is possible.

  • Meter reading upper and lower limits

    Hello,
    Does anyone know how the structure REL16_RANGE in the form class  IS_U_DM_MR_DOWNLOAD gets filled? I need to find the place where the upper and lower limits are filled and how to manipulate, i.e. to correct them.  Where, which table, are these values coming from?
    thanks,
    melinda

    GO to se38 t-code give report name IEEL16R2
    Line no : 2287.
    form fill_reading_ranges using x_reading like t_reading
                                                     y_ranges  like rel16_range.
    This form wil fill your structure REL16_RANGE.
    first it will serach for the billing documnet...then it will find out the rate category,rate then it will search for the tolearnce limit.
    Then Upper limit.
          convert lower limit 1 MR result into display format*
            call function 'ISU_METER_IDDATA_TRANSFORM'
          convert upper limit 1 MR result into display format*
            call function 'ISU_METER_IDDATA_TRANSFORM'
    Please let me know if you need any more information.
    Regards,
    Siva

  • Logistics Invoice verification MM - tolerances for lower limits and Credits

    Hello,
    My end-user is wondering why the system does not re-act/block on the lower limits of the price tolerance.
    I have checked several SAP document and found:
    1. Blocking Invoices
    If a tolerance limit is exceeded, you receive a system message. You can post the invoice in the
    system, but it is automatically blocked for payment if an upper tolerance limit is exceeded.
    So for the lower tolerance limit there is no block only a warning.
    2. Posting Credit Memos
    The system does not check if your entries in the columns Amount and Quantity correspond to
    the purchase order price or the invoice price.
    So there is never a message or block for Credit Memos.
    3. Subsequent Debits/Credits
    If you want the system to carry out a price check for a subsequent debit, it compares the
    value invoiced to date plus the value of the subsequent debit with the expected value based
    on the purchase order. The system takes tolerance limits into account when carrying out the
    price check. If a price variance exceeds one of the upper tolerance limits, the subsequent
    debit is blocked for payment.
    So only a check for subsequent Debit , not for Credit.
    The examples my end-user has are the following.
    1. Blocking Invoices
    If the Invoice price is too low, the purchaser should be informed, he has to check what is wrong in the purchase order.
    Maybe the price unit was filled in incorrectly or ...
    Example:
    a. Standard price is 100 Eur per 1 PC
    b. Purchase price is 1000 Eur per 1 PC
    Purchaser has made mistake it should have been 100 per 1 PC.
    I checked and the Purchaser gets an info msg 06207 Effective price is 102.00 EUR, material price is 100.00 EUR,
    but he can ignore this message.
    c. Invoice price is 500 Eur per 1 PC
    This invoice price is actually too high compared with the standard price but because of the high Purchase price no blocking occurs.
    In this case we would like the system to also block the Invoice for payment.
    2. Posting Credit Memos
    Purchase order has a price of 1765 Eur.
    We received goods and an Invoice for 1765 Eur.
    We have returned the goods to the Vendor and we post a Credit Memo of 1048 Eur.
    We receive no warning and the Credit Memo is not blocked for payment
    The system should warn us that the Credit Memo has a too low value and we would prefer that the system blocks the Invoice.
    3. Subsequent Debits/Credits
    The Subsequent Credit can be seen as an Invoice price too low and therefore we would like it to be handled the same, see 1.
    Can you please give us your opinion.
    Is there a possibility to change the standard behavior of the system ?

    Hello,
    The limit check values have already been set up for key tolerance PP -upper and lower limit in OMR6 tcode.
    Unfortunately when we are creating an invoice with a lower value than the expected value on the PO, it doesn't trigger the invoice block.
    From what I've read on the forum SAP proposed as a solution the use of enhancement MM08R002-User exit for tolerance checks=> fm  EXIT_SAPLKONT_002- Customer Exit: Change Tolerance Check, but in our system the check for upper limit is performed inside the fm MRM_AMOUNT_CHECK=>
    fm MRM_TOLERANCE_CHECK
    Überschreitung der Toleranzgrenze -
      IF I_AKT_WERT > I_VERGLEICHSWERT.
    ... Betrag -
        IF T169G-XW2JA NE SPACE.
          DIFF_P = I_AKT_WERT - I_VERGLEICHSWERT.
          IF DIFF_P > WERT2.
            E_BETRAG = WERT2.
            E_RETURNCODE = 1.
            E_SPERRGRUND = 'X'.
          ENDIF.
        ENDIF.
    Could you please advise me how you have implemented the check on lower limit tolerance?(eventually a sample of coding)
    Thanks,
    Andrei J.

  • How to change double i = Math.random(); value to (int) value

    I am trying to find out how to convert a given double value to integer, which is, to conver double myNumber = Math.random() to (int) value. Here is the sample program look like this.
    Thank you for the help.
    import javax.swing.JOptionPane;
    public class numbers
    public static void main(String[] args)
    int upperLimit = Integer.parseInt(JOptionPane.showInputDialog
    (null, "Enter the upper range integer."));
    double myNumber = Math.random();
    //Test of Random numbers.
    System.out.println("The Upper random number limit is: " +
    myNumber * upperLimit);
    } //End of main.
    } // End of class.

    Not sure exactly what you want and why you want to change the double to an int. I'm assuming by this you want to generate random integers, from 1 to the upper limit the user enters? If so, this is how I would do it:import java.util.*;
    import javax.swing.*;
    public class Numbers
        public static void main(String[] args)
            int upperLimit = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the upper range integer."));
            Random r = new Random();
            int myNumber = r.nextInt(upperLimit) + 1;
            System.out.println(myNumber);
    }

  • HELP!!!  math.random() problem

    Hello,
    I was wondering if anyone can help me with a problem I'm
    running into using the math.random(). I'm using Flash CS3 and
    created a very simple script to select random frames in a simple
    movie. It works as expected in the CS3 environment and in Safari
    but it doesn't work correctly in Firefox or in the DotNetNuke
    module I am using. Here is the code:
    i = Math.ceil(Math.random() * 3);
    gotoAndPlay("Image"+i);
    I would appreciate any help you can provide.

    Remember that Math.random() function returns a positive double value between 0.0 and 1.0. For a better definition you can refer to the Math class in the API.
    Since this is an assignment, I am not going to give you the code but I'll just tell you how you should be going about solving this.
    Now you have two limits right? What you can do is, multiply the smaller of the two numbers (I guess in your case its going to be the top) with the random number generated by the Math.random() function. Just add a check to see if this result is lesser than the maximum limit. If yes, then go ahead and add that number to the array. If not, just repeat the same thing.
    I hope you got the idea. If you still have problems, please let me know.
    Plutaurian

  • Help with math.random!

    I'm trying to replace all even numbers in a string with odd numbers that are produced from a random generator. I have somewhat of an idea of how to do it as far as creating an array of 5 characters(1,3,5,7,9) and then implement the math.random to take random numbers from that array. i just dont know how to execute that. for example:
    "adam123456789" -->should be "adam153157739"
    whereas, the underlined(5,1,7,3) should be random numbers(i just picked these for an instance). is it possible to do any form of :
    Methods...
    char [ ] ary = {1,3,5,7,9};
    String line = "adam123456789";
    line = line.replaceAll("[0,2,4,6,8]", Math.round(Math.random()*[ary]));
    return line;**i'm a beginner, so i dont really know what im talking about. just seeking help. thanks!

    ok. this is the class with all of my methods in there. just excuse the rest of it..
    import java.util.Random;
    public class NoVowelNoEven {
      private String str = "";
      NoVowelNoEven() {
        str = "hello";
      NoVowelNoEven(String newString) {
        str = newString;
      String getOriginal() {
        return str;
      static String getValid(String newString) {
        char[] arr = newString.toCharArray();
        String str2 = "";
        for (int i = 0; i < arr.length; i++) {
          if (isValid(arr)) {
    str2 += arr[i];
    return str2;
    static int countValidChar(String newString) {
    String validString = getValid(newString);
    return validString.length();
    static String replaceWithYAndOdd(String newString) {
         char [] ary = {1,3,5,7,9};
         String str3 = newString;
    str3 = str3.replaceAll("[a,e,i,o,u]","y");
    str3 = str3.replaceAll("[A,E,I,O,U]","Y");
         //str3 = str3.replaceAll("[0,2,4,6,8]", );
    return str3;
    static boolean isValid(char char2) {
    switch (Character.toLowerCase(char2)) {
    case 'a':
    return false;
    case 'e':
    return false;
    case 'i':
    return false;
    case 'o':
    return false;
    case 'u':
    return false;
    case '0':
    return false;
    case '2':
    return false;
    case '4':
    return false;
    case '6':
    return false;
    case '8':
    return false;
    default:
    return true;

  • Seen this question before but no answer, how can I change my email address from all caps into a more proper upper-lower style.

    Seen this question before but no answer, how can I change my email address from all caps into a more proper upper-lower style.

    You should be able to change your e-mail address from your provider ... then edit it to meet the Apple requirements.   Unfortunately you've given us no profile details so we can't tell what device you have.

  • Is there a way to create a math.random that doesn't overlap movieclips?

    Hi,
    Actually I have two questions. I am creating a memory sequence game and I was wondering:
    1. Is there a way to random position movieclips on the stage without having them overlap each other?
    2. Is there  a way to have flash draw a vector line from one clip to another in sequence and then have the user retrace what flash did? I have 6 movieclips on the stage, each with their own instance (ex. obj1_mc, obj2_mc, etc.). Is there a way to tell flash to always draw a line between movieclips in sequence even though the movieclips are randomly placed on the stage?
    Thanks,
    OJ

    sure.
    1.  the easiest way to position objects without over-lapping, IF you can assume it will always be possible, is to use something like:
    var mcA:Array=[your movieclips]
    var index:uint=0;
    positionF();
    function positionF(){
    // assuming top-left reg points of your movieclips
    mcA[index].x=Math.random()*(stage.stageWidth-mcA[index].width);
    mcA[index].y=Math.random()*(stage.stageHeight-mcA[index].height);
    var hitBool:Boolean=false;
    for(var i:int=0;i<index-1;i++){
    if(mcA[index].hitTestObject(mcA[i])){
    hitBool=true;
    break;
    if(hitBool){
    positionF();
    } else {
    index++;
    if(index<mcA.length){
    positionF();
    } else {
    // positioning complete.  do whatever
    2.  you can use the graphics class to draw dynamic lines.

Maybe you are looking for

  • 11gR2: Message state after dequeue in AQ$ queue_table view

    Dear all, we are in the process of migrating from 10gR2 to 11gR2 and encountered the following problem. We send messages over an advanced queue to 1 to n recipients. After dequeuing the message we query the AQ$<queue_table> view to determine if the s

  • Metadata in Pre Video Player?

    I watch a lot of videos--usually TV shows from DVD--on the Pre during my commute. Previously I was using an iPod Touch, and I have to say I prefer the experience on the Pre in every way but one. The iPod uses program title, season, and episode metada

  • Adobe Digital Editions Help please?

    I have purchased my first e-book: "Adobe Premiere Pro CC Digital Classroom" from JB HiFi. The payment went through successfully and I tried to download the e-book. I got the message that to download the e-book I had to install Adobe Digital Editions.

  • Exporting problems with pages

    How come whenever I export a document, in this case an essay, it is exported and saved using text edit? This is a huge problem for me since text edit doesnt support MLA format. Please help

  • Cannot Upgrade to Mountain Lion - SMART Errors (Failing)

    Hey everyone, I received a 17" MB Pro as a gift in April 2011, until then I was a Windows user.  I always kept the software up to date (currently running 10.6.8) and tried to minimize the amount of "junk" on the computer. The MB has been working incr