As3 Error Call To A Possibly Undefined Method Dispatchevent
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and call to a possibly undefined method addeventlistener policies of this site About Us Learn more about Stack Overflow the
Call To A Possibly Undefined Method Addeventlistener Through A Reference With Static Type Class
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 Call to possibly undefined method dispatchEvent through a reference with static type GetColor up vote 1 down vote favorite I'm writing a program using Main.as, that needs to listen to a function (getColor) in another class file (GetColor.as). I have the following in GetColor.as: public class GetColor { public function getColor(event:MouseEvent):void { //doing stuff here this.dispatchEvent(new Event("changeColor") ); } } and then in Main.as I have: var getPicColor:GetColor = new GetColor(); getPicColor.addEventListener("changeColor",changeColorNow); function changeColorNow(e:Event):void { //do stuff here } However, I am getting an error: 1061: Call to a possibly undefined method dispatchEvent through a reference with static type GetColor. What does this mean? I have nothing declared as static. Am I supposed to create an instance of dispatchEvent(), as opposed to using "this"? actionscript-3 flash dispatchevent share|improve this question asked May 7 '15 at 15:05 UMich_2017 718 1 Try: public class GetColor extends EventDispatcher –marbel82 May 7 '15 at 18:28 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote You cannot dispatch events with a class that (implicitly) extends Object -> that's why you are getting there error -> where is "dispatchEvent()" method coming from? Where is it inherited from? (answer: it is not!) Your GetColor class (horrible name there! :) ) must either extend a display object - which in your case it not really the correct solution, extend EventDispatcher or implement IEventDispatcher. Then you can use the met
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 http://stackoverflow.com/questions/30104968/call-to-possibly-undefined-method-dispatchevent-through-a-reference-with-static each other. Join them; it only takes a minute: Sign up MVC AS3 Error: Call to a possibly undefined method through a reference with static type up vote 0 down vote favorite I'm new to AS3 from Java and was trying to implement a Java style as3 mvc implementation which essentially has two views with an input http://stackoverflow.com/questions/26374121/mvc-as3-error-call-to-a-possibly-undefined-method-through-a-reference-with-stat field and text box which has it's contents changed by buttons. I keep getting Error: Call to a possibly undefined method handleMouseClick through a reference with static type controller:Controller. and can't understand why. This is for the function handleMouseClick in TextToolsView Here is my code (sorry for it being so long, I'm not sure how to condense it further without losing my error): TextModel package model { import flash.events.Event; import flash.events.EventDispatcher; public class TextModel extends EventDispatcher { private var text:String = new String(); private var initialText:String = new String("Initial Text"); public function TextModel() { setText(initialText); } public function setText(text:String):void { this.text = text; } public function getText():String { return this.text; } public function updateText(text:String):void { setText(text); dispatchEvent(new Event(Event.CHANGE)); } public function clearText():void { setText("Text has been cleared"); dispatchEvent(new Event(Event.CHANGE)); } public function resetText():void { setText(initialText); dispatchEvent(new Event(Event.CHANGE)); } } } TextController package controller { import flash.events.MouseEvent; import model.TextModel; public class TextController extends AbstractController { /** * Constructor * @param m model to modify */ public function TextController(m:TextModel) { super(m); } priv
using your existing account on the new forums, check out this thread. https://www.kirupa.com/forum/showthread.php?270700-eventDispatcher-Problem Register Help Remember Me? Forum Today's Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links View Forum Leaders What's New? Advanced Search Forum Flash ActionScript 3 eventDispatcher Problem Results 1 to 3 of 3 Thread: eventDispatcher Problem Thread Tools Show Printable Version Subscribe to this Thread… Search Thread call to Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode August 2nd, 2007,06:58 PM #1 mrmyers View Profile View Forum Posts 19 posts Registered User eventDispatcher Problem Hey All, Just recently started with AS3 and have hit a wall with the eventDispatcher and creating custom events. call to a I can't see what I am doing wrong: My class file: Code: package resources.methodCalls{ import flash.display.*; import flash.net.*; import flash.events.*; import flash.media.*; public class requests { public var requestedArray : Array = []; // requests class constructor public function requests() { } public function varCompiler(method:String, url:String, missionID:String, assignment:String, versionID:String) { //establish opening and closing XML tags var requestXML:XML =