A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: getting instance name problem

  1. #1
    Senior Member
    Join Date
    Jan 2010
    Location
    England
    Posts
    268

    getting instance name problem

    Hey guys, im trying to grab the instance name of something on stage, set it to a variable then remove it.

    iv tried:


    Actionscript Code:
    var something = object1
    something.removeMovieClip();

    that works. problem is im setting variables at runtime depending on a user click.

    tried this too..

    Actionscript Code:
    var myvar;
    object1.onRelease = function() {
    myvar = this._name;
    }

    tracing this out reveals that it is actually _level0.object1.

    also tried adding the string "_level0." + object1. still dosen' work.

    what im trying to do is click on objects. store there instance names into an array then remove them all when i do something else. such as press space.

    Thanks,
    Steve,
    might be addicted to flash...
    _______________________________________

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    maybe a depth issues? maybe a scope issue?

    try this:
    actionscript Code:
    var onStageArray:Array = new Array();

    someClip1.swapDepths(_root.getNextHighestDepth());
    someClip2.swapDepths(_root.getNextHighestDepth());
    someClip3.swapDepths(_root.getNextHighestDepth());

    someClip1.onPress = function(){
        onStageArray.push(this);
    }
    someClip2.onPress = function(){
        onStageArray.push(this);
    }
    someClip3.onPress = function(){
        onStageArray.push(this);
    }

    function removeAllClips(){
        for(i=0; i<onStageArray.length; i++){
            removeMovieClip(onStageArray[i]);
        }
    }

    remove_btn.onPress = function(){
        removeAllClips();
    }

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