How to Save X Y Position Object in Variable and in Array by AS3?

一笑奈何 提交于 2020-01-17 23:10:04

问题


how to put Value for X and Y Position in Variable and Array

object = (XPosition , YPosition) box_mc.x = 300 , box_mc.y = 200


回答1:


Try to improve your question.

Is that what you wanna do?

import flash.geom.Point;

var p:Point = new Point(200,300);
box_mc.x = p.x;
box_mc.y = p.y;

You may also store your values in a bi-dimensional Array as here bellow :

var a:Array = [[200,300],[150,200]];
box_mc.x = a[0][0]; //200
box_mc.y = a[0][1]; //300

or in this case as you have stored two values for posx and posy :

box_mc.x = a[1][0]; //150
box_mc.y = a[1][1]; //200

You may also check those links to understand the difference between the different kind of types where you may store values :

ActionScript 3 fundamentals: Arrays

ActionScript 3 fundamentals: Associative arrays, maps, and dictionaries

ActionScript 3 fundamentals: Vectors and ByteArrays



来源:https://stackoverflow.com/questions/39375530/how-to-save-x-y-position-object-in-variable-and-in-array-by-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!