【问题标题】:AS2 Attach Movie and LoadMovieAS2 附加电影和加载电影
【发布时间】:2010-09-17 11:37:45
【问题描述】:

我有以下代码:

var theItems:String = "4 3 6 19 20 40 41 4 3 6 19 20 40 41"

var titems = theItems.split(" ");

var nextLine = 0;
var LastSlotID = 0;
var LastX = 0;
var LastY = 0;
var slotsM = 0;
for (var i in titems){
      var thisitem:Number = titems[i];
      ThisSlotID = LastSlotID + 1;
       if(LastSlotID == 0){
            var thisSlot = Slots.attachMovie("InventorySlot", "slot"+ThisSlotID, Slots.getNextHighestDepth(), {itemID:thisitem});// the start slot
          thisSlot._y = LastY;
          thisSlot._x = LastX;
          LastSlotID = ThisSlotID + 1;
          slotsM = slotsM + 1;
        // loadMovie("http://mmysite.com/"+thisitem+".swf", thisSlot);
             //delete mySlot
       } else {
            var thisSlot = Slots.attachMovie("InventorySlot", "slot"+ThisSlotID, Slots.getNextHighestDepth(), {itemID:thisitem});// the start slot
          //thisSlot._y = LastY + ; // do this ONLY if a 4th slot
          if(slotsM == 3){
             // trace("removing" +slotsM)
              thisSlot._y = LastY + 62.9; 
              slotsM = 1;
              thisSlot._x = 0;
              LastY = thisSlot._y
              LastX = thisSlot._x
          } else {
              //trace(slotsM)
              thisSlot._x = LastX + 84.9;
            thisSlot._y = LastY

          LastSlotID = ThisSlotID + 1;
           slotsM = slotsM + 1;

            LastY = thisSlot._y;
            LastX = thisSlot._x;
          }


             //delete mySlot
       } // end of slot if 0 or not
       loadMovie("http://mysite.com/"+thisitem+".swf", thisSlot);
        var mySlot = eval("slot"+ThisSlotID);
        mySlot.onPress = function (){
              trace("" + mySlot['itemID']);
              trace(mySlot)
         }

}

在第 0 帧中。正在加载 swf,我在 Slots MC 中看到它们。但是当我单击插槽中加载的 swf 时,它根本不会跟踪任何内容

【问题讨论】:

  • 什么是 Slot 类?你的完整代码是什么?您在哪里添加 Slot 到舞台?
  • 这可能与您使用eval() 获取mySlot 的方式有关。为什么不直接在 thisSlot 上添加监听器呢?另外,请尝试跟踪“Foo”之类的内容。也许这只是一个范围界定问题。

标签: actionscript inventory


【解决方案1】:

改变

 loadMovie("http://mysite.com/"+thisitem+".swf", thisSlot);
 var mySlot = eval("slot"+ThisSlotID);
     mySlot.onPress = function (){ 
          trace("" + mySlot['itemID']);
           trace(mySlot)    
  } 

 var mySlot = loadMovie("http://mysite.com/"+thisitem+".swf", thisSlot);
      mySlot.onPress = function (){
           trace("" + mySlot['itemID']);
           trace(mySlot)      
} 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多