hey i dont know why im getting a #1009 error
I have spent ages looking through tutorials trying to find out what i have done wrong...
basically im making a drag and drop juke box app which loads different XML playlist depending on which object is dragged onto the target.
please can you help!
also if there is a way to get reset the record so another one can be selected that would be great but thats not a massive problem.Code:import flash.events.MouseEvent; //var correct:SoundCorrect = new SoundCorrect(); //var channelCorrect:SoundChannel; //custom mouse custor cursor_mc.startDrag("true"); Mouse.hide(); // declare two variables to hold the start position of the movieclip when it's dragged var startX:Number; var startY:Number; // add event listeners to the label for mouse down and mouse up record1.addEventListener(MouseEvent.MOUSE_DOWN, pickUp); record1.addEventListener(MouseEvent.MOUSE_UP, dropIt); record2.addEventListener(MouseEvent.MOUSE_DOWN, pickUp); record2.addEventListener(MouseEvent.MOUSE_UP, dropIt); record3.addEventListener(MouseEvent.MOUSE_DOWN, pickUp); record3.addEventListener(MouseEvent.MOUSE_UP, dropIt); // this function is called when a mouse down event occurs on a label function pickUp(event:MouseEvent):void { event.target.startDrag(true); event.target.parent.addChild(event.target); // reset the message textfield event.target.parent.addChild(event.target); // store the original position of the shape in case it needs to be put back startX = event.target.x; startY = event.target.y; } // this function is called when a mouse up event occurs on the label being dragged function dropIt(event:MouseEvent):void { //hide the cursor while the record is being dragged. //cursor_mc.hide(); // stop dragging the movieclip event.target.stopDrag(); // this line takes the name of the target and adds the word 'target' var theTargetName:String = "targetPlayer"; var theTarget:DisplayObject = getChildByName(theTargetName); // this line checks to see if the dragged label matches the correct movieclip target map position if (event.target.dropTarget != null && event.target.dropTarget.parent == theTarget){ if(theTargetName=="targetPlayer"){ }; // required if a movieclip is a child of a button event.target.buttonMode = false; // set the dragged movieclip's postion to the target position event.target.x = theTarget.x; event.target.y = theTarget.y; //channelCorrect = correct.play(); //starts to drag the custom mouse again after the record has been dropped cursor_mc.startDrag("true"); } else { //starts to drag the custom mouse again after the record has been dropped cursor_mc.startDrag("true"); // put the shape back event.target.x = startX; event.target.y = startY; } // remove the existing listeners to prevent the labels being moved again //event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp); //event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt); // required if a movieclip is a child of a button //event.target.buttonMode = false; // set the dragged movieclip's postion to the target position //event.target.x = theTarget.x; //event.target.y = theTarget.y; } // required if movieclip is a child of a button to transfer event through the hierarchy record1.buttonMode = true; record2.buttonMode = true; record3.buttonMode = true; // Music player populated via XML formatted data with associated .mp3 audio files // songs to play structured as an XMLList class // displays artist and song title in the interface // song list base on an XMLList class var songList:XMLList; // total number of songs in list var songsTotal:Number; // sound class variable var sound:Sound; // sound channnel variable to play, pause and stop the sound var soundChannel:SoundChannel; // holds a reference to the current song playing var currentSong:Number = 0; // variable to store the song position when paused var songPosition:Number; // flag to check if current song is paused var songPaused:Boolean; // loader for XML via a URL var XMLLoader:URLLoader = new URLLoader(); // various buttons to control songs via the interface next_btn.addEventListener(MouseEvent.CLICK, onNext); prev_btn.addEventListener(MouseEvent.CLICK, onPrev); pause_btn.addEventListener(MouseEvent.CLICK, onPause); play_btn.addEventListener(MouseEvent.CLICK, onPlay); /*reset_bt.onRelease = function () { record1._x = 70.95 record1._y = 53.9 record2._x = 195.1 record2._y = 53.9 record3._x = 332.1 record3._y = 53 }*/ // load the XML formated playlist;# //XMLLoader.load(new URLRequest("reggae.xml")); //XMLLoader.load(new URLRequest("disco.xml")); //XMLLoader.load(new URLRequest("punk.xml")); function chooseEra (event:MouseEvent):void{ if (event.target.name == "record1") { XMLLoader.load(new URLRequest("reggae.xml")); } if (event.target.name == "record2") { XMLLoader.load(new URLRequest("punk.xml")); } if (event.target.name == "record3") { XMLLoader.load(new URLRequest("disco.xml")); } } // check the data has loaded correctly; XMLLoader.addEventListener(Event.COMPLETE, processXML); // this function processes the XML data; function processXML(e:Event):void { // create an XML playlist structure var anXMLplayList:XML = new XML(e.target.data); // associate the playlist songs with the internal song list songList = anXMLplayList.SONG; // set the total songs to those found in the XML data songsTotal = songList.length(); // remove the eventlistener and restore variables XMLLoader.removeEventListener(Event.COMPLETE, processXML); XMLLoader = null; } // this function starts the first song in the list // when the play_btn is pressed via the onPlay function function playSong(aSong:Number):void { // variables for the Title, Artist and associated song in the song list var aTitle = songList[aSong]. @ TITLE; var anArtist = songList[aSong]. @ ARTIST; var aURL = songList[aSong]. @ URL; var aChart = songList[aSong]. @ CHART; var aYear = songList[aSong]. @ YEAR; albumArtWork.source = songList[aSong]. @ IMAGE; addChild (albumArtWork); // populate the interface with the current song data title_txt.text = aTitle; artist_txt.text = anArtist; year_txt.text = aYear; chart_txt.text = aChart; // check to see if the sound channel is active if (soundChannel) { soundChannel.stop(); soundChannel.removeEventListener(Event.SOUND_COMPLETE, onNext); } // create a new sound object; sound = new Sound(); // load the sound from the URL song data sound.load(new URLRequest(aURL)); // activate the sound channel via the play method; soundChannel = sound.play(); // when the current songh completes - play the next song via the onNext function soundChannel.addEventListener(Event.SOUND_COMPLETE, onNext); } // this function plays the next song in the list; function onNext(e:Event):void { // increment the current song currentSong++; // reset the current song if no more to play if (currentSong >= songsTotal) { currentSong = 0; } // else play the current song via the playSong method playSong(currentSong); } // this function plays the previous song in the song list function onPrev(e:MouseEvent):void { currentSong--; if (currentSong < 0) { currentSong = songsTotal - 1; } playSong(currentSong); } // this function pauses the current song playing and sets the boolean flag // accordingly function onPause(e:MouseEvent):void { if (soundChannel) { songPosition = soundChannel.position; soundChannel.stop(); songPaused = true; } } // this function plays the current song or restarts a paused song function onPlay(e:MouseEvent):void { if (songPaused) { soundChannel = sound.play(songPosition); songPaused = false; } else if (!soundChannel) { playSong(currentSong); } }


Reply With Quote


Bookmarks