Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.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
Arrays 如何在鼠标单击时交换Flash var阵列?_Arrays_Flash_Actionscript 2 - Fatal编程技术网

Arrays 如何在鼠标单击时交换Flash var阵列?

Arrays 如何在鼠标单击时交换Flash var阵列?,arrays,flash,actionscript-2,Arrays,Flash,Actionscript 2,我有一个FlashVar数组,我想在鼠标点击时交换另一个数组 它当前将初始数组加载到空MC中。现在,当用户按下buttonMC时,我需要它切换到var productTxt2。我的代码如下 AS2代码: var productTxt1 = new Array( "Product Name 1", "Price 1", "Headline 1", "Copy 1"); var productTxt2 = new Array( "Product Name 2", "Price 2", "Headl

我有一个FlashVar数组,我想在鼠标点击时交换另一个数组

它当前将初始数组加载到空MC中。现在,当用户按下buttonMC时,我需要它切换到var productTxt2。我的代码如下

AS2代码:

var productTxt1 = new Array(
"Product Name 1", "Price 1", "Headline 1", "Copy 1");

var productTxt2 = new Array(
"Product Name 2", "Price 2", "Headline 2", "Copy 2");

_root.createEmptyMovieClip("productInfoMC", 0);

with (productInfoMC){
    var txt1:TextField = createTextField("name", 1, 0, 0, 0, 0);
    var txt2:TextField = createTextField("price", 2, 0, 0, 0, 0);
    var txt3:TextField = createTextField("headline", 3, 0, 0, 0, 0);
    var txt4:TextField = createTextField("copy", 4, 0, 0, 0, 0);

    txt1.htmlText = _root.productTxt1[0];
    txt1.autoSize = true;
    txt2.htmlText = _root.productTxt1[1];
    txt2.autoSize = true;
    txt3.htmlText = _root.productTxt1[2];
    txt3.autoSize = true;
    txt4.htmlText = _root.productTxt1[3];
    txt4.autoSize = true;
}
var productTxt1=新数组(
“产品名称1”、“价格1”、“标题1”、“副本1”);
var productTxt2=新数组(
“产品名称2”、“价格2”、“标题2”、“副本2”);
_createEmptyMovieClip(“productInfoMC”,0);
与(productInfoMC){
var txt1:TextField=createTextField(“名称”,1,0,0,0);
var txt2:TextField=createTextField(“价格”,2,0,0,0);
var txt3:TextField=createTextField(“标题”,3,0,0,0);
var txt4:TextField=createTextField(“复制”,4,0,0,0);
}
var-tfArr=新数组(txt1、txt2、txt3、txt4);
应用设置();
updateText(productTxt1);
函数applySettings(){
对于(变量i=0;i
谢谢您--这几乎可以用了。当我单击按钮时,旧的数组文本消失了,但新的数组文本没有显示。@Justin Cross-try
buttonMC.onPress=function(){var-tmpArr:array=productTxt1[0]==tfArr[0].htmlText?productTxt2:productTxt1;updateText(tmpArr);}
var productTxt1 = new Array(
"Product Name 1", "Price 1", "Headline 1", "Copy 1");

var productTxt2 = new Array(
"Product Name 2", "Price 2", "Headline 2", "Copy 2");

_root.createEmptyMovieClip("productInfoMC", 0);

with (productInfoMC){
    var txt1:TextField = createTextField("name", 1, 0, 0, 0, 0);
    var txt2:TextField = createTextField("price", 2, 0, 0, 0, 0);
    var txt3:TextField = createTextField("headline", 3, 0, 0, 0, 0);
    var txt4:TextField = createTextField("copy", 4, 0, 0, 0, 0);
}

var tfArr = new Array(txt1, txt2, txt3, txt4);
applySettings();
updateText(productTxt1);

function applySettings(){
    for(var i = 0; i < tfArr.length; i++){
        tfArr[i].html = true;
        tfArr[i].autoSize = true;
    }
}

function updateText(contentArr: Array){
    for(var u = 0; u < tfArr.length; u++){
        tfArr[u].htmlText = contentArr[u];
    }
}

buttonMC.onPress = function(){
    updateText(productTxt1[0] == tfArr[0].htmlText ? productTxt2 : productTxt1);
}