从脚本AS3创建XML文件

发布于 2025-01-25 00:40:31 字数 4462 浏览 2 评论 0原文

我无法弄清楚如何从语言图像中获取更多XML文件,

setUpitems如何构建

在这里,它解释了我如何构建缺失的xml文件,但我不明白我如何正确构建它将在网站上对我有效

public function init(param1:int) : void
  {
     var _loc2_:String = null;
     this.itemHolder.addChild(this.hairHolder);
     this.itemHolder.addChild(this.shirtHolder);
     this.shirtHolder.visible = false;
     this.itemHolder.addChild(this.pantsHolder);
     this.pantsHolder.visible = false;
     this.itemHolder.addChild(this.shoesHolder);
     this.shoesHolder.visible = false;
     this.activeHolder = this.hairHolder;
     this.initButtons();
     this.randomTimer = new Timer(this.randomTimerInitDelay,this.randomTimerCount);
     this.randomTimer.addEventListener(TimerEvent.TIMER,this.changeRandomClothes,false,0,true);
     this.xml = new XML();
     if(param1 == 1)
     {
        _loc2_ = "boyItems.xml";
     }
     else if(param1 == 2)
     {
        _loc2_ = "girlItems.xml";
     }
     this.xmlLoader = new URLLoader(new URLRequest("./website/common/register/xmls/" + _loc2_));
     this.xmlLoader.addEventListener(Event.COMPLETE,this.xmlLoaded);
     this.xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,this.errorLoadingXml);
  }

另一个代码

private function xmlLoaded(param1:Event) : void
  {
     this.xmlLoader.removeEventListener(Event.COMPLETE,this.xmlLoaded);
     this.xmlLoader.removeEventListener(IOErrorEvent.IO_ERROR,this.errorLoadingXml);
     this.xml = XML(this.xmlLoader.data);
     Register.AVATAR_HAIR = this.xml.hair.child(0).@id;
     var _loc2_:int = Math.random() * 2 + 1;
     this.bubble.gotoAndStop("hair_" + Register.language + _loc2_);
     this.setupItems(this.xml.hair,this.hairItems,this.hairHolder);
     this.setupItems(this.xml.shirt,this.shirtItems,this.shirtHolder);
     this.setupItems(this.xml.pants,this.pantsItems,this.pantsHolder);
     this.setupItems(this.xml.shoes,this.shoesItems,this.shoesHolder);}

  
  private function setupItems(param1:*, param2:Array, param3:Sprite) : void
  {
     var _loc9_:* = undefined;
     var _loc10_:Item = null;
     var _loc4_:int = 54.5;
     var _loc5_:Number = 64.5;
     var _loc6_:*;
     var _loc7_:int = (_loc6_ = param1).children().length();
     var _loc8_:int = 0;
     while(_loc8_ < _loc7_)
     {
        _loc9_ = _loc6_.child(_loc8_);
        (_loc10_ = new Item()).x = _loc4_;
        _loc4_ += this.itemSpacing;
        _loc10_.y = _loc5_;
        _loc10_.loadItem(_loc9_.@type,_loc9_.@ordinal,_loc9_.@id,_loc9_.@inventoryType,Register.pathToItemsFolder);
        param2.push(_loc10_);
        param3.addChild(_loc10_);
        _loc8_++;
     }
  }

loadItem 文件:
(也许在这里您可以看到我如何构建XML文件)

public function loadItem(param1:int, param2:int, param3:int, param4:int, param5:String) : void
  {
     this.type = param1;
     this.ordinal = param2;
     this.id = param3;
     this.itemImage = new ImageItemNoCache(param1,param2,param3,param4,null,null,param5);
     this.itemImage.mouseEnabled = false;
     this.itemImage.mouseChildren = false;
     this.itemImage.addEventListener(ImageItem.DATA_LOADED,this.positionImage,false,0,true);
     addChild(this.itemImage);
     addEventListener(MouseEvent.CLICK,this.clickedMe,false,0,true);
  }

代码 imageitemnocache

public class ImageItemNoCache extends ImageItem
{
    private var textData:Object;

    private var itemData:Object;

    private var pathToItemsFolder:String;

    public function ImageItemNoCache(param1:int, param2:int, param3:int, param4:int, param5:Object = null, param6:Object = null, param7:String = ".")
    {
        this.textData = param5;
        this.itemData = param6;
        this.pathToItemsFolder = param7;
        super(param1,param2,param3,param4);
    }

    override protected function getImageItemData(param1:int, param2:int = -1, param3:int = -1, param4:int = -1) : ImageItemData
    {
        return new ImageItemDataNoCache(param1,param2,param3,param4,this.textData,this.itemData,this.pathToItemsFolder);
    }

    override public function clone() : DisplayItem
    {
        return new ImageItemNoCache(getType(),getOrdinal(),getId(),getInventoryType(),this.textData,this.itemData,this.pathToItemsFolder);
    }
}

I can not figure out how I get more XML file from the language images,

In the image here you will look at setupItems how it is built

Here it explains how I build the missing XML file but I do not understand how I build it properly that will work for me on the site

public function init(param1:int) : void
  {
     var _loc2_:String = null;
     this.itemHolder.addChild(this.hairHolder);
     this.itemHolder.addChild(this.shirtHolder);
     this.shirtHolder.visible = false;
     this.itemHolder.addChild(this.pantsHolder);
     this.pantsHolder.visible = false;
     this.itemHolder.addChild(this.shoesHolder);
     this.shoesHolder.visible = false;
     this.activeHolder = this.hairHolder;
     this.initButtons();
     this.randomTimer = new Timer(this.randomTimerInitDelay,this.randomTimerCount);
     this.randomTimer.addEventListener(TimerEvent.TIMER,this.changeRandomClothes,false,0,true);
     this.xml = new XML();
     if(param1 == 1)
     {
        _loc2_ = "boyItems.xml";
     }
     else if(param1 == 2)
     {
        _loc2_ = "girlItems.xml";
     }
     this.xmlLoader = new URLLoader(new URLRequest("./website/common/register/xmls/" + _loc2_));
     this.xmlLoader.addEventListener(Event.COMPLETE,this.xmlLoaded);
     this.xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,this.errorLoadingXml);
  }

another code

private function xmlLoaded(param1:Event) : void
  {
     this.xmlLoader.removeEventListener(Event.COMPLETE,this.xmlLoaded);
     this.xmlLoader.removeEventListener(IOErrorEvent.IO_ERROR,this.errorLoadingXml);
     this.xml = XML(this.xmlLoader.data);
     Register.AVATAR_HAIR = this.xml.hair.child(0).@id;
     var _loc2_:int = Math.random() * 2 + 1;
     this.bubble.gotoAndStop("hair_" + Register.language + _loc2_);
     this.setupItems(this.xml.hair,this.hairItems,this.hairHolder);
     this.setupItems(this.xml.shirt,this.shirtItems,this.shirtHolder);
     this.setupItems(this.xml.pants,this.pantsItems,this.pantsHolder);
     this.setupItems(this.xml.shoes,this.shoesItems,this.shoesHolder);}

  
  private function setupItems(param1:*, param2:Array, param3:Sprite) : void
  {
     var _loc9_:* = undefined;
     var _loc10_:Item = null;
     var _loc4_:int = 54.5;
     var _loc5_:Number = 64.5;
     var _loc6_:*;
     var _loc7_:int = (_loc6_ = param1).children().length();
     var _loc8_:int = 0;
     while(_loc8_ < _loc7_)
     {
        _loc9_ = _loc6_.child(_loc8_);
        (_loc10_ = new Item()).x = _loc4_;
        _loc4_ += this.itemSpacing;
        _loc10_.y = _loc5_;
        _loc10_.loadItem(_loc9_.@type,_loc9_.@ordinal,_loc9_.@id,_loc9_.@inventoryType,Register.pathToItemsFolder);
        param2.push(_loc10_);
        param3.addChild(_loc10_);
        _loc8_++;
     }
  }

This is the loadItem file:
(Maybe here you can see how I build the XML files)

public function loadItem(param1:int, param2:int, param3:int, param4:int, param5:String) : void
  {
     this.type = param1;
     this.ordinal = param2;
     this.id = param3;
     this.itemImage = new ImageItemNoCache(param1,param2,param3,param4,null,null,param5);
     this.itemImage.mouseEnabled = false;
     this.itemImage.mouseChildren = false;
     this.itemImage.addEventListener(ImageItem.DATA_LOADED,this.positionImage,false,0,true);
     addChild(this.itemImage);
     addEventListener(MouseEvent.CLICK,this.clickedMe,false,0,true);
  }

Code for ImageItemNoCache:

public class ImageItemNoCache extends ImageItem
{
    private var textData:Object;

    private var itemData:Object;

    private var pathToItemsFolder:String;

    public function ImageItemNoCache(param1:int, param2:int, param3:int, param4:int, param5:Object = null, param6:Object = null, param7:String = ".")
    {
        this.textData = param5;
        this.itemData = param6;
        this.pathToItemsFolder = param7;
        super(param1,param2,param3,param4);
    }

    override protected function getImageItemData(param1:int, param2:int = -1, param3:int = -1, param4:int = -1) : ImageItemData
    {
        return new ImageItemDataNoCache(param1,param2,param3,param4,this.textData,this.itemData,this.pathToItemsFolder);
    }

    override public function clone() : DisplayItem
    {
        return new ImageItemNoCache(getType(),getOrdinal(),getId(),getInventoryType(),this.textData,this.itemData,this.pathToItemsFolder);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文