Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex/AS3-有人知道如何获取AS3显示列表并从中创建mxml吗?_Apache Flex_Actionscript 3_Mxml_Transform - Fatal编程技术网

Apache flex Flex/AS3-有人知道如何获取AS3显示列表并从中创建mxml吗?

Apache flex Flex/AS3-有人知道如何获取AS3显示列表并从中创建mxml吗?,apache-flex,actionscript-3,mxml,transform,Apache Flex,Actionscript 3,Mxml,Transform,我一直在努力研究如何从应用程序中创建的显示列表构建mxml。例如,在画布上创建多个组件,然后单击按钮以获取画布及其属性的格式化xml文档(mxml) 有没有一个简单的方法 非常感谢您的帮助……没有简单的方法可以肯定 编辑: 这背后的原因是mxml实际上被翻译成actionscript,然后进行编译。因此,flash player对mxml及其存在一无所知。没有简单的方法可以肯定 编辑: 这背后的原因是mxml实际上被翻译成actionscript,然后进行编译。因此,flash player对m

我一直在努力研究如何从应用程序中创建的显示列表构建mxml。例如,在画布上创建多个组件,然后单击按钮以获取画布及其属性的格式化xml文档(mxml)

有没有一个简单的方法


非常感谢您的帮助……

没有简单的方法可以肯定

编辑
这背后的原因是mxml实际上被翻译成actionscript,然后进行编译。因此,flash player对mxml及其存在一无所知。

没有简单的方法可以肯定

编辑
这背后的原因是mxml实际上被翻译成actionscript,然后进行编译。因此,flash player对mxml及其存在一无所知。

了解更多背景知识会有所帮助,比如为什么需要这样做。据我所知,没有一个简单的或内置的方法来做到这一点

以下是一个可能有帮助的方向:

  • 为应用程序支持的每种类型的DisplayObject嵌入明文mxml模板文件。(模板文件,其中每个属性都有一个变量可与字符串插值交换,例如:mx:HRule height=“{$hRuleHeight}”width=“${hRuleWidth}”/

  • 每次编辑/创建对象时,保存信息---当需要生成mxml时,对每个保存的项进行排序,获取属性并用它们解析模板。AS3不支持字符串插值,如果您自己没有,下面是一个实现

用法:

var示例:StringInterpolation=new StringInterpolation();
setKeyAndValue('${id}','foo');
示例.setKeyAndValue('${baseurl}','http://testing123');
跟踪(例如,eval(“”));
/*产出:*/
src:

//

包com.philipbroadway.utils
{
公共类StringObject
{
内部变量键:数组;
内部变量值:数组;
内部变量结果:字符串;
内部变量i:uint;
/**
* 
* 
*/        
公共职能()
{
_键=[];
_值=[];
}
/**
* 
*@param key:String变量名
*@param value:String在求值过程中找到密钥时要替换的值
* 
*/        
公共函数setKeyAndValue(键:字符串,值:字符串):void
{
变量元字符:数组=[];
push(新的RegExp(/\$/);
push(newregexp(/\{/);
push(newregexp(/\}/);
push(newregexp(/\^/);
push(新的RegExp(/\./);
push(新的RegExp(/\*/);
push(新的RegExp(/\+/);
变量替换:数组=[];
push(新字符串(“\\$”);
push(新字符串('\\{');
push(新字符串('\\}');
push(新字符串('\\^');
replacements.push(新字符串('\\.');
replacements.push(新字符串('\\*');
push(新字符串('\\+');

对于(i=0;i来说,了解更多关于这方面的背景知识会有所帮助,比如为什么需要这样做。据我所知,没有一种简单或内置的方法可以做到这一点

以下是一个可能有帮助的方向:

  • 为应用程序将支持的每种类型的DisplayObject嵌入明文mxml模板文件。(每个属性都有一个变量可与字符串插值交换的模板文件例如:mx:HRule height=“{$hRuleHeight}”width=“${hRuleWidth}”/

  • 每次编辑/创建对象时,保存信息---当需要生成mxml时,对每个保存的项进行排序,获取属性并用它们解析模板。AS3不支持字符串插值,如果您自己没有,下面是一个实现

用法:

var示例:StringInterpolation=new StringInterpolation();
setKeyAndValue('${id}','foo');
示例.setKeyAndValue('${baseurl}','http://testing123');
跟踪(例如,eval(“”));
/*产出:*/
src:

//

包com.philipbroadway.utils
{
公共类StringObject
{
内部变量键:数组;
内部变量值:数组;
内部变量结果:字符串;
内部变量i:uint;
/**
* 
* 
*/        
公共职能()
{
_键=[];
_值=[];
}
/**
* 
*@param key:String变量名
*@param value:String在求值过程中找到密钥时要替换的值
* 
*/        
公共函数setKeyAndValue(键:字符串,值:字符串):void
{
变量元字符:数组=[];
push(新的RegExp(/\$/);
push(newregexp(/\{/);
push(newregexp(/\}/);
push(newregexp(/\^/);
push(新的RegExp(/\./);
push(新的RegExp(/\*/);
push(新的RegExp(/\+/);
变量替换:数组=[];
push(新字符串(“\\$”);
push(新字符串('\\{');
push(新字符串('\\}');
push(新字符串('\\^');
replacements.push(新字符串('\\.');
replacements.push(新字符串('\\*');
push(新字符串('\\+');
对于(i=0;ii不
        var example:StringInterpolation=new StringInterpolation();

        example.setKeyAndValue('${id}','foo');
        example.setKeyAndValue('${baseurl}','http://testing123');

        trace(example.eval('<table width="480" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="3"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="480" height="270"><param name="movie" value="http://testing123/player/Take180Player.swf?xmlLocation=/s/bx/http://testing123}&links=true" />'));


 /*outputs:<table width="480" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="3"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="480" height="270"><param name="movie" value="http://testing123/player/Take180Player.swf?xmlLocation=/s/bx/http://testing123&links=true" /> */
package com.philipbroadway.utils
{
    public class StringInterpolation extends Object
    {
        internal var _keys:Array;
        internal var _values:Array;
        internal var _result:String;
        internal var i:uint;

        /**
         * 
         * 
         */        
        public function StringInterpolation()
        {
            _keys=[];
            _values=[];    
        }





        /**
         * 
         * @param key:String a variable name
         * @param value:String a value to replace when the key is found during eval
         * 
         */        
        public function setKeyAndValue(key:String,value:String):void
        {
            var metacharacters:Array=[];
            metacharacters.push(new RegExp(/\$/));
            metacharacters.push(new RegExp(/\{/));
            metacharacters.push(new RegExp(/\}/));
            metacharacters.push(new RegExp(/\^/));
            metacharacters.push(new RegExp(/\./));
            metacharacters.push(new RegExp(/\*/));
            metacharacters.push(new RegExp(/\+/));

            var replacements:Array=[];
            replacements.push(new String('\\$'));
            replacements.push(new String('\\{'));
            replacements.push(new String('\\}'));
            replacements.push(new String('\\^'));
            replacements.push(new String('\\.'));
            replacements.push(new String('\\*'));
            replacements.push(new String('\\+'));

            for(i=0;i<metacharacters.length;i++)
            {
                key=key.replace(metacharacters[i],replacements[i]);
            }
            _keys.push(key);
            _values.push(value);
        }





        /**
         * 
         * @param value:String to be interpolated
         * @return String interpolated
         * 
         */        
        public function eval(value:String):String
        {
            _result=value;
            for(i=0;i<_keys.length;i++)
            {
                var regEx:RegExp=new RegExp(_keys[i],'g');
                _result=_result.replace(regEx,_values[i]);
            }

            return _result;
        }




        /**
         * 
         * 
         */        
        public  function reset():void
        {
            _keys=[];
            _values=[];                
        }
    }
}