Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/12/2013, 14:24
Oximandias
 
Fecha de Ingreso: diciembre-2013
Mensajes: 2
Antigüedad: 10 años, 4 meses
Puntos: 0
Pregunta Utilizar funciones de un archivo externo en Sencha Touch 2

Buenas noches, esta es la situación:

Tengo una app (es una simple cuenta atras) en donde utilizo unas funciones para el funcionamiento de la cuenta tras. Mi intención es poner esas funciones en un archivo externo (funciones.js por ejemplo) y utilizarlas en Main.js.

¿Como puedo hacerlo?

Este es el codigo de Main.js:

Código:
Ext.define('temporizador.view.Main', 
{

    extend: 'Ext.Container',
    xtype: 'main',

    requires: 
    [
        
    ],

    config: 
    {

        items: 
        [
            
            {
                xtype: 'label',
                html: '5',
                flex: 1,
                id: 'tsegundos'
            },
            {
                xtype: 'label',
                html: 'seg',
                flex: 1
            },
            {
            <!-- Barra con botones -->
                xtype: 'toolbar',
                docked: 'bottom',

                items:
                [
                    {
                        xtype: 'button',
                        text: 'Iniciar',
                        ui: 'confirm',
                        id: 'btniniciar',

                        listeners:
                        {
                            tap: function(e)
                            {
                                var boton = Ext.getCmp('btniniciar')
                                var nuevoSeg = boton.getText()
                                var segundos = Ext.getCmp('tsegundos')
                                var tiempoSeg = segundos.getHtml()

                                function empezar()
                                {
                                    if (nuevoSeg == 'Iniciar')
                                    {
                                        eltemp = setInterval(tiempo,1000)
                                    }
                                }

                                function tiempo()
                                {
                                    tiempoSeg = tiempoSeg - 1
                                    segundos.setHtml(tiempoSeg)

                                    if (tiempoSeg == 0)
                                        {
                                            clearInterval(eltemp)

                                            boton.setText('Iniciar')
                                            boton.setUi('confirm')
                                        }
                                }

                                function parar()
                                {
                                    if(nuevoSeg == 'Detener')
                                    {
                                        clearInterval(eltemp)
                                    }
                                }



                                if (boton.getText() == 'Iniciar')
                                {
                                    if(tiempoSeg != '0')
                                    {
                                        boton.setText('Detener')
                                        boton.setUi('decline')

                                        empezar()
                                    }
                                                                            
                                }
                                else
                                {
                                    boton.setText('Iniciar')
                                    boton.setUi('confirm')

                                    parar()
                                }
                            }
                        }
                    },
                    {
                    <!-- Boton de Restablecer -->

                        xtype: 'button',
                        text: 'Restablecer',
                        ui: 'normal',

                        listeners:
                        {
                            tap:function(e)
                            {
                                var segundos = Ext.getCmp('tsegundos')
                                segundos.setHtml('5')

                            }
                        }
                    }
                ]

            }
        ]
    }
});
Gracias!