Trigger the random function?

I would like to create a function that triggers one of the three functions randomly. Anyone know the best way to achieve this?

Thank you!

Simple test: 3 labels on the timeline and the three functions

Enter the code to run when the composition is fully charged here

var ran_number = Math.floor ((Math.random () * 3) + 1);

function one() {}

SYM. Stop ('Label 1')

}

two() {} function

SYM. Stop ('Label 2');

}

three() {} function

SYM. Stop ('Label 3');

}

If (ran_number == 1) {}

One();

Alert ('one');

}

If (ran_number == 2) {}

Two();

Alert ('two');

}

If (ran_number == 3) {}

Three();

Alert ('three');

}

Tags: Edge Animate

Similar Questions

  • I use the random function and he know instructions 'case' must end with a ':' but it is!

    I use the random function and he know instructions 'case' must end with a ':' but it is! I put

    case 10000 timer += 2; popupName._visible = true; :

    then I put

    case of 10000 {timer += 2; popupName._visible = true ;}:}

    but he still know it.

    What I am doing wrong?

    First of all, whenever you have more than three similar lines, you should probably refactor something.  Especially when you have 10,000 lines. This should have sounded the alarm, but I guess you are new to this.

    Second, when you have such a long code, paste everything here. Please, I beg you. It's a pain to navigate the thread.

    And here's what I * think * you really want:

    If (random (10001) == 10000) {}

    timer += 2;

    popupName._visible = true;

    }

    It simply means: "take a random number between 0 and 10001 (exclusive). If this number is 10,000, do something. If not, ignore this code block. »

  • Error-could not create an instance of the custom function

    Hello

    I'm trying to implement an extension of the simple custom function OPM 10.2. Here is the code:
    package com.oracle.determinations.examples;

    import com.oracle.determinations.engine.CustomFunction;
    import com.oracle.determinations.engine.EntityInstance;
    import java.util.Random;

    SerializableAttribute public class RandomFunction extends CustomFunction {}
    public Object evaluate (EntityInstance entityInstance, Object [] items) {}

    If (items [0] == null) {}
    return 0;
    } else {}
    -Code to generate a random number
    }
    }
    }

    The xml extension is the following:
    -< extension >
    -< features >
    -name of the function = "RandomFunction" type return = 'number' >
    < name arg = "enterednumber" type = "number" / >
    < Manager platform = 'java' class = "com.oracle.determinations.examples.RandomFunction" / > "
    < Manager platform = "dotnet" class = "com.oracle.determinations.examples.RandomFunction" / > "
    < / feature >
    < / functions >
    < / extension >

    I placed the code extension xml under the Development\Extensions\Examples folder and the jar file named "JavaLibrary1" containing only the above mentioned code is under Development\Extensions\Examples\lib.

    The rule that calls the custom function is as follows:
    the random number = RandomFunction (figure)

    I get the error "Unable to create year instance of com.oracle.determinations.examples.RandomFunction" when I debug the project.

    Please tell me how to solve this problem.

    Thank you
    JAS

    Received your email and found the problem. The problem is the custom .NET, function definition is invalid, and must be (or must be removed).

    When you are debugging with screens, it uses a combination of dosages of Web for Java and the host of the debugger, which takes place in .NET. Although the modules runs into reality in the determinations of web, the debugger needs always to be able to open the modules locally for purposes of reflection (eg. obtaining a list of all possible attributes and the type of data). Even if the modules is not actually executed in .NET, it must therefore be loadable, which means that if you do not provide a custom function .NET Manager, it must be valid. This:

    >

    >

    Does not appoint a .NET class, that's why the debugger complains. Delete this line (only the Manager of java leaving intact) and your example works.

    >
    You also mentioned that the random function is not a good choice, that means that the engine of dosage will not work with the random function?
    >

    Yes, a random function will not work because the engine must be (and is optimized to be) deterministic - same entry should always produce the same result.

    It is difficult to imagine what you can in theory of random numbers for (otherwise), but if you don't need, you may either) front of seeds new sessions with random inputs as attributes of basic (requires customization of your host application, for example, web determinations) or b) generate the random number from other values in your modules such as the customer, name and date of birth. This should ensure that the same combination of inputs will result in the same number of 'random' each time.

  • How to trigger the function Listfind

    Hi all

    If the field is empty, this code sets the variable nxtstep depending on the day of the week, check if the form field "is not date" and works very well in this case.

    If the form field is not empty, then it assigns to the variable nxtstep as the date on which is selected what he does, however, he is not checking to see if it is a holiday. It should trigger the function listfind and check to see if that date is a holiday, but it is just to enter the date without going through this review.

    Why does this work? Thank you

    <!--> REQUEST UPDATE
    < cfif isDefined "(form. UPDATEADDBTN") >
    < cfif FORM. GTE ENTID 1 >
    < cfset isCOMPANYNull = iif (len (trim (form.COMPANY)) EQ 0, true, false) >
    < cfset isCOMMENTSNull = iif (len (trim (form.COMMENTS)) EQ 0, true, false) >

    <!--> SET DATE AS FORM FIELD

    < cfset nxtstep = trim (form. ABUNDANCE) >

    <!-SET DATE IF NO DATE ENTERED->
    < cfif not isDate (nxtstep) >

    < cfif DayOfWeek (Now ()) eq 2 >
    < cfset nxtstep = dateAdd ("d", now())) 2, >

    < cfelseif DayOfWeek (Now ()) eq 3 >
    < cfset nxtstep = dateAdd ("d", now())) 2, >

    < cfelseif DayOfWeek (Now ()) eq 4 >
    < cfset nxtstep = dateAdd ("d", now())) 2, >

    < cfelseif DayOfWeek (Now ()) eq 5 >
    < cfset nxtstep = dateAdd ("d", now())) 4, >

    < cfelseif DayOfWeek (Now ()) eq 6 >
    < cfset nxtstep = dateAdd ("d", now())) 3, >

    < cfelseif DayOfWeek (Now ()) eq 7 >
    < cfset nxtstep = dateAdd ("d", now())) 2, >

    < cfelseif DayOfWeek (Now ()) eq 1 >
    < cfset nxtstep = dateAdd ("d", 1, now())) >
    < / cfif >

    <! - IF a DATE IS ENTERED CHECK TO SEE IF it IS a holiday - >

    < cfelse >

    <!-CHECK TO SEE if the DATE ENTRIES IS one day public HOLIDAY AND ADD DAYS-->
    < cfif ListFind (ValueList (hols.holiday), nxtstep) >

    < cfif DayOfWeek (nxtstep) eq 2 >
    < cfset nxtstep = dateAdd ("d", 2, nxtstep) >
    < cfelseif DayOfWeek (nxtstep) eq 3 >
    < cfset nxtstep = dateAdd ("d", 5, nxtstep) >
    < cfelseif DayOfWeek (nxtstep) eq 4 >
    < cfset nxtstep = dateAdd ("d", 2, nxtstep) >
    < cfelseif DayOfWeek (nxtstep) eq 5 >
    < cfset nxtstep = dateAdd ("d", 4, nxtstep) >
    < cfelseif DayOfWeek (nxtstep) eq 6 >
    < cfset nxtstep = dateAdd ("d", 6, nxtstep) >
    < cfelseif DayOfWeek (nxtstep) eq 7 >
    < cfset nxtstep = dateAdd ("d", 2, nxtstep) >
    < cfelseif DayOfWeek (nxtstep) eq 1 >
    < cfset nxtstep = dateAdd ("d", 1, nxtstep) >
    < / cfif >


    < / cfif >


    < / cfif >

    You do several things that can contribute to the problem.  In your first block of code, you use dateadd to assign to a variable datetime nxtstep.  In the following code block, you check to see if this datetime variable appears in a list.

    A list is just a delimited string, looking for datetime variables is doomed to failure unless you convert these variables in a string.  You can use dateformat for that.  Choose the right format should also fix your another of your variables of datetime whose part of the time, while your list of holidays is probably not.

    I remember vaguely similar issues on your part.  You should re-read the answers you got.  You may be ignoring some of them.

  • How to trigger the function when certain keys entered in the text field?

    Gidday

    I have a listener of stadium for keyboard events, that triggers a two function control the error for text field entries according to which the movieclip, the fields are.  Text in some movieclips trigger fields, a function that checks if the entry is between a certain digital interval, while the textfields in the other movieclips test to ensure that text fields are not left empty.

    It works very well apart from me not holding does not count another keyboard events that the letters, numbers, and signs of punctuation, or, among other things, the SHIFT key.

    So what is happening now is that the events of keyboard away from the numbers, letters and punctuation trigger an output error.

    I was wondering how to fix this?

    The listener that I use is:

    stage.addEventListener (KeyboardEvent.KEY_UP, KeyPressed);

    KeyPressed is a function that determines what error check its operation to run according to which window movieclip is open.

    Thank you for your help on this one.

    Shaun

    If you want it to be a little more optimized, you can create a wrapper class for the textfield and then you wouldn't add the event listener for each text field.

    class MyTextField extends TextField {}

    public void MyTextField() {}

    this.addEventListener (Event.CHANGE, eventhandler);

    }

    }

    In the form create instances of MyTextField instead of directly TextField.

    Concerning

    Knockaert

  • What does not restart in the FFT functions way?

    Hi all

    I would like to know what that "restart average" made for the FFT functions. According to aid,"reboot on average indicates if the VI restarts the process chosen medium." If restart on average is set to TRUE, the restart of the VI the selected with an average of process. If reboot on average is set to FALSE, the VI does not restart the process chosen sprawl. The default value is FALSE. When you call this VI for the first time, the averaging process restarts automatically. A typical case when you need to reboot on average is when a major change of entry occurs in the middle of the averaging process"

    I realized that the FFT function takes in an array of values and perform the FFT on it. If the FFT function keep a buffer previous values and clears when restart average = true? Because the FFT functions are not Point by point and they take both in all the data to deal with, "a major change of entry occurs in the middle of the averaging process" can be true?

    Thank you!

    Sigh.  I really tried to explain what was going on (probably) with this function, you use (and, I thought naively, you understand), but you got me wrong.

    This VI creates a zero average noise signal, providing 1024 points per second.  Do you know what should be the power spectrum of the signal?  Due to the randomness of the input signal, the power (for a small finished sample) spectrum will also have a random component.  If you had several ghosts of power on average, the average would begin to converge with the expected for random noise power spectrum.

    If you run this VI and look at the Spectra resulting (on average), you will notice that the first spectrum is the most "spice" and that spectra are averaged, the variation is reduced and diminishes the value of crete (shown by looking at the scale of Amplitude).  At any time, you can press "Reset average" and see this... reset the average, the following spectrum shows the growing nose, etc.

    It shows the right way to test the function of the power spectrum and discover what he does. My suggestion as to what makes this function seems to be largely correct.

    Bob Schor

  • The power spectral density function counts inaccurate amplitude caused by the window function?

    I'm new to this forum, so please let me know if this would correspond better to a different discussion forum.

    Here's the question:

    I would like to know if the power spectral density function ("FFT PSD for 1 Channel.vi") automatically compensates for the loss of the amplitude of entry caused by the window function.  In other words, is a specific window correction factor applied within the PSD vi or do I apply manually?

    Details of the background:

    I tried to answer the question myself by generating a sine wave sampling, it as it is periodic in record time (i.e. 0 to each end of recording time).  The frequency of the sine wave was such that the frequency would exactly correspond to a spectral line in the PSD.  Then I generated the PSD of the sine wave twice: once using a Hanning window and once using a rectangular window (not on average in both cases).  The rectangular extent of the PSD with windows to the frequency of the sine wave is 1.5 times the size of the PSD with a Hanning window applied.

    The experience above indicated to me that a manual setting of the PSD output for the function of window was necessary, however, I repeated the above experiment using random vibration data and does not clear 1.5 x factor.  I have also been informed by his colleagues that the PSD should set for the window function.

    Thank you for your comments.

    Spectral leakage.  When you use a finished sample data from the spectrum resulting is the convolution of the spectrum of the signal as if it extended indefinitely in time with the spectrum of the window.  Even if you do not use a window function, you actually have a rectangular window the same width as the sample size.

    Draw out of the VI PSD with all style of trace to show points to the data points. Turn off Auto scale on the X axis, and expand the graph around your pic. Look at the results of different windows.  In any case, there are several values non-null.  With actual sampled data of limited duration, you will never get the idealized line spectrum.

    If summarize you the output spectral value remains close to 3.2 for all windows.

    Lynn

  • How to trigger the value change in the structure of the event

    HII everyone, like the title, how should I trigger the value change event to display a message... Here is my connection... I want to trigger structure of the event to bring up the subvi, when the flame and the led are TRUE State... I have using the node property, but still not able to run event structure... How should I connect? Thank you very much...

    There are several ways you can do. First of all, you need to configure your sub - vi while he does everything you want when you run (in the properties of vi, top most window for example) and to make sure that it closes completely when you're done (when you click on the 'OK' button, for example).

    Spend you need an asynchronous call to the subvi. There are several ways to do so. My favorite one below. You go in the palette under 'Application control' and select a static reference VI. I like this approach because it keeps track of the way subvi for you, as long as the subvi is in the same project. Then, drag the sub - vi on the empty square which will be changes to your sub - vi icon. Then, you connect to an invoke node in the same palette under and select run VI. "Wait, that 's" set to false and the main VI will continue to function after the start of the vi of Sub. Together "Auto Ref" is the best way to go. Otherwise, you will need to follow the sub - vi reference and shut up yourself when you are finished.

  • How to return on a Subvi in a calling VI and does not stop the calling function

    I am writing a program which consists of a call VI and one under VI. I want to call function to run continuously and be able to trigger the sub VI (via activation of the voice). I want the sub VI to expire automatically after 10 seconds and return to the calling VI (master), which will continue until the sub VI is still called.

    I found a way to expire the sub VI using the 'stop' command, but he left the appellant VI also, which does not. I know there is no 'back' or 'soft stop' in LabVIEW, but someone he knows a way to do this?

    What you really need in your Subvi is something like what is shown below. You specify the delay using the delay function or get Date/Time In Seconds msec. would work in the same way.

  • Close Internet Explorer creates two elements of rundll32.exe * 32 on the list of the task manager that trigger the physical memory to 90-100%

    Close Internet Explorer creates two elements of rundll32.exe * 32 on the list of the task manager that trigger the physical memory to 90-100%

    You have IE set to 'delete browsing history leaving? "  Rundll32 (with a command line incorporating something in the sense of a call to a function ClearMyTracksByProcess in inetcpl.cpl) is generated to perform this action.

  • Use the button submit to trigger the validation and prompt to save instead of submit action

    I want to add a Submit button that will trigger the validation using the built-in functionality. This will work as well with the "validation of forms" setting on the properties of the form. See cliché below.

    However, if the validation success, I want to apply for registration dialog box instead actually submit the form using this line of code:

    app.execMenuItem("SaveAs");
    

    How is that possible?

    Tarek

    Hello

    to do this, you can simply call the function execValidate integrated, your form by using the following:

    var boValidate = xfa.form.form1.execValidate ();

    If {(boValidate)

    app.execMenuItem ("SaveAs");

    } else {}

    App.Alert ("Validation failed.");

    }

    I hope this will help you!

  • slow down the ENTER_FRAME function

    I use the ENTER_FRAME with Math.random function to animate / simulate a random track number, as you can see in a digital Voltmeter for example.

    the range goes from 12.0 to 12.9 and works well, but my problem is that I need to slow down the pace at which the numbers change... A lot.

    Y at - it anyway to do it without slowing down the entire timeline?

    Currently my ACE is limited to the movieclip digital volt.

    That's what I have:

    addEventListener (Event.ENTER_FRAME, fl_EnterFrameHandler_1);

    function fl_EnterFrameHandler_1(event:Event):void
    {
    var newVal:Number = 12 + (int (Math.random () * 10) / 10);
    Volt.Text = newVal.toString ();
    }

    -Pat

    You can use:

    var loops: int = 0;


    var int rate = 100;  //<- this="" controls="" the="" rate="" of="" updates="" to="">

    addEventListener (Event.ENTER_FRAME, fl_EnterFrameHandler_1);

    function fl_EnterFrameHandler_1(event:Event):void
    {

    If (% loops == 0) {}
    var newVal:Number = 12 + (int (Math.random () * 10) / 10);
    Volt.Text = newVal.toString ();

    }

    loops ++

    }

    -Pat

  • Realistic of the random movements of multiple MovieClips

    Hi here is my code:

    30 images/s

    var human = 30;

    hSpeed var = 4;

    for (i=0; i<humans; i++) {
         //attach movieclip with name "human"
         //give it a random x y position (there are now 30 scattered human MCs)
         _root["human"+i].onEnterFrame = function() {
              this._x += random(hSpeed); //Here is the 'random' movement of the Movieclips
              this._x -= random(hSpeed);
              this._y += random(hSpeed);
              this._y -= random(hSpeed);
                   //some more code
         }
    }
    

    Makes the jitter movieclips on, humans don't do that, I can't find a way to make their random movement still smooth, moving in a random direction for a few seconds (preferably a random amout of seconds), then to change direction - I found a way to do it but it does not work on individuals It works on all 30 movieclips, which means that all move in the same direction.

    Don't forget that the movement must be random for each individual movieclip, not all move in the same direction.

    Does anyone know how? Thank you

    If you want to maintain the movement in a random direction for some time, then you're probably better using code interpolation.  Generate interpolations for each object that moves them from their current position to some random in some random delays.  And have a listener that determines when the Tween is complete so that a new Tween is engaged with the new direction and speed (time).

  • How the get function is available or not on the loaded swf file

    I have 100 swf file in one of my projects. And there is a common feature in some of the SWFs. All these files are loadded in the file main.swf. Here's my Question, "If have the common function is the swf file that is loaded, int how to trigger this funciton of the main.swf.

    Quite simply,.

                if(movieclip.test){
                    movieclip.test();
                }
    

    ('movieclip' is the loaded SWF file and "test()" is the function)

  • Why is the hitTest function works only with attachmovie?

    Hello.

    I need help. I can't get the hitTest to work for my script below.

    I tested using movieclips created on stage at design-time and collided during execution. hitTest, works very well in this situation.

    But if I use the attachmovie command and create a movie on stage during the performance, the video cannot hitTest with other clips. The hitTest just doesn't work.

    Please help me by recommending changes. I don't know what to do. It is not that difficult.

    Thank you.

    -Aslan

    """"""""""""""""""""

    The script below is essentially to create instances of enemymc, and he will fall vertically, hitting a movieclip target_mc which is set at design time. Please help, out of ideas.

    """""""""""""""""""""

    var enemyTime:Number = 0;

    var enemyLimit:Number = 20;

    onEnterFrame = Function)

    {

    enemyTime ++;

    trace (enemyTime);

    if(enemyTime == enemyLimit)

    {

    var enID: Number = Math.Random ();

    enemy_mc = _root.attachMovie ('enemymc', 'en' + enID, _root.getNextHighestDepth ());

    ["fr" + enID] _root ._x = int (Math.random () * Stage.width);

    _root ["fr" + enID] ._y = - 5;

    _root ["fr" + enID] .onEnterFrame = function()

    {

    var chk:Boolean = false;

    var currMov:MovieClip;

    ce ._y += 5 ;

    currMov = this;

    if (this.hitTest (_root.target_mc, true))

    {

    trace ("the enemy detected a success.");

    }

    if (this ._y > (Stage.height - 10))

    {

    this.removeMovieClip ();

    }

    }

    enemyTime = 0;

    }

    }

    If you have two targets mc then they must have different instance names and you must hitTest for each of them.

    If (this.) HitTest (target_mc1) | this.hitTest (target_mc2))
    {
    trace ("the enemy detected a success.");
    }

    And if you need to deal with them in different ways depending on who gets the success, just use two separate tests.

    As far as why my way and not your way, I have to be honest and say that I spent time trying to get your way to work and by trial and error, I ended up with, that's what you see.  I thought that the biggest change took place (which means he started work) when I changed the hitTest to not include the "true" setting, which I think is applicable to the use of corrdinates, and not an object.  But when I started your code and changed only this line, it still does not work, so something else in my revised code also applies.

    I didn't like using the random calculation for falling objects, which may have been part of the problem.  That will produce a fractional value with a point decimal, and names of the instance with dots in them are probably an accident waiting to happen (ex: en0.27365514)

    If you want to know what changes were absolutely necessary for its work, start with your code and the hitTest change first and then see what must be done to get things working properly.  I was tempted, but I had other things I wanted to do, so I got what I got the job.

Maybe you are looking for

  • I can't get Firefox on my MacBookPro, my user profile is not available. Help!

    I got a message at the bottom of my screen telling me that my navigation could be faster if I "refreshed" Firefox, so I refreshed. I lost my favorites and a few other things (I forgot it would happen) and the thought restart my MacBookPro could recei

  • NB200 won't connect to the wireless

    Ther machine appears unable to display the connectioin wireless...Even if my mobile phones can display and connect... Is there something - really, you hope as a mini computer laptop hsd st less the connectibility of a mobile phone?The connection at h

  • M91p ((modèle 4524) will not sleep)

    Hi - I wonder if anyone can help me with this problem - I got a M91p Tower (model 4524) for a couple of years - has decided to upgrade to Windows 8.1 and operate using the UEFI. I installed Windows 8.1 with the game to the mobo in the UEFI but cannot

  • Can not get CC Installer to initialize

    I downloaded CC on my computer this morning, but I had to do a reset a restore point previous to a few days ago and lost my CC.  Now it does allow me to download again. When I try to run the installer it just stops. I searched through the help pages

  • New user lost. Need of simple questions answered

    I received a short time trying to configure vmware 5 for virtualizing office in a university setting. Especially for our laboratories and public machines. I have a few thin clients from Wyse, I can try with DellWe are a single network MS most of the