A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Why does this code crash Flash?

  1. #1
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269

    resolved [RESOLVED] Why does this code crash Flash?

    I'm sure I should be able to do this kind of thing by now, but heck - looks like I can't. I very rarely write custom classes - and this bit of code crashing Flash without any error messages is probably why. Can anyone tell me what I've done wrong?

    I have a movieclip in my Flash library which contains a textfield. For the linkage, I have set it to com.CustomTitle which points it to this class file:

    Code:
    package com{
        
        import flash.display.*;
        import flash.text.*;
    	
        dynamic public class CustomTitle extends MovieClip{
           
            public var txt:String;
            public var newText:String;
            public var n:uint;
            public var char:String;
    
            public function CustomTitle(){
                
                txt = this.name;
                newText = "";
                n = 0;
                while (n < txt.length){
                    char = txt.charAt(n);
                    if (char != "_"){
                        newText = newText + char;
                    }else{
                        newText = newText + " ";
                    }
    	    n ++;
                }
                this.text = newText;
                return;
            }   
        }
    }
    It's meant to replace the text in the movieclip with it's own instance name, substituting underscores for spaces.

    Thanks.

  2. #2
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269
    Ignore me - this.text was meant to be this.textField.text. Duh!

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