Ik zit al een tijdje met een vaag probleem in Actionscript.
Het is de bedoeling om letters neer te zetten volgens in een XML file opgegeven x en y coords.
Op zich gaat het goed, alleen worden de movieclips gepositioneert in de linker bovenhoek (0,0).
Oftewel, ze reageren niet op _x en _y.
En als ik dit doe:
... werkt het wel, maar dus niet volgens de door mij gewenste xpos en ypos.
Ik heb zitten kloten met depths, daar ligt het m.i. niet aan.
Ook een setInterval (beetje vertraging), showAlphabet op 2e frame, en een onLoad werkten niet..
Iemand een tip waar ik moet kijken?
Het is de bedoeling om letters neer te zetten volgens in een XML file opgegeven x en y coords.
Op zich gaat het goed, alleen worden de movieclips gepositioneert in de linker bovenhoek (0,0).
Oftewel, ze reageren niet op _x en _y.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| Stage.align = "TL";
Stage.scaleMode = "noScale";
var container:MovieClip = _root.container;
var charArr:Array = new Array();
xmldoc = new XML();
xmldoc.ignoreWhite = true;
xmldoc.load("http://localhost/get_alphabet.php");
xmldoc.onLoad = function(success) {
if (success) {
rootnode = xmldoc.firstChild.childNodes;
for (m=0; m<rootnode.length; m++) {
temp = rootnode[m];
this["charObject"+id] = new Object();
this["charObject"+id].id = temp.attributes.id;
this["charObject"+id].char = temp.childNodes[0].firstChild;
this["charObject"+id].xpos = temp.childNodes[1].firstChild;
this["charObject"+id].ypos = temp.childNodes[2].firstChild;
charArr.push(this["charObject"+id]);
}
showAlphabet();
}
};
function showAlphabet() {
trace("charArr.length = "+charArr.length);
for (var i = 0; i<charArr.length; i++) {
var tid = charArr[i].id;
container.attachMovie("mc_char_"+charArr[i].char, "char"+tid, container.getNextHighestDepth());
container["char"+tid].id = charArr[i].id;
container["char"+tid].char = charArr[i].char;
container["char"+tid]._x = charArr[i].xpos; // GEEN REACTIE
container["char"+tid]._y = charArr[i].ypos; // GEEN REACTIE
trace("char:"+charArr[i].char+" | "+charArr[i].xpos+" | "+charArr[i].ypos); // xpos EN ypos HEBBEN WEL WAARDES
container["char"+tid].onPress = function() {
this.swapDepths(container.getNextHighestDepth());
this.startDrag();
};
container["char"+tid].onRelease = function() {
this.stopDrag();
trace(this+" | "+this._x+" | "+this._y+" | "+this.char); // HIER OOK
};
container["char"+tid].onReleaseOutside = function() {
this.stopDrag();
};
}
} |
En als ik dit doe:
code:
1
2
| container["char"+tid]._x = random(Stage.width); // WEL REACTIE
container["char"+tid]._y = random(Stage.height); // WEL REACTIE |
... werkt het wel, maar dus niet volgens de door mij gewenste xpos en ypos.
Ik heb zitten kloten met depths, daar ligt het m.i. niet aan.
Ook een setInterval (beetje vertraging), showAlphabet op 2e frame, en een onLoad werkten niet..
Iemand een tip waar ik moet kijken?