Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:40:34+00:00 2026-06-09T09:40:34+00:00

Working example is here (this script deals with the triangle animation) http://movable.pagodabox.com/ full code

  • 0

“Working” example is here (this script deals with the triangle animation)

http://movable.pagodabox.com/

full code here: http://pastebin.com/rgPNxHgJ

This question is mainly about the proper syntax. I have the following:

shape.transitionTo({
     offset: {
          x: 10,
          y: 10
     }
})

What I want to do is have “x” and “y” be randomly selected from an array, for example:

    movementIn = [
        {x: 34, y: 66},
        {x: -34, y: -66}
    ],

    shape.transitionTo({
        offset: movementIn[Math.floor(Math.random() * movementIn.length)],
    });

But this doesn’t seem to be working… it seems to be only choosing the first item every time. Am I doing something wrong here?

how do I select a random X and Y pair and insert it into the “offset” parameter?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:40:36+00:00Added an answer on June 9, 2026 at 9:40 am

    “Works for me”

    arr = ["a","b","c"]
    res = ""
    for (i = 0; i < 10; i++) {
       res += arr[Math.floor(Math.random() * arr.length)]
    }
    alert(res)
    

    Do note that this is not the “correct” way to pick one item as the distribution is slightly skewed ..

    There are some syntax and semantical issues with the code in the question that should be explored:

    {
       although_SomeBrowsers: "accept me",
       iAmAnInvalidLiteral: "BecauseThereIsAnExtraComma",
    }
    

    I feel trolled, here you go:

    arr = [{x:1,y:-1},{x:2,y:-2},{x:3,y:-3}]
    for (i = 0; i < 10; i++) {
       AN_OBJECT = arr[Math.floor(Math.random() * arr.length)]
       // do whatever you want to do with what AN_OBJECT names
       alert("x: " + AN_OBJECT.x + " y: " + AN_OBJECT.y)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
I'm working on a jquery carousel. You can see the example here: http://jsfiddle.net/6fwbS/2/ Click
I am working through the example from https://blogs.oracle.com/arungupta/entry/java_ee_6_and_nosql . Here is a link to
Working Example: This is almost identical to code I use in another places on
I've this NGINX rewrite URL: if ($http_host !~ ([a-zA-Z0-9.-]+)\.example\.com(.+)) { rewrite ^ http://example.com/browse.php?u=http://$1$2? permanent;
I'm working on a stored proc that executes some dynamic sql. Here's the example
UPDATE: This is the working example. First we create a class to hold weekday,
I had this working in prototype.js but it conflicted with a few script files.
I have a semi-working example that you can look at. This appears to work
I'm looking on Entity Framework at the moment and working with Code First example.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.