• User Newbie

    Problema Codice Player musicale Errore 1152

    Ciao a tutti.
    è da stamattina che sbatto la testa!

    Ho recuperato un player che utilizzavo su un vecchio sito per un altro sito web.
    Uso Flash Cs6. Il problema che ho è questo:

    Scena 1, livello ‘FlashAICB’, fotogramma 1, riga 41 1152: rilevato un conflitto nella definizione ereditata flash.display:MovieClip.isPlaying nello spazio dei nomi public

    La riga 41 è quella in grassetto, quindi la riga 3 qui sotto.

    Mi aiutate? Grazie a chi interverrà! Sono disperato!

    //Player Musicalevar musicPiece:Sound = new Sound(new URLRequest("010.MP3")); 
    **var** mySoundChannel:SoundChannel; 
    **var isPlaying:Boolean = false; **
    **var** pos:Number = 0; 
    
    
    **function** playMusic():**void** { 
         **if** (!isPlaying) {  
              mySoundChannel = musicPiece.play(pos);  
              mySoundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler); 
              isPlaying = **true**;  
         }  
    }
    
    
    **function** play_(**event**:MouseEvent):**void** {
         playMusic();
    }
    
    
    playMusic();
    
    
    mySoundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
    
    
    **function** soundCompleteHandler(e:Event):**void** { 
         pos = 0;
         isPlaying = **false**;
         playMusic(); 
    }
    
    
    
    
    // First button we will make is a play button, add an eventlistener.
    play_btn.addEventListener(MouseEvent.CLICK, play_);
    
    
    // The pause button, here we will use the pos variable we made earlier.
    pause_btn.addEventListener(MouseEvent.CLICK, pause_);
    
    
    **function** pause_(**event**:Event):**void** {
    // if the music is player, save the current time and stop the playing.
    **if** (isPlaying) {
    pos = mySoundChannel.position;
    mySoundChannel.stop();
    isPlaying = **false**;
    }
    }
    
    
    // Now the final button is the stop button, allmost thet same as pause
    stop_btn.addEventListener(MouseEvent.CLICK, stop_);
    
    
    **function** stop_(**event**:Event):**void** {
    // First we check if there is anything to stop then make it stop, and reset the pos variable to 0 (start time)
    **if** (mySoundChannel != **null**) {
    mySoundChannel.stop();
    pos = 0;
    isPlaying = **false**;
    }
    }
    
    
    // this is a bit complicated, but I will try to explain anyway.
    // first we make a rectangle and set its width to 100.
    **var** rectangle:Rectangle = **new** Rectangle(0,0,100,0);
    
    
    // then we need a varible to check if the handle is being dragged.
    **var** dragging:Boolean = **false**;
    
    
    // the eventlistener for startdragging
    volume_mc.mySlider_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    **function** startDragging(**event**:Event):**void** {
    
    
    // here we tell flash the margin on where it should be able to drag, (remember 100 pixels back and forth)
    volume_mc.mySlider_mc.startDrag(**false**,rectangle);
    dragging = **true**;
    
    
    // This is very important, an eventlistener so we can change the volume, not only make it look good.
    volume_mc.mySlider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
    }
    
    
    // well here is the adjust volume function, its not that complicated
    **function** adjustVolume(**event**:Event):**void** {
    
    
    // we make a variable to calculate the volume from the slider handle position and divide it by 100
    **var** myVol:Number = volume_mc.mySlider_mc.x / 100;
    // then we set it with the mySoundTransform
    **var** mySoundTransform:SoundTransform = **new** SoundTransform(myVol);
    **if** (mySoundChannel != **null**) {
    mySoundChannel.soundTransform = mySoundTransform;
    }
    }
    
    
    // and of cause the stop draggin function, I dont feel the need to explain it.
    stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    **function** stopDragging(**event**:Event):**void** {
    **if** (dragging) {
    dragging = **false**;
    volume_mc.mySlider_mc.stopDrag();
    }
    
    }
    

  • Super User

    Così è difficile, ci vorrebe il player completo.


  • User Newbie

    @Nhatan said:

    Così è difficile, ci vorrebe il player completo.

    Grazie mille per la risposta: ora: Come lo posso pubblicare qui?