dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [F8] Function doesnt work

  1. #1
    Member
    Join Date
    Dec 2007
    Posts
    46

    [F8] Function doesnt work

    I have a textfield and following code doesnt work on it
    please help



    function setClear():vioid{
    this.text = "";
    }


    myText.onSetFocus = setClear();

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    function setClear():Void{
    this.text "";
    };

    myText.onSetFocus setClear

  3. #3
    Member
    Join Date
    Dec 2007
    Posts
    46
    Thanks for Reply
    I did a simple Change in the Code.
    But it is also not working...
    Please Help


    PHP Code:
    function setClear(myText:String):vioid{
       if(
    this.text == myText){
            
    this.text "";
       }
    }
    myText.onSetFocus setClear(Name); 

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    what is vioid ?
    expected error - The class or interface 'vioid' could not be loaded.

    try -

    PHP Code:
    function setClear(field:TextField,str:String):Void
    if(
    field.text == strfield.text ""
    }; 

    var 
    Name:String "Bob";

    myText.onSetFocus = function(){ 
    setClear(thisName);  
    }; 
    hth

  5. #5
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi guys,

    Possible reasons for errors:
    I think "this" not refers the text field..
    You wrote: "vioid" instead of "Void"
    The "Name" possible is undefined (maybe you meant "this._name")

    I suggest something like the follow:
    PHP Code:
    function setClear(Input) {
        if (
    myText.text == InputmyText.text "";
    }

    myText.onSetFocus = function() {
        
    setClear("myText")  // Or: setClear(this._name)

    UPDATED: I think now we have more than one solutions

    Regards!

    Kostas
    Last edited by Kostas Zotos; 05-03-2008 at 09:00 AM.
    K. Zotos online portfolio: http://www.in3d.eu

  6. #6
    Member
    Join Date
    Dec 2007
    Posts
    46
    Thanks, Im sure it ll work, let me check it Thanks once Again
    Last edited by manofspirit; 05-03-2008 at 12:55 PM.

  7. #7
    Member
    Join Date
    Dec 2007
    Posts
    46
    @a_modified_dog
    Thanks a lot, Your code works
    Can you please explain why this function doesnot work directly?
    like mText.onSetFocus = setClear(this, "Hello");

    why we need to put it into another function as u did?

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    the TextField.onSetFocus method is a function that passes an
    oldFocus parameter when the textfield receives keyboard focus.

    my_txt.onSetFocus = function(oldFocus:Object) {}

    it cannot be used (as per your example) to pass parameters
    to a secondary function.

  9. #9
    Member
    Join Date
    Dec 2007
    Posts
    46
    Thanks

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