SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2006
    Location
    Cardiff, Wales. UK
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Movie clip losing variable value

    I'm duplicating movie clips and during that process I'm setting a key number and a movieNumber that are on the timeline of the movie clip, then calling the setClipFunctions function below. When I pass the movieClip parameter to the function, the trace shows it picks up the key and movieNumber variable just fine, but when I click the Edit button,the trace shows the movieClip name but the key and movieNumber variables have set back to 0.

    Code Actionscript:
    function setClipFunctions(a:MovieClip):Void {
    	var thisClip:MovieClip = a;
    	trace("this clip @ setClipFunctions = "+thisClip);
    	trace("this key @ setClipFunctions = "+thisClip.key);
    	trace("this movienumber @ setClipFunctions = "+thisClip.nMovieNumber);
    ....more code...
    	//edit button
    	thisClip.btEdit.onRelease = function() {
    		trace("this clip @ btEdit = "+thisClip);
    		trace("this key @ btEdit = "+thisClip.key);
    		trace("this movienumber @ btEdit = "+thisClip.nMovieNumber);
    		loadFormat(thisClip, thisClip.key, thisClip.nMovieNumber);
    		thisClip._visible = false;
    	};
    }

    The code in between just sets drag and drop parameters and a textbox, nothing that interferes with these two variables at all.
    I don't understand how they have been reset or lost. Can anyone point out my error? I'm using Flash 8 and AS2

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2006
    Location
    Cardiff, Wales. UK
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry - worked it out! Had to put a bit of code in the MC to stop it resetting the variables:

    Code Actionscript:
    if ((key == undefined) || (key == 0)) {
    	var key:Number = 0;
    } else {
    	trace("key from within mc = "+key);
    }
    if ((nMovieNumber == undefined) || (nMovieNumber == 0)) {
    	var nMovieNumber:Number = 0;
    } else {
    	trace("movieNumber from within mc = "+nMovieNumber);
    }


Bookmarks

Posting Permissions

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