【问题标题】:ActionScript 3 Flash error 1009 and 2025 combo boxActionScript 3 Flash 错误 1009 和 2025 组合框
【发布时间】:2012-10-21 22:44:06
【问题描述】:

我正在尝试使用组件资产中的组合框插入音乐。昨天工作正常,但今天突然停止工作,它给了我这个错误:

TypeError:错误 #1009:无法访问空对象引用的属性或方法。

ArgumentError:错误 #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

谢谢

【问题讨论】:

    标签: actionscript-3 combobox runtime-error


    【解决方案1】:

    好的,找到答案了。看来我需要放这3行代码:

    import fl.events.ComponentEvent; 
    import fl.controls.ComboBox;
    import fl.data.DataProvider;
    

    【讨论】:

      猜你喜欢
      • 2010-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-04
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 2013-01-23
      相关资源
      最近更新 更多