flash - Actionscript strange coords after removeChild is called -


Can someone help me to understand the meaning of the following?

(x = 0, y = 0, w = 208, h = 40) 0 208 (x = 42, y = 0, w = 166, h = 40) 0 166

The X coordinate is still 0, although the width has changed, getBounds correct value I hope I have to change X also. The wrong values ​​of X, globalToLocal and localToGlobal work incorrectly.

If you click anywhere on the left side of the rectangle of another (still visible) you should:

2 28 (x = 2, y = 28)

Whatever is good for nothing, values ​​in brackets should be in phase and they are not.

code:

  public function test (): zero {var s: Sprite; Var i: int; Var arr: array = new array (); For (i = 0; i <5; ++ i) {s = new sprite ()); S.graphics.beginFill (0x999); S.graphics.drawRect (0, 0, 40, 40); S.graphics.endFill (); S.x = i * 42; Arr.push (s); AddChild (s); } Trace (this.getBounds (phase), x, width); RemoveChild (Advent [0]); Advent [0] = Faucet; Trace (this.getBounds (stage), x, width); AddEventListener (MouseEvent.CLICK, click); } Click Private Function (e: MouseEvent): Zero {e.localX, e.localY, localToGlobal (new point (e.localX, e.localY)); }  

You are confused at two different points, but I think that Each stem has an incomplete view of Flash with the coordinate systems from each stem. Remember that each display object is around its own coordinate system In its first question, the "X" and "Y" properties of an object are over the top of the object - Dynamically c to reflect the left corner They are not considered, they show the location of the origin of that object in relation to the coordinate system of that origin. Therefore, the "x" value of an object does not change just because the object's content changes - it changes when you move an object.

The problem with your step coordinates is that the localToGlobal method coordinates with the scope in which it is called - and you are calling it from parents of rectangles, But you are passing in the coordinates from the local system inside the rectangular. For some, beware of the following and understand it:

  function click (e: MouseEvent): zero {// bad - rectangular within the scope of "this" // trace (e) Uses. LocalX, E. Local, localtwo global (new point (e.loclux, e.localysis))); // works - Localization through the scope of the rectangle trace (e.target.localToGlobal (new point (e.localX, e.localY)); // Optionally, with the coordinates taken from that area Call it to any radius: Trace (local point Globoble (new point, mousex, mice)); trace (e.target.localToGlobal (new point (e.target.mouseX, e.target.mouseY));}  

Update: This part of the misleading is how eventbuilding works in AS3. Read some paragraphs before getting the original idea, and then understand that in this example the event is initially released from a rectangle (because that graphic has been clicked on), but you only catch them because they are scope The bubble through which you set your listener is the e.target rectangle, and e.currentTarget is the scope of your audience. Then the last piece of the puzzle is that e.localX and is e.localY always coordinate system of the original target of the event. (The reason for this is that they are the attributes of this phenomenon, and this phenomenon is not understood to change because the performance list is picked up.)

As the last note, if You are wondering how beginners usually face this stuff, the answer is that people usually engage viewers directly with the displayed object, which has graphical content, which will be clicked. In that case, e.target and e.currentTarget will always be the same, and most beginners will not need to understand any of its topics.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -