4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-fx-target-Sprite'>/**
19 </span> * @class Ext.fx.target.Sprite
20 * @extends Ext.fx.target.Target
22 This class represents a animation target for a {@link Ext.draw.Sprite}. In general this class will not be
23 created directly, the {@link Ext.draw.Sprite} will be passed to the animation and
24 and the appropriate target will be created.
29 Ext.define('Ext.fx.target.Sprite', {
31 /* Begin Definitions */
33 extend: 'Ext.fx.target.Target',
39 getFromPrim: function(sprite, attr) {
41 if (attr == 'translate') {
43 x: sprite.attr.translation.x || 0,
44 y: sprite.attr.translation.y || 0
47 else if (attr == 'rotate') {
49 degrees: sprite.attr.rotation.degrees || 0,
50 x: sprite.attr.rotation.x,
51 y: sprite.attr.rotation.y
55 o = sprite.attr[attr];
60 getAttr: function(attr, val) {
61 return [[this.target, val != undefined ? val : this.getFromPrim(this.target, attr)]];
64 setAttr: function(targetData) {
65 var ln = targetData.length,
67 attrs, attr, attrArr, attPtr, spritePtr, idx, value, i, j, x, y, ln2;
68 for (i = 0; i < ln; i++) {
69 attrs = targetData[i].attrs;
71 attrArr = attrs[attr];
73 for (j = 0; j < ln2; j++) {
74 spritePtr = attrArr[j][0];
75 attPtr = attrArr[j][1];
76 if (attr === 'translate') {
82 else if (attr === 'rotate') {
92 degrees: attPtr.degrees,
97 else if (attr === 'width' || attr === 'height' || attr === 'x' || attr === 'y') {
98 value = parseFloat(attPtr);
103 idx = Ext.Array.indexOf(spriteArr, spritePtr);
105 spriteArr.push([spritePtr, {}]);
106 idx = spriteArr.length - 1;
108 spriteArr[idx][1][attr] = value;
112 ln = spriteArr.length;
113 for (i = 0; i < ln; i++) {
114 spritePtr = spriteArr[i];
115 spritePtr[0].setAttributes(spritePtr[1]);
117 this.target.redraw();