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

Adding items in an Array

Community Beginner ,
Jan 15, 2015 Jan 15, 2015

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
457
Translate
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

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

Translate
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

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

Translate
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

It won't compile...

Translate
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

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.

Translate
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

Got it..

Thank you guys for your valuable suggestions..

Translate
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

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

Translate
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
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.

Translate
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