A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] instance variables being set outside of instances

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Toronto, Canada

    [F8] instance variables being set outside of instances

    this makes no ****ing sense and I want to cry.

    I have a class called Note, it receives some text, makes a movie clip makes a textfield on the clip and shows it.

    Each instance can receive text any number of times and itll keep the text in an array and when it comes time to show the note, it arranges the text fields in line under each other.

    the array that holds the text is an instance variable. Now, when I have 2 or more notes in the same movie, the array for each instance RETAINS the text from the previous notes! WTF.

    I do not at any time insert the previous notes' text into the current note, nor is the text array static, those would be the only two logical explanations, nor are the variables of the two notes the same when I create them in the movie.

    here's code

    //creation of the first note on frame 37 of the movie
    var noteNote:Note = new Note(this, _root.movie, 650, 50);
    noteNote.addText("<b>Securities</b>Source provides online access to the most sought-after Canadian and U.S. securities law materials – all in one place – through a single password.");
    //creation of the second note on frame 73 of the movie
    var noteNote2:Note = new Note(this, _root.movie, 650, note.y + note._height);
    noteNote2.addText("As the official publisher, Thomson Carswell’s OSC Bulletin is available weekly by noon each Friday and contains the full weekly Insider Reporting data (Chapter 7) directly from CDS.");
    	public var note:MovieClip;
    	public var movie:Movie;
    	public var x:Number;
    	public var y:Number;
    	public var parent:MovieClip;
    	public var parentMovie:Movie;
    	public var fadeDir:Number = 0;
    	public var fadeSpeed:Number = 8;
    	public static var width:Number = 260;
    	private var texts:Array = new Array(); //THIS IS THE ARRAY FOR THE TEXT BLURBS
    	public static var buffer:Number = 15;
    	public static var color:Number = 0xf9de80;
    	public var _height:Number;
    	///text should be one paragraph or one point
    	///if isPoint is left undefined it is assumed false
    	public function addText(text:String, isPoint:Boolean):Void
    		texts = new Array();
    		isPoint = isPoint == undefined ? false : true;
    		var index:Number = texts.length;
    		texts[index] = [];
    		texts[index][1] = isPoint;
    		//var textParent:MovieClip = note.createEmptyMovieClip("text_parent_" + note.getNextHighestDepth(), note.getNextHighestDepth());
    		var tf:TextField = note.createTextField("text_" + note.getNextHighestDepth(), note.getNextHighestDepth(), buffer, 0, width - ((buffer * 2)), 1000);
    		tf.wordWrap = true;
    		tf.multiline = true;
    		//tf.embedFonts = true;
    		tf.background = true;
    		tf.backgroundColor = 0xffffff;
    		tf.html = true;
    		tf.type = "dynamic";
    		tf.htmlText = text;
    		tf.autoSize = true;
    		tf._visible = false;
    		texts[index][0] = tf;
    		var ****:Array = texts;
    I set **** to texts every time text is added so I can see texts as a local in the debugger, this is how I found out that the array still kept the text from the Note on frame 37 when making the note on frame 73.

    I've solved this by clearing the array before I first use it in a note, but this still makes no sense, that instance variables are retaining the values of previous instances.

    I'd like some input on what this could be, also **** isn't the variable name, it's a 'bad' word, because I'm angry.
    Last edited by Ogre11; 03-01-2007 at 01:34 PM.

  2. #2
    Senior Member
    Join Date
    Nov 2004
    Toronto, Canada
    I posted this at the Adobe forums as well, seems that in as 2 arrays instantiated in a class, static or not become static. So you have to set them to a new array in the constructor, or at least before you use them.

    Apparently this is fixed in as3

  3. #3
    Senior Member gordonart's Avatar
    Join Date
    Jun 2003

    Several Logical OR doesn´t work

    I have a if statement with many OR-Operators but it doesn´t seem to work.
    It only the first ( mark1 ) that the trace works on.

    if(eval(bild._droptarget) == (mark2 || mark3 || mark4 || mark5 || mark6 || mark7 || mark8)){
    trace ("fel");

    what could be wrong?
    Mattias Gordon
    illustrator/ animator

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