@@ -233,13 +233,19 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
233233 * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE } texType
234234 */
235235 loadTextureNormal : function ( normal , texType ) {
236- if ( ! normal ) return ;
237-
236+ if ( ! normal )
237+ return ;
238238 texType = texType || ccui . Widget . LOCAL_TEXTURE ;
239239 this . _normalFileName = normal ;
240240 this . _normalTexType = texType ;
241241
242+ var self = this ;
242243 var normalRenderer = this . _buttonNormalRenderer ;
244+ if ( ! normalRenderer . _textureLoaded ) {
245+ normalRenderer . addEventListener ( "load" , function ( ) {
246+ self . loadTextureNormal ( self . _normalFileName , self . _normalTexType ) ;
247+ } ) ;
248+ }
243249 switch ( this . _normalTexType ) {
244250 case ccui . Widget . LOCAL_TEXTURE :
245251 //SetTexture cannot load resource
@@ -252,19 +258,14 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
252258 default :
253259 break ;
254260 }
255- var loaded = normalRenderer . _textureLoaded ;
256- normalRenderer . removeEventListener ( 'load' , this . _loadNormalTextureCallback ) ;
257- normalRenderer . addEventListener ( 'load' , this . _loadNormalTextureCallback , this ) ;
258- if ( loaded ) {
259- this . _loadNormalTextureCallback ( ) ;
260- }
261- } ,
262- _loadNormalTextureCallback : function ( ) {
261+
262+ this . _normalTextureLoaded = normalRenderer . _textureLoaded ;
263+
263264 this . _normalTextureSize = this . _buttonNormalRenderer . getContentSize ( ) ;
264265 this . _updateChildrenDisplayedRGBA ( ) ;
265266 if ( this . _unifySize ) {
266267 if ( this . _scale9Enabled ) {
267- this . _buttonNormalRenderer . setCapInsets ( this . _capInsetsNormal ) ;
268+ normalRenderer . setCapInsets ( this . _capInsetsNormal ) ;
268269 this . _updateContentSizeWithTextureSize ( this . _getNormalSize ( ) ) ;
269270 }
270271 } else
0 commit comments