Error 1061 As3 Flash
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you
Call To A Possibly Undefined Method Addeventlistener Through A Reference With Static Type Class
might have Meta Discuss the workings and policies of this site call to a possibly undefined method play through a reference with static type class. About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting error Type 1061: Call to a possibly undefined method addEventListener through a reference with static type up vote 1 down vote favorite I moved my code from my Application to a separate AS class file and now I'm getting the following errors: 1061: Call to a possibly undefined method addEventListener through a reference with static type Class. 1180: Call to a possibly undefined method addEventListener. . package managers { import flash.events.Event; import flash.events.EventDispatcher; public class RemoteManager extends EventDispatcher { public function RemoteManager() { } public static function init(clearCache:Boolean = false):void { addEventListener(SETTINGS_CHANGE, settingChangeHandler); addEventListener(ITEMS_UPDATED, itemsUpdatedHandler); } } } actionscript-3 flex share|improve this question asked Aug 6 '12 at 10:02 1.21 gigawatts 3,969124691 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted Your code addEventListener(SETTINGS_CHANGE, settingChangeHandler); evaluates to this.addEventListener(SETTINGS_CHANGE, settingChangeHandler); There is no this in a static method, since it's designed to function without an instance. Furthermore, you cannot attach an event listener and dispatch events from a static class. Either change your function declaration to public function init(clearCache:Boolean = false):void Or implement a singleton pattern to kinda get a "static class, that dispatches events". Singleton with event management. share
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up AS3 Error http://stackoverflow.com/questions/11826131/getting-error-type-1061-call-to-a-possibly-undefined-method-addeventlistener-th 1061 Reference with Static Type up vote 0 down vote favorite I'm new to AS3, and trying to create a draggable element. However, I keep getting error 1061, and I don't know why, because I'm pretty sure I don't have any spelling errors or the like. Can someone please tell me what I'm doing wrong? Here is my code: package { import flash.display.*; import http://stackoverflow.com/questions/26268568/as3-error-1061-reference-with-static-type flash.events.*; import flash.geom.Rectangle; public class Script extends MovieClip{ public var value:Number; private var max:Number; private var min:Number; public function Draggable(){ min = erhu_mc.y; max = erhu_mc.height - Erhu_H3_btn.height; Erhu_H3_btn.addEventListener(MouseEvent.MOUSE_DOWN, dragHandle); } function dragHandle(event:MouseEvent):void { Erhu_H3_btn.startDrag(new Rectangle, false,(0,min,0,max)); stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging); } function stopDragging(event:MouseEvent):void { Erhu_H3_btn.stopDrag(); stage.removeEventListener(MouseEvent.MOUSE_UP, stopDragging); } } } actionscript-3 function flash share|improve this question asked Oct 9 '14 at 0:35 Anne 31 1 It's because Erhu_H3_btn is the name of a class, not an instance name of an object on the stage. –Marty Oct 9 '14 at 4:01 I don't understand...'Erhu_H3_btn' is the name of my button, which is on my stage...so why is it a class and not an instance name? –Anne Oct 9 '14 at 9:19 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted There are 2 issues with your current class. Erhu_H3_btn.startDrag(new Rectangle, false,(0,min,0,max)); needs to be: Erhu_H3_btn.startDrag(false,new Rectangle(0,min,0,max)); You can't directly reference objects from the timeline from a class.[ref] You will need to either pass a reference to the object, or a reference to the stage. For example, the following returns null: import flash.display.*; public
Du siehst YouTube auf Deutsch. Du kannst diese Einstellung unten ändern. Learn more You're viewing YouTube in German. You can https://www.youtube.com/watch?v=PKijMtmBx7Y change this preference below. Schließen Ja, ich möchte sie http://board.flashkit.com/board/showthread.php?821025-AS3-Error-1061 behalten Rückgängig machen Schließen Dieses Video ist nicht verfügbar. WiedergabelisteWarteschlangeWiedergabelisteWarteschlange Alle entfernenBeenden Wird geladen... Wiedergabeliste Warteschlange __count__/__total__ Flash AS3 Error Code 1061 Undefined Method Flashthingy AbonnierenAbonniertAbo beenden2.0712 Tsd. Wird geladen... Wird geladen... Wird verarbeitet... Hinzufügen Möchtest call to du dieses Video später noch einmal ansehen? Wenn du bei YouTube angemeldet bist, kannst du dieses Video zu einer Playlist hinzufügen. Anmelden Teilen Mehr Melden Möchtest du dieses Video melden? Melde dich an, um unangemessene Inhalte zu melden. Anmelden Statistik 405 Aufrufe 2 Dieses Video call to a gefällt dir? Melde dich bei YouTube an, damit dein Feedback gezählt wird. Anmelden 3 1 Dieses Video gefällt dir nicht? Melde dich bei YouTube an, damit dein Feedback gezählt wird. Anmelden 2 Wird geladen... Wird geladen... Wird geladen... Die Bewertungsfunktion ist nach Ausleihen des Videos verfügbar. Diese Funktion ist zurzeit nicht verfügbar. Bitte versuche es später erneut. Veröffentlicht am 25.11.2014This is video show a very simple way to rectify that 1061 error code undefined method. This is not the solution for all 1061 error codes. Kategorie Praktische Tipps & Styling Lizenz Standard-YouTube-Lizenz Mehr anzeigen Weniger anzeigen Wird geladen... Anzeige Autoplay Wenn Autoplay aktiviert ist, wird die Wiedergabe automatisch mit einem der aktuellen Videovorschläge fortgesetzt. Nächstes Video Creating Linked Text Fields Using AS3 in Flash CS5 - Dauer: 10:59 flashandmath 20.100 Aufrufe 10:59 Ho
this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread: [AS3] Error 1061 Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 02-06-2011,02:59 PM #1 Axiomonline View Profile View Forum Posts Member Join Date May 2005 Posts 95 [AS3] Error 1061 Hey there, Working on a new game, and while it LOOKS like everything is happy scrappy... it's not. When I test run I keep getting the following error: 1061: Call to a possibly undefined method hitTestObject through a reference with static type Class. What I THINK this means is that I dont have the actual file *pointing* to the Dungeon Manager class I created. Since it looks to me like the hitTestObject method is correct. Any insight would be fantastic, Heres the project: http://www.filefactory.com/file/b54f...O_DIABOLIK.rar Reply With Quote 02-07-2011,01:54 PM #2 realMakc View Profile View Forum Posts Senior Member Join Date Oct 2002 Posts 822 it says, you are calling method on the class, not the instance of the class who is this? a word of friendly advice: FFS stop using AS2 Reply With Quote 02-08-2011,01:17 PM #3 Axiomonline View Profile View Forum Posts Member Join Date May 2005 Posts 95 Okay, that kind of helped. But according to the book I am going from, A method call calls a trigger directives in the method's function definition. Isn't that what I want here? Plus, what is the difference between a method call and instance call and how can you tell which is needed? Reply With Quote 02-08-2011,06:58 PM #4 realMakc View Profile View Forum Posts Senior Member Join Date Oct 2002 Posts 822 A method call calls a trigger directives in the method's function definition A "method" is simply a synonym for function which is defined as a part of class vs "standalone" function, which is called just "function". so calling a method, or calling a function, triggers statements in its body - that's what your book said, probably. what is the difference between a method call and instance call methods may be defined for the class (and then you cal ClassName.methodName()) or for an instance of the class (and then you call instance.methodName()). In this case, you are trying to call the method defined for an instance as if it was defined for the class. how can you tell which is needed? you look up the declaration of met