A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Array string is textField or movieClip?

  1. #1
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171

    resolved [RESOLVED] Array string is textField or movieClip?

    Converting AS2 to AS3 ,
    In my project I have an array that refers to a set of movieClips and textFields.
    I want to cycle trough the array and find out wether the string represents an movieClip or array.

    PHP Code:
    var changeFocusItems:Array = new Array();
    changeFocusItems.push("myMovieClip");
    changeFocusItems.push("myTextFieldOnStage");

    for 
    each (var myItem:String in changeFocusItems) {
        if (
    myItem is TextField) {
            
    // do change textField property..
        
    } else if (myItem is MovieClip) {
            
    // change movieClip property
        
    }

    How do I recognise myItem string as a textField / movieClip?
    Last edited by somlemeg; 12-31-2009 at 07:24 AM.

  2. #2
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171
    Now I'v come one step further, but I have problem changing movie clip properties:

    PHP Code:
    var myMovieClip:MovieClip = new MovieClip();
    var 
    changeFocusItems:Array = new Array();
    var 
    changeFocusItemsType:Dictionary = new Dictionary();

    changeFocusItems.push("myMovieClip");
    changeFocusItemsType["myMovieClip"]="m";
    changeFocusItems.push("myTextFieldOnStage");
    changeFocusItemsType["myTextFieldOnStage"]="t";
    //changeFocusItems.push("mov1");
    //changeFocusItemsType["mov1"]="m";

    for each (var myItem:String in changeFocusItems) {
        
    trace(changeFocusItemsType[myItem]);
        if (
    changeFocusItemsType[myItem]=="t") {

            
    trace("is a text field");
            
    // do change textField property..
        
    } else if (changeFocusItemsType[myItem] == "m") {
            
    // change movieClip property
            
    trace("is a movie clip");
            var 
    tmpMovieClip:MovieClip = new MovieClip();
            
    tmpMovieClip=MovieClip(getChildByName(myItem));
            
    tmpMovieClip.x=0;
        }

    the error occurs on tmpMovieClip.x=0;

  3. #3
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171

    Solved

    solved.

    PHP Code:
    var myMovieClip:MovieClip = new MovieClip();
    addChild(myMovieClip);
    var 
    changeFocusItems:Array = new Array();
    var 
    changeFocusItemsType:Dictionary = new Dictionary();

    changeFocusItems.push("myMovieClip");
    changeFocusItemsType["myMovieClip"]="m";
    changeFocusItems.push("myTextFieldOnStage");
    changeFocusItemsType["myTextFieldOnStage"]="t";
    changeFocusItems.push("mov1");
    changeFocusItemsType["mov1"]="m";
    //changeFocusItems.push("mov1");
    //changeFocusItemsType["mov1"]="m";

    for each (var myItem:String in changeFocusItems) {
        
    trace(myItem);
        if (
    changeFocusItemsType[myItem]=="t") {
            
    trace("is a text field");
            
    with (getChildByName(myItem)) {
                
    selectable=false;
            }
            
    // do change textField property..
        
    } else if (changeFocusItemsType[myItem] == "m") {
            
    // change movieClip property
            
    trace("is a movie clip");
            if (
    getChildByName(myItem)!=null) {
                
    with (getChildByName(myItem)) {
                    
    x=100;
                }
            }
        }


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center