IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ActionScript 1 & ActionScript 2 Discussion :

Problème sur l'événement onEnterFrame


Sujet :

ActionScript 1 & ActionScript 2

  1. #1
    Membre éprouvé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2007
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juin 2007
    Messages : 148
    Par défaut Problème sur l'événement onEnterFrame
    Bonjour,
    Je programme actuellement un petit lecteur mp3 flash, malheuresement j'ai un petit soucis sur un événements onEnterFrame et je n'arrive pas à savoir d'où ça peut venir.
    Je m'explique, lorsque je charge le flash je veux qu'il traite automatiquement une fonction qui va récupéré le temps afin de gérer ma TimeLine.

    Mon code se décompose en quatres classes (j'utilise MTASC pour compiler)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
     
    class TemplateMp3Base extends Template
    {
    	// ------------- CONSTANTE ----------------
    	public var PLAYER_HEIGHT:Number = 26;
    	public var BUTTON_WIDTH:Number = 26;
    	public var BUTTON_HEIGHT:Number = 26;
    	public var SLIDER_WIDTH:Number = 20;
    	public var SLIDER_HEIGHT:Number = 10;
    	public var VOLUME_WIDTH:Number = 30;
    	public var VOLUME_HEIGHT:Number = 6;
     
    	// ------------- VARIABLES ----------------
    	private var _playerPlay:MovieClip;
    	private var _playerPause:MovieClip;
    	private var _playerStop:MovieClip;
    	private var _playerVolume:MovieClip;
    	private var _playerTime:MovieClip;
    	private var _playerSlider:MovieClip;
    	private var _loadingBar:MovieClip;
    	private var _playerBackground:MovieClip;
     
    	private var _volume:Number = 100;
    	private var _volumeMax:Number = 200;
    	private var _timeFormat:TextFormat;
     
     
    	private var _playerButtonColor:Number = 0xffffff;
    	private var _playerSliderColor:Number = 0xffffff;
    	private var _playerSliderBarBgColor:Number = 0xffffff;
    	private var _playerColor:Number = 0x111111;
    	private var _loadingColor:Number = 0xcccccc;
     
     
    	private function TempalteMp3Base() {
    	}
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
     
     
    class TemplateMp3 extends TemplateMp3Base
    {
    	// ------------- CONSTANTE ----------------
     
     
    	// ------------- VARIABLES ----------------
     
    	/* ====================== CONSTRUCTEUR ======================
    	==============================================================*/
    	public function TemplateMp3()
    	{
    		super();
    	}
    	static function main():Void 
    	{
    		// Initialisation du lecteur
    		var player:PlayerBase = new PlayerBase(new TemplateMp3());
    	}
    	/* ==================== FIN CONSTRUCTEUR ====================
    	===============================================================*/
    	/* ==================== METHODES PRIVEES ====================
    	===============================================================*/
    	private function _initPlayer()
    	{
    		super._initPlayer();
    		this._initPlayerBackground();
    		this._initPlayerPlay();
    		this._initPlayerPause();
    		this._initPlayerStop();
    		this._initPlayerVolume();
    		this._initPlayerTime();
    		this._initPlayerSlider(SLIDER_WIDTH);
     
    	}
    	/**
    	*  Initialisation des boutons
    	* @param = pTarget = Clip
    	* @param pWidth : Taille du bouton en largeur.
    	**/
    	private function _initButton(pTarget:MovieClip, pWidth:Number)
    	{
    		if(pWidth == undefined)
    		{
    			pWidth = BUTTON_WIDTH;
    		}
    		var vArea:MovieClip = pTarget.createEmptyMovieClip("area_mc",pTarget.getNextHighestDepth());
    		var vIcon:MovieClip = pTarget.createEmptyMovieClip("icon_mc",pTarget.getNextHighestDepth());
     
    		vArea.beginFill(0,0);
    		vArea.moveTo(2,2);
    		vArea.lineTo(2, PLAYER_HEIGHT-4);
    		vArea.lineTo(pWidth - 4, PLAYER_HEIGHT - 4);
    		vArea.lineTo(pWidth - 4, 2);
    		vArea.endFill();
     
    		vArea.icon = vIcon;
    		vArea.onRollOver = function(){
    			this.icon._alpha = 75;
    		};
    		vArea.onPress = vArea.onRollOut = vArea.onDragOut = function() {
    			this.icon._alpha = 100;
    		};
    	}
    	/**
    	*  Change l'état d'un bouton
    	* @param pButton  : Bouton
    	* @param pStatus : activation du bouton
    	* @param pMask : Affichage de celui-ci
    	**/
    	private function _enableButton(pButton:MovieClip,pStatus:Boolean,pMask:Boolean)
    	{
    		pButton.area_mc.enabled = pStatus;
    		pButton._visible = !pMask;
    		if(!pStatus){
    			pButton.icon_mc._alpha = 30;
    		}
    		else{
    			pButton.icon_mc._alpha = 100;
    		}
    	}
    	private function _initPlayerBackground()
    	{
    		this._playerBackground = this.player.createEmptyMovieClip("background_mc",this._player.getNextHighestDepth());
     
    		this._playerBackground.beginFill(this._playerColor)
    		this._playerBackground.moveTo(0,0);
    		this._playerBackground.lineTo(0,Stage.height);
    		this._playerBackground.lineTo(Stage.width,Stage.height);
    		this._playerBackground.lineTo(Stage.width,0);
    		this._playerBackground.endFill();
    	}
    	private function _initPlayerPlay()
    	{
    		this._playerPlay = this._player.createEmptyMovieClip("btn_player",this._player.getNextHighestDepth());
    		this._initButton(this._playerPlay);
     
    		this._playerPlay.area_mc.onRelease = this.delegate(this, this.playRelease);
     
    		this._playerPlay.icon_mc.beginFill(this._playerButtonColor);
    		this._playerPlay.icon_mc.lineTo(0, 8);
    		this._playerPlay.icon_mc.lineTo(6, 4);
    		this._playerPlay.icon_mc.endFill();	
    		this._playerPlay.icon_mc._y = BUTTON_HEIGHT / 2 - _playerPlay.icon_mc._height / 2;
    		this._playerPlay.icon_mc._x = BUTTON_WIDTH / 2 - _playerPlay.icon_mc._width / 2;
    	}
    	/**
    	*  Bouton Pause
    	**/
    	private function _initPlayerPause()
    	{
    		this._playerPause = this._player.createEmptyMovieClip("btn_pause",this._player.getNextHighestDepth());
    		this._initButton(this._playerPause);
     
    		this._playerPause.area_mc.onRelease = this.delegate(this, this.pauseRelease);
     
    		//icone
    		this._playerPause.icon_mc.beginFill(this._playerButtonColor);
    		this._playerPause.icon_mc.lineTo(0,8);
    		this._playerPause.icon_mc.lineTo(3,8);
    		this._playerPause.icon_mc.lineTo(3,0);
    		this._playerPause.icon_mc.endFill();
    		this._playerPause.icon_mc.beginFill(this._playerButtonColor);
    		this._playerPause.icon_mc.lineTo(5,0);
    		this._playerPause.icon_mc.lineTo(5,8);
    		this._playerPause.icon_mc.lineTo(8,8);
    		this._playerPause.icon_mc.lineTo(8,0);
    		this._playerPause.icon_mc.endFill();
    		this._playerPause.icon_mc._y = BUTTON_HEIGHT / 2 - _playerPause.icon_mc._height / 2;
    		this._playerPause.icon_mc._x = BUTTON_WIDTH / 2 - _playerPause.icon_mc._width / 2;
    		//Initialisation du bouton
    		this._enableButton(this._playerPause, false, true);
    	}
    	/**
    	*  Bouton Stop
    	**/
    	private function _initPlayerStop()
    	{
    		//création du clip pour le bouton
    		this._playerStop = this._player.createEmptyMovieClip("btn_stop",this._player.getNextHighestDepth());
    		this._initButton(this._playerStop);
    		//emplacement du bouton en x
    		this._playerStop._x = BUTTON_WIDTH;
    		// délégation  de bouton
    		this._playerStop.area_mc.onRelease = this.delegate(this, this.stopRelease);
     
    		//icone
    		this._playerStop.icon_mc.beginFill(this._playerButtonColor);
    		this._playerStop.icon_mc.lineTo(0,8);
    		this._playerStop.icon_mc.lineTo(8,8);
    		this._playerStop.icon_mc.lineTo(8,0);
    		this._playerStop.icon_mc.endFill();
    		//Emplacement de l'icone
    		this._playerStop.icon_mc._y = BUTTON_HEIGHT/2 - _playerStop.icon_mc._height/2;
    		this._playerStop.icon_mc._x = BUTTON_WIDTH/2 - _playerStop.icon_mc._width/2;
    		//Initialisation du bouton		
    		this._enableButton(this._playerStop, false);
    	}
    	/**
    	*  Volume
    	**/
    	private function _initPlayerVolume()
    	{
    		this._playerVolume = this._player.createEmptyMovieClip("btn_volume",this._player.getNextHighestDepth());
    		this._initButton(this._playerVolume, VOLUME_WIDTH);
     
    		this._playerVolume._x = BUTTON_WIDTH * 2;
     
    		this._playerVolume.area_mc.onPress = this.delegate(this, this._volumePress);
    		this._playerVolume.area_mc.onRelease = this.delegate(this, this._volumeRelease);
    		this._playerVolume.area_mc.onReleaseOutside = this.delegate(this, this._volumeRelease);
     
    		var vIconBackground:MovieClip = this._playerVolume.icon_mc.createEmptyMovieClip("background_mc", 1);
    		vIconBackground.beginFill(this._playerButtonColor, 25);
    		vIconBackground.moveTo(0, VOLUME_HEIGHT);
    		vIconBackground.lineTo(VOLUME_WIDTH - 8, VOLUME_HEIGHT);
    		vIconBackground.lineTo(VOLUME_WIDTH - 8, 0);
    		vIconBackground.endFill();
    		vIconBackground._y = BUTTON_HEIGHT/2 - vIconBackground._height/2;
    		vIconBackground._x = VOLUME_WIDTH/2 - vIconBackground._width/2;
     
    		this._updateVolume();
    	}
    	private function _updateVolume()
    	{
    		var vIcon:MovieClip;
    		if (this._playerVolume.icon_mc.current_mc == undefined) {
    			vIcon = this._playerVolume.icon_mc.createEmptyMovieClip("current_mc", 2);
    		} else {
    			vIcon = this._playerVolume.icon_mc.current_mc;
    		}
    		vIcon.clear();
     
    		if (this._volume > this._volumeMax) {
    			this._volume = this._volumeMax;
    		}
     
    		var vWidth:Number = (VOLUME_WIDTH - 8) * this._volume / this._volumeMax;
    		var vRatio:Number = this._volume / this._volumeMax;
     
    		vIcon.beginFill(this._playerButtonColor);
    		vIcon.moveTo(0, VOLUME_HEIGHT);
    		vIcon.lineTo(vWidth, VOLUME_HEIGHT);
    		vIcon.lineTo(vWidth, VOLUME_HEIGHT - VOLUME_HEIGHT * vRatio);
    		vIcon.endFill();
    		vIcon._y = vIcon._parent.background_mc._y;
    		vIcon._x = vIcon._parent.background_mc._x;
     
    		this.controller.setVolume(this._volume);
    	}
     
    	private function _volumeEnterFrame()
    	{
    		var xMouse:Number = this._playerVolume.icon_mc.current_mc._xmouse;
    		var nbMax:Number = this._playerVolume.icon_mc.background_mc._width;
    		if(xMouse > nbMax){
    			xMouse = nbMax;
    		}
    		if(xMouse < 0){
    			xMouse = 0;
    		}
    		var volume:Number = xMouse * this._volumeMax / nbMax;
    		this._volume = volume;
    		this._updateVolume();
    	}
     
    	/**
    	* Affichage du temps 
    	**/
    	private function _initPlayerTime()
    	{
    		this._playerTime = this._player.createEmptyMovieClip("btn_time", this._player.getNextHighestDepth());
    		this._playerTime._x = BUTTON_WIDTH*2 + VOLUME_WIDTH;
     
    		this._playerTime.createTextField("txt_time", this._player.getNextHighestDepth(), 0, 0, 0, 0);
    		this._playerTime.txt_time.selectable = false;
    		this._playerTime.txt_time.textColor = this._playerButtonColor;
    		this._playerTime.txt_time.text = "00:00:00";
    		this._playerTime.txt_time.autoSize = "left";
    		this._playerTime.txt_time._y = BUTTON_HEIGHT /2 - this._playerTime.txt_time._height/2;
    		this._playerTime.txt_time._x = 6;
    		this._playerTime.onEnterFrame = this.delegate(this, function() {
    		});
     
    	}
    	/**
    	* SliderBar : TimeLine 
    	**/
    	private function _initPlayerSlider(pMargin:Number)
    	{
    		this._playerSlider = this._player.createEmptyMovieClip("slider_mc", this._player.getNextHighestDepth());
     
    		var vMargin:Number = pMargin;
    		vMargin += 10;
     
    		this._playerSlider._x = BUTTON_WIDTH * 3 + VOLUME_WIDTH + vMargin;
    		this._playerSlider.width = this._swfWidth - BUTTON_WIDTH*3 - VOLUME_WIDTH - this._playerTime._width;
     
    		//barre
    		var vBarBg:MovieClip = this._playerSlider.createEmptyMovieClip("barBg_mc", this._playerSlider.getNextHighestDepth());
    		vBarBg.beginFill(0xffcc33,25);
    		vBarBg.moveTo(0,-1);
    		vBarBg.lineTo(this._playerSlider.width,-1);
    		vBarBg.lineTo(this._playerSlider.width,2);
    		vBarBg.lineTo(0,2);
    		vBarBg.endFill();
    		vBarBg._y = BUTTON_HEIGHT /2;
     
    		//Barre de chargement
    		this._loadingBar = this._playerSlider.createEmptyMovieClip("loading_mc",this._playerSlider.getNextHighestDepth());
    		this._loadingBar.beginFill(this._loadingColor, 75);
    		this._loadingBar.lineTo(this._playerSlider.width, 0);
    		this._loadingBar.lineTo(this._playerSlider.width, 2);
    		this._loadingBar.lineTo(0, 2);
    		this._loadingBar.endFill();
    		this._loadingBar._y = BUTTON_HEIGHT / 2;
    		this._loadingBar._xscale = 0;
    		this._loadingBar._visible = false;
     
    		// barre slider 
    		var vSlider:MovieClip = this._playerSlider.createEmptyMovieClip("bar_mc", this._playerSlider.getNextHighestDepth()); 
    		vSlider.parent = this;
    		vSlider.margin = vMargin;
    		vSlider.width = SLIDER_WIDTH;
    		vSlider.barWidth = this._playerSlider.width;
    		vSlider.onRollOver = function(){
    			this._alpha = 75;
    		};
    		vSlider.onRollOut = function(){  
    			this._alpha = 100
    		};
    		vSlider.onPress = this.delegate(this, function(){
    			this._playerSlider.bar_mc.startDrag(false, 0, this._playerSlider.bar_mc._y, this._playerSlider.width - this._playerSlider.bar_mc._width, this._playerSlider.bar_mc._y);
    			this._playerSlider.bar_mc.onEnterFrame = this.delegate(this, this._sliderMoving);
    		});
    		vSlider.onRelease = vSlider.onReleaseOutside = this.delegate(this, function(){ 
    			this._playerSlider.bar_mc.stopDrag();
    			this._playerSlider.bar_mc.onEnterFrame = this.delegate(this, this._sliderEnterFrame);
    		});
     
    		vSlider.beginFill(this._playerSliderColor); 
    		vSlider.lineTo(0, SLIDER_HEIGHT);
    		vSlider.lineTo(SLIDER_WIDTH, SLIDER_HEIGHT);
    		vSlider.lineTo(SLIDER_WIDTH, 0);
    		vSlider.endFill();
     
    		vSlider._y = PLAYER_HEIGHT / 2 - SLIDER_HEIGHT / 2;
    		vSlider.onEnterFrame = this.delegate(this, this._sliderEnterFrame);
    	}
    	private function _sliderEnterFrame(){
    		var nbMax:Number;
    		var nbTime:Number;
    		var position:Number; 
    		var nbDuration:Number;
     
    		// Le maximum
    		if (this._loadingBar._visible) {
    			nbMax = this._loadingBar._width - SLIDER_WIDTH;
    		} else {
    			nbMax = this._playerSlider.width - SLIDER_WIDTH;
    		}
    		nbMax = (nbMax < 0) ? 0 : nbMax;
    		nbMax = (nbMax > this._playerSlider.width) ? this._playerSlider.width : nbMax;
    		// Le temps
    		nbTime = this.controller.getPosition();
    		nbDuration = this.controller.getDuration();
    		// La position
    		position = Math.round(nbTime/nbDuration * nbMax);
    		if (isNaN(position)) {
    			position = 0;
    		}
    		this._playerSlider.bar_mc._x = position;
     
    	}
    	/**
    	 * Déplacement du slider
    	 */
    	private function _sliderMoving()
    	{
    		var position:Number = this._playerSlider.bar_mc._x / (this._playerSlider.width - SLIDER_WIDTH) * this.controller.getDuration(); 
    		this.controller.setPosition(position);
    		this.controller.setDuration();
    	}
    	/**
    	 * Chargement
    	 */
    	private function _loading(){
    		var objLoading:Object = this.controller.getLoading();
    		this._loadingBar._xscale = (objLoading.percent >= 1)?objLoading.percent:0; 
    		if (objLoading.percent == 100) { 
    			this._loadingBar._visible = false; 
    			delete this._loadingBar.onEnterFrame; 
    		}
    	}
    	/* =================== METHODES PUBLIQUES ===================
    	================================================================*/
    	public function playRelease()
    	{
    		super.playRelease();
     
    		this._enableButton(this._playerPlay, false, true);
    		this._enableButton(this._playerPause, true, false);
    		this._enableButton(this._playerStop, true);
     
    	}
    	public function pauseRelease()
    	{
    		super.pauseRelease();
     
    		this._enableButton(this._playerPause, false, true);
    		this._enableButton(this._playerPlay, true);
    	}
    	public function stopRelease()
    	{
    		super.stopRelease();
     
    		this._enableButton(this._playerStop, false);
    		this._enableButton(this._playerPause, false, true);
    		this._enableButton(this._playerPlay, true);
    	}
    	/**
    	 * On appuie sur le bouton Volume
    	 */
    	private function _volumePress()
    	{
    		this._playerVolume.onEnterFrame = this.delegate(this,this._volumeEnterFrame);
    	}
    	/**
    	 * On relâche le bouton Volume
    	 */
    	private function _volumeRelease()
    	{	
    		delete this._playerVolume.onEnterFrame;
    	}
    	/**
    	 * Affichage du chargement
    	 */
    	public function startLoading():Void
    	{
    		super.startLoading();
    		this._loadingBar.onEnterFrame = delegate(this, this._loading);
    		this._loadingBar._visible = true;
    	}
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    class PlayerBase
    {
    	private var _template:Template;
    	private var _bufferTime:Number = 5;
    	private var _loop:Boolean = false;
    	private var _times:Array;
    	private var _positions:Array;
    	private var _sound:Sound;
    	private var _soundUrl:String;
    	private var _firstPlay:Boolean = true;
    	public var isPlaying:Boolean = false;
    	private var _soundDuration:Number;
    	private var _soundPosition:Number;
    	public function PlayerBase(pTemplate:Template)
    	{
     
    		this._template = pTemplate;
    		this._template.controller = this;
    		this._initVars();
    		this._initSound();
    	}
    	/*======================= END = CONSTRUCTOR = END ========================*/
    	/*========================================================================*/
     
    	/*=============================== PRIVATE ================================*/
    	/*========================================================================*/
    	private function _initSound()
    	{
    		// Sound manager
    		this._sound = new Sound();
    		this._sound.loadSound(this._soundUrl, true);
    	}
    	private function _initVars()
    	{
    		if (_root.srcOfSound != undefined) {
    			this._soundUrl = _root.srcOfSound;
    		}
    		if (_root.buffer != undefined) {
    			this._bufferTime = Number(_root.buffer);
    		}
    		if (_root.loop == "1") {
    			this._loop = true;
    		}
    	}
    	/*========================= END = PRIVATE = END ==========================*/
    	/*========================================================================*/
     
    	/*================================ PUBLIC ================================*/
    	/*========================================================================*/
    	public function setPosition(pPosition:Number)
    	{
    		pPosition = (pPosition < 0)? 0 : pPosition;
    		pPosition = (pPosition > this._sound.duration) ? this._sound.duration : pPosition;
    		this._soundPosition = pPosition;
    	}
    	public function setVolume(pVolume:Number)
    	{
    		this._sound.setVolume(pVolume);
    	}
    	public function setDuration()
    	{
    		this._soundDuration = this._sound.duration;
    	}
    	public function getPosition():Number
    	{
    		return this._soundPosition;
    	}
    	public function getDuration():Number
    	{
    		return this._soundDuration;
    	}
    	public function getLoading():Object
    	{
    		var loaded:Number = this._sound.getBytesLoaded();
    		var total:Number = this._sound.getBytesTotal();
    		var percent:Number = Math.round(loaded / total * 100); 
    		return {loaded:loaded, total:total, percent:percent};
    	}
    	public function play()
    	{
    		var nbPosition:Number = (this._soundPosition!=0)?Math.round(this._soundPosition/1000):0;
    		this._sound.start(nbPosition);			
    		this.isPlaying = true;
    	}
    	/**
    	 * Pause
    	 */
    	public function pause()
    	{
    		this._soundPosition = this._sound.position;
    		this._sound.stop();		
    		this.isPlaying = false;
    	}
    	/**
    	 * Pause
    	 */
    	public function stop()
    	{
    		this._soundPosition = 0;
    		this._sound.stop();		
    		this.isPlaying = false;
    	}
    	/*========================== END = PUBLIC = END ==========================*/
    	/*========================================================================*/
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    class Template 
    {
    	//---------------------CONSTANTES
    	private var SWF_MIN_WIDTH:Number = 160;
    	private var SWF_MIN_HEIGHT:Number = 50;
    	//---------------------VARIABLES
    	private var _swfWidth:Number;
    	private var _swfHeight:Number;
    	private var _player:MovieClip;
    	public var player:MovieClip = _root.player_mc;
    	private var _background:MovieClip = _root.background_mc;
    	public var controller:PlayerBase;
    	/*============================= CONSTRUCTEUR =============================*/
    	/*========================================================================*/
    	/**
    	* Initialisation
    	*/
    	private function Template()
    	{
    		this._initFlash();
    		this._initPlayer();
    	}
    	private function _initPlayer(){
    		this._player = _root.createEmptyMovieClip("player_mc", _root.getNextHighestDepth()); 
    	}
    	/*======================= FIN = CONSTRUCTEUR = FIN =======================*/
    	/*========================================================================*/
     
    	/*=========================== METHODES PRIVEES ===========================*/
    	/*========================================================================*/
    	/**
    	 * Délégation de fonction
    	 * 
    	 * @param pTarget La cible
    	 * @param pFunc La fonction
    	 * @return La même fonction avec un scope fixe
    	 */
    	public function delegate(pTarget:Object, pFunc:Function):Function
    	{
    		var ThisFunction:Function = function()
    		{
    			var target = arguments.callee.target;
    			var func = arguments.callee.func;
    			return func.apply(target);
    		};
     
    		ThisFunction.target = pTarget;
    		ThisFunction.func = pFunc;
     
    		return ThisFunction;
    	}
    	/**
    	 * Initialisation du Flash
    	 */
    	private function _initFlash()
    	{
    		Stage.scaleMode = "noScale";
    		Stage.align = "TL";
     
    		if (_root.width != undefined) {
    			this._swfWidth = Number(_root.width);
    		} else {
    			this._swfWidth = Stage.width;
    		}
    		if (this._swfWidth < SWF_MIN_WIDTH) {
    			this._swfWidth = SWF_MIN_WIDTH;
    		}
     
    		if (_root.height != undefined) {
    			this._swfHeight = Number(_root.height);
    		} else {
    			this._swfHeight = Stage.height;
    		}
    		if (this._swfHeight < SWF_MIN_HEIGHT) {
    			this._swfHeight = SWF_MIN_HEIGHT;
    		}
    	} 
     
    	/*=========================== METHODES PUBLIQUES ===========================*/
    	/*========================================================================*/
    	public function playRelease()
    	{
    		this.controller.play();
    		if (this.controller.getLoading().percent != 100) {
    			this.startLoading();
    		}
    	}
    	public function pauseRelease()
    	{
    		this.controller.pause();
    	}
    	public function stopRelease()
    	{
    		this.controller.stop();
    	}
    	public function startLoading()
    	{
     
    	}
    	/*==================== FIN = METHODES PUBLIQUES = FIN ====================*/
    	/*========================================================================*/
     
     
     
    }

    Certaines choses peuvent parraitre bizarre, mais je fais des tests pour trouver d'où vient le problème, je suis débutant en Action script j'ai commencé y'a moins d'une semaine.

    merci d'avance.

  2. #2
    Membre éprouvé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2007
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juin 2007
    Messages : 148
    Par défaut
    Cela marche dorénaveant malgré le fait que je sois resté plusieurs heures bloqué dessus.

    Il m'a fallut rajouter sur la procédure playRelease() sur la classe TemplateMp3
    après le super.play();

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    this._playerSlider.vSlider.onEnterFrame = this.delegate(this, this._sliderEnterFrame);
    je ne comprend pas vraiment pourquoi et je ne met pas le sujet en résolu pour le moment, si quelqu'un connaissant bien le flash pouvait m'expliquer le pourquoi du comment je lui en serais très reconnaissant

Discussions similaires

  1. Problème sur l'évènement setOnItemClickListener
    Par anto2b dans le forum Android
    Réponses: 4
    Dernier message: 08/06/2012, 10h08
  2. [Débutant] [API Communicator] Problème sur les événements
    Par Gumpy dans le forum C#
    Réponses: 1
    Dernier message: 01/02/2012, 14h38
  3. Problème sur l'événement Form_Open
    Par funkyjul dans le forum IHM
    Réponses: 5
    Dernier message: 29/01/2010, 14h53
  4. Problème sur un évènement
    Par midotoon dans le forum ASP.NET
    Réponses: 4
    Dernier message: 17/12/2007, 15h20
  5. [Access 2007] Problème sur l'évènement Dirty
    Par Psykokwak68 dans le forum Access
    Réponses: 12
    Dernier message: 29/10/2007, 15h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo