SEARCH YOUR SOLUTION HERE  

The supplied DisplayObject must be a child of the caller.

What does it mean And why doesnt my code work
PHP Code: stop();
importflash.events.Event;
varTimerApple:Timer=newTimer(500);

TimerApple.addEventListener(TimerEvent.TIMER,OnStartApple);

TimerApple.start();

functionOnStartApple(e:Event){

varaf:Sprite=newEnemy();
af.x=Math.random()*640;
addChild(af);

//Removefromstage,willgivepoint
af.addEventListener(Event.ENTER_FRAME,hitTheGround)
functionhitTheGround(e:Event):void
{
if(af.hitTestObject(Basket)){
removeChild(af);
}
}

//Controllingbasket
Basket.addEventListener(MouseEvent.MOUSE_DOWN,fl_ClickToDrag_2);

functionfl_ClickToDrag_2(event:MouseEvent):void
{
Basket.startDrag();
}

}
And then the class "Enemy"
PHP Code: package{
importflash.events.Event;
importflash.display.MovieClip;
importflash.display.Sprite;
importflash.text.TextField;
publicclassAppleextendsSprite{
privatevarcore:Object;
publicfunctionApple(){
addEventListener(Event.ADDED_TO_STAGE,onadd);
}

privatefunctiononadd(e:Event){
core=MovieClip(root);
addEventListener(Event.ENTER_FRAME,loop);
}

privatefunctionloop(e:Event){
y+=10;
}


publicfunctionremoveListeners():void{
removeEventListener(Event.ENTER_FRAME,loop);
}
}
}

Posted On: Thursday 25th of October 2012 09:26:56 PM Total Views:  235
View Complete with Replies




Related Messages:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller   (57 Views)
Would I have to go backwards to delete it
Flash "The supplied DisplayObject must be a child of the caller"   (52 Views)
. I got an annoying problem that I can't figure out. Code: package { import flash.display.MovieClip; import flash.events.*; public class PhotoBrowser extends MovieClip { var thumbnails:Array = new Array(); public function PhotoBrowser() { continue_btn.addEventListener(MouseEvent.CLICK, playMovie); forward.addEventListener(MouseEvent.CLICK, gotoFrame40); backward.addEventListener(MouseEvent.CLICK, gotoFrame20); search_btn.addEventListener(MouseEvent.CLICK, search); } function playMovie(e:MouseEvent) { play(); } function gotoFrame40(e:MouseEvent):void { gotoAndStop(40); } function gotoFrame20(e:MouseEvent) { gotoAndStop(20); for (var p:int = 0; p < thumbnails.length; p++) { thumbnails[p].visible = true; } } function gotoLargeThumb(e:MouseEvent):void { gotoAndStop(40); for (var k:int = 0; k < thumbnails.length; k++) { thumbnails[k].visible = false; } } function search(e:MouseEvent) { var query:int = int(search_txt.text); trace(query); for (var n:int = 0; n < thumbnails.length; n++) { this.removeChild(thumbnails[n]); thumbnails[n].removeEventListener(MouseEvent.CLICK, gotoLargeThumb); } var xpos:int = 105; var ypos:int = 265; for (var i:int = 0; i < query; i++) { var thumb:Thumbnail = new Thumbnail(); thumb.scaleX = 0.5; thumb.scaleY = 0.5; thumb.x = xpos; thumb.y = ypos; xpos += thumb.width + 10; thumbnails[i] = thumb; this.addChild(thumbnails[i]); thumbnails[i].addEventListener(MouseEvent.CLICK, gotoLargeThumb); } } } } Output: 1 2 3 4 3 2 ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display:isplayObjectContainer/removeChild() at PhotoBrowser/search()
event target vs displayobject?   (69 Views)
A MouseEvent target that needs to end up in a displayobject variable.. how would I pull that off ie Code: private function skRollOver(e:MouseEvent):void { e.target; // is a regular Object Why isn't it reporting back a displayobject }
Dragging on nested displayobjects   (84 Views)
I have many displayobjects on the screen, with a textfield inside each using the common MOUSE_DOWN listener +startDrag event.target approach, but theres a problem when the mosue click near to a textfield object, which cant be dragged is there a way to make the target be the highest displayObject/ draggable object any suggestions
Error #2025: The supplied DisplayObject must be a child of the caller.   (74 Views)
Error #2025: The supplied DisplayObject must be a child of the caller is the message I'm getting when I try to remove all the movieclips in an array. I understand why it's happening: I've already removed one of the movieclips earlier. I tried putting an if statement in the loop to remove it, but the movie clip still exist, and the trace statement doesn't return null. for(var i=0;i
Error #2007: Parameter text must be non-null   (86 Views)
this may be somehow a common error, but I couldn't track down where is the problem. I'm getting the following error trying to use a code to randomly pick a quote from a xml file. The flash/code works fine, however in IE eventually the error shows up which is really annoying. In Firefox it seems like everything is working fine. The error is: TypeError: Error #2007: Parameter text must be non-null. at flash.text::TextField/set text() at quotes_fla::MainTimeline/rotateQuote() at flash.utils::Timer/flash.utils:Timer::_timerDispatch() at flash.utils::Timer/flash.utils:Timer::tick() Code: import caurina.transitions.Tweener; var quote:Array = new Array(); var totalQuotes:Number; quoteMC.alpha = 0; var rotateTimer:Timer = new Timer(5000, 100);//rotates the quote every 2 seconds for 100 times rotateTimer.addEventListener("timer", rotateQuote);//add a listener to the timer rotateTimer.start();// start the timer function init():void { var quotesXML:XML = new XML(); quotesXML.ignoreWhitespace = true; var XMLURL:URLRequest = new URLRequest("flash/quotes1.xml"); var myLoader:URLLoader = new URLLoader(XMLURL); myLoader.addEventListener("complete", xmlLoaded); function xmlLoaded(event:Event):void { quotesXML = XML(myLoader.data); totalQuotes = quotesXML.quote.length(); for (var i:int = 0; i < quotesXML.quote.length(); i++) { quote[i] = quotesXML.quote[i].text; } var initRandom:Number = randomNumber(0, totalQuotes); Tweener.addTween(quoteMC, {alpha:1, time:5}); quoteMC.quote_txt.text = String(quote[initRandom]); } } function rotateQuote(evt:TimerEvent) { quoteMC.alpha = 0; Tweener.addTween(quoteMC, {alpha:1, time:5}); quoteMC.quote_txt.text = ""; var randomness:Number = randomNumber(0, totalQuotes); quoteMC.quote_txt.text = quote[randomness]; } function randomNumber(low:Number, high:Number):Number { var low:Number = low; var high:Number = high; return Math.round(Math.random() * high - low) + low; } init(); I'm totally new at as3 so any help will be welcome.
Left side of assignment operator must be variable or property   (144 Views)
Hi , thanks for all the help so far, i'm hoping this is an easy one for you to help me with. Actionscript Code: if (B_AuthorBox.text = "" && B_TitleBox.text =""){ BookVar = BookVar; } else {BookVar = BookVar +1;} I keep getting this message Left side of assignment operator must be variable or property How can I get around it
Left side of assignment operator must be variable or property.   (82 Views)
I'm trying to do this.. on(release) { if(b1boolean && b2boolean && b3boolean && b4boolean = true{ gotoAndPlay("Correct",1); } } but i keep getting this.. Left side of assignment operator must be variable or property. everytime i try it. and if i change "=" to "==" i get.. ')' expected So whats wrong :S
Statement must appear within on handler error   (72 Views)
novice AS coder, trying to get a simple flash form to submit data to a php script, then get data back from the script. the "send" button has this code: on(release) { //assign user-input value to lv property called years lvOut.years = years.text; //send to a blank window... lvOut.send(path + "test.php","_blank"); //get results returned to lvIn form.sendAndLoad("test.php", lvIn, "POST"); } lvIn = new LoadVars(); //create lv object lvIn.onLoad = function (success) { if(success){ //PHP variable value to textbox output.text = lvIn.returnVal; }else{ //...or notify of failure output.text = "fail"; } } and throws 2 errors: **Error** Symbol=form_mc, layer=btn, frame=1, Line 10: Statement must appear within on handler lvIn = new LoadVars(); //create lv object **Error** Symbol=form_mc, layer=btn, frame=1, Line 11: Statement must appear within on handler lvIn.onLoad = function (success) I want the var "lvIn" to hold the data from the php script. I'm sure this is easy, but, being a beginner w/ AS I am in need of kind assistance.
user must be unable to select any dates after today (future dates)   (77 Views)
, You can find the file in the attachment. It's not the site, but it's the datechooser I use as base. I found this code and this is probably the one I need, with a little modifications. The question is: in what place do I have to insert this code and to what object I need to link it The target is that the user can't select a day in the future. comp.disabledRanges = [ {rangeStart: new Date(mydate.getYear, mydate.getMonth, mydate.getDay)} ]; I also found this one: if (selectecDate > Date) { alert("This date can't be in the future"); return false } Could someone please provide some help It's getting extremely urgent as I need to deliver the project today!
Importing 255+ sprite images...must be an easier way!   (75 Views)
! I'm trying to import 259 images *sprite based* due to the fact that Flash CS3 Pro won't import uncompressed .avi videos without making them look terrible and very low quality. I'm designing flash that will run on a local computer and will require no downloading but all the import options are download based thus limiting the quality of video to 9999kbps :\ So i'm forced to sprite my video and manually put ONE sprite per frame so form high quality animation.... PLEASE tell me there's a faster way for me to import 259 sprites into 259 frames than to go in ONE BY ONE and move them to the box manually lol You'd think that for such high end software there would be an option to high light all your sprites and move them to the frames in order :\
RangeError: Error #2006: The supplied index is out of bounds.   (54 Views)
Trying to make a quiz (AS3) and I'm receiving an error when I do true/false questions. My quiz doesn't seem to like when you have only 2 answers. RangeError: Error #2006: The supplied index is out of bounds. at flash.display:: DisplayObjectContainer/getChildAt() at TriviaGameDeluxe/finishQuestion() at TriviaGameDeluxe/clickAnswer() Here is the .as file package { import flash.display.*; import flash.text.*; import flash.events.*; import flash.net.URLLoader; import flash.net.URLRequest; //import flash.utils.Timer; public class TriviaGameDeluxe extends MovieClip { // question data private var dataXML:XML; // text formats private var questionFormat:TextFormat; private var answerFormat:TextFormat; private var scoreFormat:TextFormat; private var hintFormat:TextFormat; // text fields private var messageField:TextField; private var questionField:TextField; private var scoreField:TextField; // sprites and objects private var gameSprite:Sprite; private var questionSprite:Sprite; private var answerSprites:Sprite; private var gameButton:GameButton; private var hintButton:GameButton; //private var clock:Clock; // game state variables private var questionNum:int; private var correctAnswer:String; private var numQuestionsAsked:int; private var numCorrect:int; private var answers:Array; private var questionPoints:int; private var gameScore:int; public function startTriviaGame() { // create game sprite gameSprite = new Sprite(); addChild(gameSprite); // set text formats questionFormat = new TextFormat("Arial",24,0x330000,true,false,false,nu ll,null,"center"); answerFormat = new TextFormat("Arial",18,0x330000,true,false,false,nu ll,null,"left"); scoreFormat = new TextFormat("Arial",18,0x330000,true,false,false,nu ll,null,"center"); hintFormat = new TextFormat("Arial",14,0x330000,true,false,false,nu ll,null,"center"); // create score field and starting message text scoreField = createText("",questionFormat,gameSprite,0,440,550) ; messageField = createText("Loading Questions...",questionFormat,gameSprite,0,50,550); // set up game state and load questions questionNum = 0; numQuestionsAsked = 0; numCorrect = 0; gameScore = 0; showGameScore(); xmlImport(); } // start loading of questions public function xmlImport() { var xmlURL:URLRequest = new URLRequest("trivia2.xml"); var xmlLoader:URLLoader = new URLLoader(xmlURL); xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); } // questions loaded public function xmlLoaded(event:Event) { var tempXML:XML = XML(event.target.data); dataXML = selectQuestions(tempXML,10); gameSprite.removeChild(messageField); messageField = createText("Get ready for the first question!",questionFormat,gameSprite,0,60,550); showGameButton("GO!"); } // select a number of random questions public function selectQuestions(allXML:XML, numToChoose:int):XML { // create a new XML object to hold the questions var chosenXML:XML = ; // loop until we have enough while(chosenXML.child("*").length() < numToChoose) { // pick a random question and move it over var r:int = Math.floor(Math.random()*allXML.child("*").length( )); chosenXML.appendChild(allXML.item[r].copy()); // don't use it again delete allXML.item[r]; } // ret return chosenXML; } // creates a text field public function createText(text:String, tf:TextFormat, s:Sprite, x,y: Number, width:Number): TextField { var tField:TextField = new TextField(); tField.x = x; tField.y = y; tField.width = width; tField.defaultTextFormat = tf; tField.selectable = false; tField.multiline = true; tField.wordWrap = true; if (tf.align == "left") { tField.autoSize = TextFieldAutoSize.LEFT; } else { tField.autoSize = TextFieldAutoSize.CENTER; } tField.text = text; s.addChild(tField); return tField; } // updates the score public function showGameScore() { scoreField.text = "Number of Questions: "+numQuestionsAsked+" Number Correct: "+numCorrect; } // ask player if they are ready for next question public function showGameButton(buttonLabel:String) { gameButton = new GameButton(); gameButton.label.text = buttonLabel; gameButton.x = 220; gameButton.y = 300; gameSprite.addChild(gameButton); gameButton.addEventListener(MouseEvent.CLICK,press edGameButton); } // player is ready public function pressedGameButton(event:MouseEvent) { // clean up question if (questionSprite != null) { gameSprite.removeChild(questionSprite); } // remove button and message gameSprite.removeChild(gameButton); gameSprite.removeChild(messageField); // ask the next question if (questionNum >= dataXML.child("*").length()) { gotoAndStop("gameover"); } else { askQuestion(); } } // set up the question public function askQuestion() { // prepare new question sprite questionSprite = new Sprite(); gameSprite.addChild(questionSprite); // create text field for question var question:String = dataXML.item[questionNum].question; questionField = createText(question,questionFormat,questionSprite, 0,60,550); // create sprite for answers, get correct answer and shuffle all correctAnswer = dataXML.item[questionNum].answers.answer[0]; answers = shuffleAnswers(dataXML.item[questionNum].answers); // put each answer into a new sprite with a circle icon answerSprites = new Sprite(); for(var i:int=0;i 0) { var r:int = Math.floor(Math.random()*answers.child("*").length ()); shuffledAnswers.push(answers.answer[r]); delete answers.answer[r]; } return shuffledAnswers; } public function pressedHintButton(event:MouseEvent) { // remove button gameSprite.removeChild(hintButton); hintButton = null; // penalty questionPoints -= 300; showGameScore(); // show hint var hint:String = dataXML.item[questionNum].hint; var hintField:TextField = createText(hint,hintFormat,questionSprite,0,390,55 0); } */ // player selects an answer public function clickAnswer(event:MouseEvent) { // get selected answer text, and compare var selectedAnswer = event.currentTarget.getChildAt(0).text; if (selectedAnswer == correctAnswer) { numCorrect++; messageField = createText("You got it!",questionFormat,gameSprite,0,180,550); //gameScore += questionPoints; } else { messageField = createText("Incorrect! The correct answer was:",questionFormat,gameSprite,0,180,550); } finishQuestion(); } public function finishQuestion() { // remove all but the correct answer for(var i:int=0;i
How do I call the slide show swf that must be added ABOVE the main swf in the Display   (62 Views)
We're building a new Flash Web Site. I've been able to pretty much figure out how to get everything to work together, but my designer wife has thrown me a curve ball I can't hit. Basics: The site operates around a swf named main.swf. the different content areas are external swfs called by a navbar in main.swf. One of the primary content areas is a gallery of our work, with five separate types; branding, package design, collateral, Internet, and Digital. The left hand swf for the Gallery section contains five movie clips that let you select the specific gallery area that displays on the right hand side. Included in the right hand area are thumbnails (movie clips) that when clicked she wants a Greybox-like slide show to appear over the entire area (1100x x 690), INCLUDING the main.swf. As I currently envision it, this is an 1100 x 690 XML-driven portfolio swf, with the alpha of the overall stage box at about 30%, and the actual gallery centered. If I haven't lost you, my challenge is to call the slide show swf from a click event in the thumbnail on the right hand side. If I understand the Display Object Model this swf is about three levels removed from the stage. How do I call the slide show swf that must be added ABOVE the main swf in the Display List from a click on the right hand area thumbnail I'm gaining a better understanding of classes, and am using them to hold all the AS for the external swfs. Basically I need to be able to talk to the main swf from the brandRight.swf which is the right hand swf containing the thumbnails. I'll be happy to post current code and further explain what's happening. If there is a better overall strategy to use for this I'm all ears (as Ross used to say!).
Classes must not be nested?   (80 Views)
I created a new Flash file (Actionscript 3) and pasted this code on the first frame: ActionScript Code: class TestClass1 extends Object { public function identify() { trace('i am class one'); } } var obj:Object; obj = new TestClass1(); obj.identify(); I get the error 1131: Classes must not be nested What am I doing wrong
Help with Error#2007: Parameter hitTestObject must be non-null.   (62 Views)
I am taking a class on lynda.com. Even though I followed all the code, the drag and drop game still does not work. The object I am moving does not snap to the target and an error pops up. This is my DragDrop class: package { import flash.display.*; import flash.events.*; public class DragDrop extends Sprite { var origX:Number; var origY:Number; var target:DisplayObject; public function DragDrop() { origX = x; origY = y; addEventListener(MouseEvent.MOUSE_DOWN, drag); buttonMode = true; } function drag(evt:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_UP, drop); startDrag(); parent.addChild(this); } function drop(evt:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_UP, drop); stopDrag(); if(hitTestObject(target)) { visible = false; target.alpha = 1; Object(parent).match(); } x = origX; y = origY; } } } I get this error when I try to move an object in the test movie. I am guessing defining target as DisplayObject at the beginning is not enough TypeError: Error #2007: Parameter hitTestObject must be non-null. at flash.display::DisplayObject/flash.display:DisplayObject::_hitTest() at flash.display::DisplayObject/hitTestObject() at DragDrop/::drop()
Statement must appear within on handler error   (122 Views)
hi , when i am using this code. submit.onPress = function(){ if(Title.text!="" && Comments.text !="" && Image.text!=""){ myData.Title = Title.text myData.Comments = Comments.text myData.Image = Image.text myData.sendAndLoad("save.php", myData, "POST") } } stop() its is generating an error mgs...i.e **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler button.onPress = function(){ Total ActionScript Errors: 1 Reported Errors: 1 why so please help me... i am using Macromedia flash 8 which support as2...
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded   (62 Views)
... Again.. a big problem for contact forms .. Im using Cs5 .. publishing in FP10 and usign AS3... I've read a lot of webs trying to find a solution and found possible one.. to change: URLLoaderDataFormat.VARIABLES; for URLLoaderDataFormat.TEXT; already did this but the same error persist... Any ideas why this happens Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. at Error$/throwError() at flash.net::URLVariables/decode() at flash.net::URLVariables() at contact_fla::MainTimeline/sendMessage() And this is the code stop(); import flash.events.MouseEvent; import flash.net.URLRequest; import flash.net.URLRequestMethod; import flash.net.URLLoader; import flash.net.URLLoaderDataFormat; import flash.net.URLVariables; import flash.events.*; import flash.net.*; contact_name.text = contact_company.text = contact_email.text = contact_subject.text = contact_message.text = message_status.text = ""; var var_load:URLLoader = new URLLoader ; var URL_request:URLRequest = new URLRequest("send_mail.php"); URL_request.method = URLRequestMethod.POST; btn_submit.addEventListener(MouseEvent.CLICK, sendMessage); function sendMessage(event:MouseEvent):void { if (contact_name.text == "" || contact_company.text == "" || contact_email.text == "" || contact_subject.text == "" || contact_message.text == "") { message_status.text = "PLEASE FILL UP ALL THE TEXT FIELDS"; } else if (!validate_email(contact_email.text)) { message_status.text = "PLEASE ENTER A VALID EMAIL ADRESS"; } else { var email_data:String = "$name=" + contact_name.text + "&company=" + contact_company.text + "&email=" + contact_email.text + "&subject" + contact_subject.text + "&message" + contact_message.text; var URL_vars:URLVariables = new URLVariables(email_data); URL_vars.dataFormat = URLLoaderDataFormat.TEXT; URL_request.data = URL_vars; var_load.load( URL_request ); var_load.addEventListener(Event.COMPLETE, receive_response ); } } function validate_email(s:String):Boolean { var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/; var r:Object = p.exec(s); if (r == null) { return false; } return true; } btn_clear.addEventListener(MouseEvent.CLICK, clearInfo); function clearInfo(event:MouseEvent):void { contact_message.text = ""; } function receive_response(e:Event):void { var loader:URLLoader = URLLoader(e.target); var email_status = new URLVariables(loader.data).success; if (email_status == "yes") { gotoAndStop(2); } else { message_status.text = "FAILED - YOUR MESSAGE CANNOT SENT"; } }
DisplayObject must be a child of the caller   (86 Views)
Hi all, hope you can assist me with this problem I'm having. I'm basically trying to refresh a jpg image every second from within my flash project. The code so far: Code: //This function is called from the loader's event listener. //It moves the loaded image into the appropriate container for display function imgLoaded(event:Event):void { movie.get_picture.addChild(l.content); }; //This is the function called by the timer that performs all the above //loading steps each time the timer ticks. This updates the image once per //second. function refresh_url(event:TimerEvent){ var unique = new Date().getTime(); var url:String = "http://www.live-photo.com/asheville-.jpg" + unique; var urlReq:URLRequest = new URLRequest(url); l.load(urlReq); l.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded); }; //Create the timer object that will call the function to update the image //object once per second. var myTimer = new Timer(1000); //Add an event listener to the timer to refresh the image every time the timer //ticks myTimer.addEventListener("timer",refresh_url); //Start the timer myTimer.start(); The image refreshes, but only on what looks like every 2nd call to the refresh_url function. It will load the image once, then it will throw an error: Quote: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::Loader/flash.display:Loader::_load() at flash.display::Loader/load() at map_project1_fla::MainTimeline/refresh_url() at flash.utils::Timer/flash.utils:Timer::_timerDispatch() at flash.utils::Timer/flash.utils:Timer::tick() And then it will load the picture, then it will throw the error, then load, then throw, etc... What do I need to do to avoid this error
Depth RangeError: Error #2006: The supplied index is out of bounds.   (60 Views)
I'm trying to layer lots of objects behind each other depending on there y position. each clip is added dynamically and assigned a numer as its name, then im trying to use the set child index to set its depth... Code: var number:Number = Number(movie.name); setChildIndex(movie, number); I get the error "The supplied index is out of bounds.", what does this mean and how can i fix it,
not sure how to fix this error: The Class "Ball" must subclass...   (154 Views)
So I am trying to create a document class for my program, and I know all the code is correct because I already have the program working. I am currently trying to rebuild the program, and I simply copy and pasted all the working code into my new program. I have 2 document classes, and when I run the program i get an error, and I don't know how to fix it. It says "The class 'ball' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type." I don't understand why it isn't working now, is there some setting that I need to turn on to get it to work I do have the line of code : import flash.display.MovieClip; Can anyone help Let me know if you need more information about my program.