【发布时间】:2010-06-22 14:19:09
【问题描述】:
我不小心在一个无法选择 php 的项目中使用了 flash,不幸的是,我已经到了需要编辑一些动作脚本的地步,这超出了我的能力。
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>
我正在尝试从 Flash xml 编辑器 2 编辑界面,下面是相关代码。我需要在节点名称之后包含名称文本,因此它会在编辑器的相关选项卡上显示 project_2 Place name。我尝试的编辑已被评论。任何帮助将不胜感激!
汤姆
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();
}
【问题讨论】:
标签: xml flash actionscript-3