Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    714

    [F8] - replaceText ... come funziona?

    Buongiorno,
    sarà che sono convalescente da un'influenza ma non capisco come funziona il comando replaceText.

    Per esempio:

    codice:
    prova="05/06/2011"
    trace (prova.substring(3,2))
    trace (prova.substring(5,6))
    prova=prova.replaceText(3, 2, "")
    semplicemente voglio togliere le "/" dalla data per controllare che siano effettivamente numeri quelli inseriti ... se non ricordo in passato lo facevo con un ciclo che controllava ciascun carattere però mi chiedevo se questo replaceText non fosse migliore.

    grazie dell'aiuto
    mir
    Fotografario MultiUtente Interamente in Flash: QUI

  2. #2
    trace(stringa.split("/").join(""))

    (non esiste una funzione replaceText, almeno a quanto ne so)

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    714
    oooooooo .... grazie ...

    ma a che serve allora replaceText???
    Fotografario MultiUtente Interamente in Flash: QUI

  4. #4
    Dove hai preso quella funzione?
    Probabilmente c'era un altro pezzo di codice con la definizione della funzione
    codice:
    function replaceText(stringa){
      //qualcosa
    }

  5. #5
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    714
    hmmmmmmmmm.....

    FORSE E' UN COMANDO SOLO DI FLASH LITE ....

    codice:
    replaceText (TextField.replaceText method)
    public replaceText(beginIndex:Number, endIndex:Number, newText:String) : Void
    
    Replaces a range of characters, specified by the beginIndex and endIndex parameters, in the specified text field with the contents of the newText parameter.
    
    Availability: ActionScript 1.0; Flash Lite 2.0
    
    Parameters
    beginIndex:Number - The start index value for the replacement range.
    
    endIndex:Number - The end index value for the replacement range.
    
    newText:String - The text to use to replace the specified range of characters.
    
    Example
    The following example creates a text field called my_txt and assigns the text dog@house.net to the field. The indexOf() method is used to find the first occurrence of the specified symbol (@). If the symbol is found, the specified text (between the index of 0 and the symbol) replaces with the string bird. If the symbol is not found, an error message is displayed in the Output panel.If the symbol is not found, an error message writes to the log file. 
    
    this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320, 22);
    my_txt.autoSize = true;
    my_txt.text = "dog@house.net";
    
    var symbol:String = "@";
    var symbolPos:Number = my_txt.text.indexOf(symbol);
    if (symbolPos>-1) {
        my_txt.replaceText(0, symbolPos, "bird");
    } else {
        trace("symbol '"+symbol+"' not found.");
    }
    Fotografario MultiUtente Interamente in Flash: QUI

  6. #6
    forse

    edit:

    Ho controllato, il metodo esiste, ma è della classe TextField e non serve per modificare una stringa, ma per cambiare il testo in una casella textfield.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.