Author: | Monday, January 7, 2008 | (0) comments
-fla
function drawXML() {
for(mc in _root.drawarea) {
removeMovieClip(_root.drawarea[mc]);
}
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(success) {
if(success) {
var count = 0;
var root = this.firstChild;
for(var node = root.firstChild; node != null; node = node.nextSibling) {
var x = node.attributes.x;
var y = node.attributes.y;
var p = _root.drawarea.attachMovie("point", "p" + _root.count++, _root.drawarea.getNextHighestDepth());
p._x = x;
p._y = y;
p.onRelease = function() {
_root.sendToPHP(this._x, this._y);
}
}
}
}
xml.load("test.xml");
}
function sendToPHP(x, y) {
var lv = new LoadVars();
var lv2 = new LoadVars();
lv.x = x;
lv.y = y;
lv2.onLoad = function(success) {
if(success) {
_root.drawXML();
}
}
lv.sendAndLoad("deletexml.php", lv2, "POST");
}
drawXML();
-php
$x = $_POST['x'];
$y = $_POST['y'];
$xml = domxml_open_file("test.xml");
$root = $xml->document_element();
$nodes = $root->child_nodes();
foreach($nodes as $node) {
$attrs = $node->attributes();
foreach($attrs as $attr) {
if($attr->name == "x" && $attr->value == $x) {
foreach($attrs as $attr) {
if($attr->name == "y" && $attr->value == $y) {
$root->remove_child($node);
$xml->dump_file('test.xml');
echo "success";
}
}
}
}
}
(0) comments: