As3.0 Error 1061
Contents |
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 call to a possibly undefined method addeventlistener through a reference with static type class more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Call To A Possibly Undefined Method Play Through A Reference With Static Type Class.
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 Flash compiler error 1061: Call to a possibly undefined method run… but run exists! up vote 0 down vote favorite So I've been working on making a game in Processing but I think Flash would be a better way to get more people playing it, so I've decided to learn Flash. The problem is that I keep getting really stupid errors on incredibly simple things. For instance, I want to make a 'Block' object to use in a platform game. So I make a new .as file, name it Block.as, and define the Block class within it like so: package { public class Block { public function Block() { // constructor code } public function run() { } } } I don't want to add the code yet, I just want to ensure that this works. So in my main timeline code, I try to create an instance of the Block object and execute its run method: var block1:Block = new Block(); block1.run(); Every time it gives me this inane error: Scene 1, Layer 'Layer 1', Frame 1, Line 2 1061: Call to a possibly undefined method run through a reference with static type Block. What undefined method!? It's defined RIGHT THERE in Block.as. The class file is even in the same folder and everything. I'm getting REALLY annoyed at how poorly Flash handles such a ridiculously simple project. Does anyone know why Flash hates me? flash class properties undefined share|improve this question edited Mar 1 '11 at 23:20 scriptocalypse 3,83121835 asked Mar 1 '11 at 22:57 Zane Geiger 132210 your code works for me, even without a return type: clearmpls.com/temp/block.zip –jpea Mar 1 '11 at 23:06 That was a completely idiotic question title! Thanks, scriptocalypse, for cleaning it up. –Josh Stodola Mar 1 '11 at 23:21 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted You didn't declare a return type for run. public functio
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 1061 Reference with Static Type up vote 0 down vote favorite I'm http://stackoverflow.com/questions/5161437/flash-compiler-error-1061-call-to-a-possibly-undefined-method-run-but-run-ex 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 flash.events.*; import flash.geom.Rectangle; public class Script extends MovieClip{ public var value:Number; private var max:Number; private var min:Number; public http://stackoverflow.com/questions/26268568/as3-error-1061-reference-with-static-type 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 class Script extends MovieClip { public function Script() { trace(stage); } I copied and moded your code so that it works on a frame.: import flash.display.*; import flash.events.*; import flash.geom.Rectangle; var value:Number; var max:Number; var min:Num
What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security. We suggest you http://www.kongregate.com/forums/4-game-programming/topics/280840-as3-error-1061 install the latest version of one of these browsers: Download Google Chrome Download Mozilla Firefox Download Microsoft Edge Download Apple Safari No Thanks … Kongregate p0 l0 f m s Settings Sign Out Sign in Register or Sign in: Username or email Password Remember me Forgot password? Games Categories Top Rated Action Multiplayer Hot New MMO Adventure & RPG My Favorites Strategy & call to Defense Shooter Upgrades Tower Defense Sports/Racing Zombie MMO More Categories Achievements Badges Recommended for Me Action Badges Rarest Badges Racing Badges Easiest Unearned Puzzle Badges Newest Badges All Badges Quests All Quests My Kong Trending with Friends Activity Feed g Register or sign in to start receiving activity updates from around Kongregate! Forums Kongregate Game Forums General Gaming Technical Support Game Programming All Forums Dev call to a Upload Your Game Kongregate is a community-driven browser games portal with an open platform for all web games. Get your games in front of thousands of users while monetizing through ads and virtual goods. Learn more » Visit our developers site » Learn more about our publishing program - we help game developers get their games out to millions of users on multiple platforms. Read Our Blog » We publish new content weekly, on game/data analysis, case studies, engineering solutions, and design insights. Access Documentation » Get everything you need to know about how to implement our APIs and SDKs into your game. see more results » {"url":"/search"} X Complete Initialization for 10 kreds 15% « Previous Next » Congratulations! You’ve completed your Kongregate account! Keep exploring Kongregate with more badges and games! Hide the progress bar forever? Yes No Forums → Game Programming → [AS3] Error 1061 (Solved) Limit my search to this forum 5 posts Sign in to reply There was an error. Delete post THIS IS A SPINNER or cancel THIS IS A SPINNER Jul 13, 2012 1:19pm lautaro52 35 posts metadata Hello! i am