dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: How the f-word do I get myString.length?

  1. #1
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    Extreamly basic programming I guess. Im trying to get the length from a textfile-loaded variable, in order to apply scrolloing to it.
    //In the content.txt:
    &test= this is my textfield text&

    //in the first frame of my dumb .fla file:
    loadVariablesNum("content.txt", 0);

    //10 frames forward:
    stringThing=new String;
    stringThing=test.toString();
    trace(stringThing.length());
    stop();

    But my dumb code keeps tracing "underfined"...

    Can you type in some workin example codelines? I know that you know how to do it, hehe. Come on, dont keep it a secret...

    Allso, if there is a way to get the height of the text indtead, that would be much better. I have tried the myTextfield.textHeight, but still- "underfined". All I want to do is to get the height some way or another so I can make the scrolling to the dynamic texfield...is this a crime? (lol) :-D

  2. #2
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    ok, so I found TextField.maxhscroll, but is anyone kind enough to explain how I use this feature? Im so totaly lost in the cosmic space when it comes to text-thingys...

  3. #3
    Senior Member
    Join Date
    Apr 2002
    Posts
    143
    length is a property of the string object not a method so all you need to do is take the () off the end

    Example

    Code:
    //In the content.txt: 
    &test= this is my textfield text& 
    
    //in the first frame of my dumb .fla file: 
    loadVariablesNum("content.txt", 0); 
    
    //10 frames forward: 
    stringThing=new String; 
    stringThing=test.toString(); 
    trace(stringThing.length); 
    stop();
    think of properties as varibles and methods as functions and objects as collections of varibles and methods

  4. #4
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    Thanks for the .length knowledge, Mark! Now Im trying with the '.scroll' though, I think figured it out, but I doesnt works jet. Is this becouse I nested the functions?

    //create "thread" for this scrolling
    _root.createEmptyMovieClip( "scrollControl", 1 );
    _root.scrollControl.onEnterFrame=function(){
    // where ever we are at this millisecond w/in the text field that's 'currentScroll'.
    currentScroll = _root.test.scroll;
    //
    _root.downScrollBut.onRollOver=function(){
    if (Number(currentScroll)<Number(_root.test.maxscroll )) {
    // if we are above the bottom of the text box, tell keep scrolling down
    _root.test.scroll = Number(currentScroll)+1;

    }else{
    _root.downScrollBut.enabled=false;
    _root.upScrollBut.enabled=true;
    }
    };
    //
    _root.downScrollBut.onRollOver=function(){
    if (Number(currentScroll)<=Number(_root.test.maxscrol l)) {
    // if we are below the top of the text box, keep scrolling up.
    _root.test.scroll = Number(currentScroll)-1;
    }else{
    _root.downScrollBut.enabled=true;
    _root.upScrollBut.enabled=false;
    }
    };
    };
    stop();

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    143
    this isnt what im an expert on but either your missing the prototype word in

    Example
    Code:
    _root.createEmptyMovieClip( "scrollControl", 1 ); 
    _root.scrollControl.prototype.onEnterFrame=function(){ 
    	currentScroll = _root.test.scroll; 
    	_root.downScrollBut.prototype.onRollOver=function(){ 
    		if (Number(currentScroll) // if we are above the bottom of the text box, tell keep scrolling down 
    			_root.test.scroll = Number(currentScroll)+1; 
    		}else{ 
    			_root.downScrollBut.enabled=false; 
    			_root.upScrollBut.enabled=true; 
    		} 
    	}; 
    	_root.downScrollBut.prototype.onRollOver=function(){ 
    		if (Number(currentScroll)<=Number(_root.test.maxscroll)) { 
    			_root.test.scroll = Number(currentScroll)-1; 
    		}else{ 
    			_root.downScrollBut.enabled=true; 
    			_root.upScrollBut.enabled=false; 
    		} 
    	}; 
    }; 
    stop();

  6. #6
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    Thanks Mark, you can call yourself an expert! Everything works, an I made an if-statment to make the buttons appear only when neccesary. Something I have wondered for quite a long time: How do you guys make that pretty fly blue 'code:' -text?

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Posts
    143
    just type in

    &#91;code&#93;
    insert code here
    &#91;/code&#93;


    theres a few of them
    like
    &#91;url&#93;
    &#91;swf&#93;
    &#91;img&#93;


    theres a page round here some where that tells you them all

  8. #8
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    Code:
    for(i=0;i<1000;i++){
    trace("cool fly blue code-text- duude!");
    }

  9. #9
    Senior Member
    Join Date
    Apr 2002
    Posts
    143
    are you happy now?

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