A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] how many character in my text field?

  1. #1
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299

    [F8] how many character in my text field?

    How do I find out or read, how many character in my text field?

    Which is brought in byXML?

    so that I could make an IF statement with.

    ie.

    if (this many characters) {
    do this;
    }else{
    Something else
    }

    Pretty simple. I wish!!!
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  2. #2
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    PHP Code:
    var characterLength yourTextFieldName.length;
    trace(characterLength); // returns the number of characters in your text field. 

  3. #3
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299

    Thanks,

    So I used characterLength.text; to put the value in a text field, but it only returns 0. Not the trackInfo that gets fed into it.

    Code:
    characterLengthvar characterLength = this.trackInfo.length;
    
    trace(characterLength);
    this.characterLength.text;

    I need to grab the info from the XML maybe???
    Code:
    // Load the songs XML
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function()
    {
    	var nodes:Array = this.firstChild.childNodes;
    	for(var i=0;i<nodes.length;i++)
    	{
    		sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.track));
    	}
    	playSong();
    
    }
    Could you tell me how thats done?
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  4. #4
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299

    New angle on Xml text scroller

    So, I've figured out that I need to use do this through Xml.

    So I've done.
    Code:
    // Setup sound object
    var s:Sound = new Sound();
    
    s.setVolume(75);
    
    // Array of songs
    var sa:Array = new Array();
    
    // Currently playing song
    var cps:Number = -1;
    
    // Position of music
    var pos:Number;
    
    // Load the songs XML
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function() {
    	var nodes:Array = this.firstChild.childNodes;
    	for (var i = 0; i<nodes.length; i++) {
    		sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.track));
    	}
    
       xmlLoaded();
    };
    
    
    private function xmlLoaded () :Void {
        this.infoMarion.trackInfo.text = sa[cps].track;
        this.infoMarion.trackInfo.autoSize = true;
    
        functionToSetUpEnterFrameHandlers();
    
        playSong();
    
    }
    
    private function functionToSetUpEnterFrameHandlers() :Void {
        _root.onEnterFrame = function() {
            if (this.infoMarion.trackInfo._width>15) {
                if ((this.infoMarion.trackInfo._x+this.infoMarion.trackInfo._width)<0) {
                    this.infoMarion.trackInfo._x = 145;
                } else {
                    this.infoMarion.trackInfo._x--;
                }
            }
    		}
    }
    
    xml.load(text1);
    
    // Play the MP3 File
    function playSong():Void
    {
    	s = new Sound();
    	//
    	s.setVolume(75);
    	if(cps == sa.length - 1)
    	{
    		cps = -1;
    		//s.loadSound(sa[cps].earl, true);
    	}
    	else
    	{
    		s.loadSound(sa[++cps].earl, true);
    	}
    	infoMarion.trackInfo.text = sa[cps].track;
    	playPause.gotoAndStop("pause");
    	textPos = 0;
    }
    But know I get error codes.
    private function xmlLoaded () :Void {
    private function functionToSetUpEnterFrameHandlers() :Void {
    Attribute used outside class.
    If anyone has any insight it would be appreciated.

    ZIPPED FILES
    Thanks,
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

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