我意外地偶然發現了一個項目,其中PHP不是一個選項使用閃光燈,不幸的是我已經到了一個點,我需要編輯一個小動作,它超出了我。問題與actionscript 3和xml
的XML看起來像這樣(我知道這是愚蠢的,但它已經綁成將刺激重寫一些PHP解析功能!)
<project>
<project_1>
<name>Place name</name>
<other>sample</other>
</project_1>
<project_2>
<name>Place name</name>
<other>paragraph of text</other>
</project_2>
</project>
我想編輯從閃存中的XML編輯器的界面2,下面是相關的代碼。我需要在節點名稱後包含名稱文本,所以它會在編輯器的相關選項卡上讀取project_2地名。我試過的編輯已被評論。任何幫助將不勝感激!
湯姆
public class ClassicXMLNode extends MovieClip implements IEventDispatcher{
public var XMLData:XML;
public var isRoot:Boolean = false;
public var num:Number;
public var nodeName:String;
public var nodePath:String; // This will track the path throughout the XML document
public var childrenNodes:XMLList;
public var numNodes:uint;
public var childHolder:MovieClip;
public var isOpen:Boolean = false; // Tracks whether the nodes data is opened or closed
public static var moveDistance:Number; // This will be used for recursive loops : opening and closing sections
public function ClassicXMLNode(Data:XML, nodeNum:Number, xmlPath:String = null) {
XMLData = Data;
num = nodeNum;
xmlPath ? nodePath = xmlPath : nodePath = "";
nodeName = XMLData.name();
nodePath += "." + nodeName;
//trace(nodePath);
addEventListener(Event.ADDED_TO_STAGE, addedListener);
}
public function addedListener(e:Event):void {
//I added the var project
var project:String = XMLData.project*.name.text();
//Load the XMLData
//and tried to concatenate it here
nodeName_txt.text = XMLData.name + project();
childrenNodes = XMLData.children();
numNodes = childrenNodes.length();
//Create the holder for childNodes
childHolder = new MovieClip();
childHolder.y = ClassicTree.nodeSpacing;
childHolder.x = 50;
addChild(childHolder);
// Event Listeners
openButton.buttonMode = true;
openButton.tabEnabled = false;
openButton.addEventListener(MouseEvent.CLICK, _click);
numNodes == 0 ? openButton.visible = false : null;
this.addEventListener(MouseEvent.MOUSE_OVER, hideActionMenu);
this.addEventListener(MouseEvent.MOUSE_OUT, hideActionMenu);
hideActionMenu();
moveButtonCheck();
}
很酷,謝謝,看起來像一個更好的做事方式。不幸的是,我正在編輯一個更大的應用程序的一部分,所以它不太配合。我只是想了解它,但請看下面... :) – Tom 2010-06-23 11:26:59