• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adding items in an Array

Community Beginner ,
Jan 15, 2015 Jan 15, 2015

Copy link to clipboard

Copied

Hello friends!

I got a code which was responsible for some drag and drop items. In the code there i saw there was created an array named "positionArray" and two values(X and Y position of an item) are added, you can see in red highlighted area. But i dont't know why word "xPos" and "yPos" are used here in the red highlighted area, and What are they..can anybody please tell me..??

Capture.PNG

Thank you..

TOPICS
ActionScript

Views

421

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2015 Jan 15, 2015

Copy link to clipboard

Copied

The {} notation creates a new Object. "xPos" and "yPos" are simply the identifiers given to properties of that object.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 16, 2015 Jan 16, 2015

Copy link to clipboard

Copied

What will happen if i remove those highlighted words and only use "dropArray.x, dropArray.y"..??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 16, 2015 Jan 16, 2015

Copy link to clipboard

Copied

It won't compile...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2015 Jan 16, 2015

Copy link to clipboard

Copied

Yep. That'll break it. Objects work by having you assign values to property references - and you are removing those references so it isn't assigning those values to anything. You could do that in the case of an Array - but you should probably stick with how the code was developed and use an Object.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

Got it..

Thank you guys for your valuable suggestions..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 22, 2015 Jan 22, 2015

Copy link to clipboard

Copied

Pop04 wrote:

What will happen if i remove those highlighted words and only use "dropArray.x, dropArray.y"..??

In that case it will push both the x value and the y value into the array, as numbers. You'd end up with an array with a bunch of numbers in it -- 2 numbers for every object in dropArray. That could be a way to do it, but the problem is code elsewhere is surely expecting to find objects in the array with xPos and yPos properties, so it would break.

-Aaron

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 23, 2015 Jan 23, 2015

Copy link to clipboard

Copied

LATEST

you mean every time whenever an object is selected, its x and y postions are stored in that array and so on..Afterall array gets a lot of values as a number in it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines