2012-10-21 2 views
-2

구성 요소 자산의 콤보 상자를 사용하여 음악을 삽입하려고했습니다. 어제는 정상적으로 작동하지만 갑자기 작동이 멈췄다. 그리고이 오류가 발생했다.ActionScript 3 플래시 오류 1009 및 2025 콤보 상자

TypeError : Error # 1009 : null 객체 참조의 속성이나 메소드에 액세스 할 수 없다.

ArgumentError : Error # 2025 : 제공된 DisplayObject는 호출자의 자식이어야합니다.

나는 이러한 오류가 나타납니다 콤보 상자를 클릭 할 때마다, 이상하게도 어제 잘 작동합니다. 이 첫 번째 프레임에 대한 코드입니다 :

import flash.events.Event; 
import flash.events.MouseEvent; 
import flash.system.fscommand; 
import flash.media.Sound; 
import flash.media.SoundChannel; 
import flash.net.URLRequest; 
import flash.events.Event; 
import flash.media.SoundTransform; 
import flash.events.MouseEvent; 

//Declare MUSIC Variables 
var musicSelection:Sound; 
var musicChannel:SoundChannel; 
var musicTrack:String = "music/dearly_beloved.mp3"; 
var musicVolume:Number=0.2; 
/*var isMuted = false;*/ 


loadMusic(); 
function loadMusic():void 
{ 
//first stop old sound playing 
    SoundMixer.stopAll(); 
    musicSelection = new Sound(); 
    musicChannel = new SoundChannel(); 
//create and load the required soun 
musicSelection.load(new URLRequest(musicTrack)); 
     //when loaded - play it 
     musicSelection.addEventListener(Event.COMPLETE, musicLoaded); 
    } 

     function musicLoaded(evt:Event):void 
    { 
     //finished with this listener 
     musicSelection.removeEventListener(Event.COMPLETE, musicLoaded); 
     //play music 
     playMusic(); 
     } 

     function playMusic():void 
    { 
    //play the random or selected music 
    musicChannel = musicSelection.play(); 
    //setting the volume control property to the music channel 
    musicChannel.soundTransform = new SoundTransform(musicVolume, 0); 
    //but add this one to make repeats 
     musicChannel.addEventListener(Event.SOUND_COMPLETE, playAgain); 
    } 
    function playAgain(evt:Event):void { 
    // remove this listener and repeat 
    musicChannel.removeEventListener(Event.SOUND_COMPLETE, playAgain); 
    playMusic(); 
    } 

는이 두 번째 프레임의 코드입니다 : 내가 콤보 상자를 클릭 할 때마다

import flash.events.Event; 
menuBtn.addEventListener(MouseEvent.CLICK, goToMenu) 
function goToMenu(evt:Event):void 
{ 
gotoAndPlay(2); 
} 
// BUTTON EVENT LISTENERS 
musicCombo.addEventListener(Event.CHANGE, updateMusic); 
volumeSL.addEventListener(Event.CHANGE, setSlider); 

//process COMBO BOX changes 
function updateMusic(evt:Event):void 
{ 
if (musicCombo.selectedItem.data == "none") 
{ 
    //no music is required so stop sound playing 
    SoundMixer.stopAll(); 
} 
else 
{ 
    //otherwise load in the selected music 
    musicTrack = "music/" + musicCombo.selectedItem.data; 
    loadMusic(); 
} 
    } 

    function setSlider(evt:Event):void 
    { 
//identify the button clicked 
var mySlider:Object = (evt.target); 
//adjusting to volume of the music channel 
musicVolume = mySlider.value; 
musicChannel.soundTransform = new SoundTransform(musicVolume, 0); 
    } 

오류가 발생 내가 시도 할 때 삽입 데이터를 넣지 않고 다른 콤보 상자를 열면 같은 오류가 발생합니다. 너희들이 나를 도울 수 있기를 바랍니다 최대한 빨리이 금요일에의 xD가

감사

답변

0

좋아, 답을 발견 이번 주 인해 발생합니다. 이 3 줄의 코드를 넣어야합니다.

import fl.events.ComponentEvent; 
import fl.controls.ComboBox; 
import fl.data.DataProvider; 
관련 문제