Search code examples
arraysactionscript-3flashmovieclipaddchild

accessing array elements in another frame as3


I have created an Array in frame 1 and dynamically create a list of movieclips with it , and I want to create the same Array in frame 3 and those movieclips again if something is true or false.is it possible ? because when I'm trying to do this , I will get this error : 1151: A conflict exists with definition i in namespace internal.

here is my code at frame 1 :

stop(); 
import flash.display.MovieClip;
var p_x:uint = 90;
var p_y:uint = 108;
var my_list:String = "Games,Videos, Medias,Images,Photos,Personal Photos,Social                  Media,Private,Social,None,Names,Families";
var myListString:Array = my_list.split(",");
var myArray:Array=new Array ();
var listObject = 1;
for (var i:uint=0; i<12; i++)
{
    var myItemList:mrb=new mrb();
    myItemList.x = p_x;
    myItemList.y = p_y + 80;
    myItemList.y = (p_y + (listObject * 65));
    myArray.push(myItemList);
    myItemList.txt.text = i.toString();
    myItemList.txt.text = myListString[i].toString();
    myItemList.name = "item"+i; 
    addChild(myItemList) as MovieClip ;
    listObject++;
}

and here is code at frame 3 :

    var tmpCurFrame:int = currentFrame;

    this.addEventListener(Event.ENTER_FRAME, handleUpdate)

        function handleUpdate(e:Event):void {
        if (tmpCurFrame != currentFrame) {
          this.removeEventListener(Event.ENTER_FRAME, handleUpdate);
                    return;
                }
               if (so.data.fav1 != undefined) 
    {
    if ( so.data.fav1 == "on") 
    {
    for (var i:int = 0; i < myListString.length;)
{    if (myListString[i].indexOf() > -1)
        {
    var myRectangle:mrb=new mrb();
            trace("found it at index: " + i);
            myRectangle.x = p_x;
            myRectangle.y = (p_y + (findobject * 50));
            trace('p_y+80 =' + (p_y+(findobject*80)) + 'p_x = ' + p_x );
            myArray.push(myRectangle);
            myRectangle.txt.text = myListString[i].toString();
            trace(my_array2[i].toString() );
            addChild(myRectangle);
          }
        }

      }      
    }
    else
    {
    fav_1.fav_on.visible=true;

       }

  }

Solution

  • This error message simply means that you use twice the same variable i. You just have to give them differents names.