Access of undefined method/property through reference with a static type Class

I get the following error: (it's not word for word but you get the idea)
Error: Access of undefined method getStatus through reference with a static type Class.
Here's what's happening in the code. I'm trying to create a User class that is instantiated at the start of my app. I want the User class to have properties like mainStatus, with helper methods like setStatus etc. Pretty simple.
so on my HardDisk I have my flash_working folder with all my flash projects. I created my class file/package under the directory com.mypackage
package com.mypackage
    import flash.display.*;
    public class User extends Sprite
        public var mainStatus:int;
        public function User()
            trace("User Created!");
            mainStatus = 0;
        public function setStatus(status:int):void
         mainStatus = status;
    public function getStatus():int
        return mainStatus;
Ok, so far so good.
now I created a new .fla file under the root of /flash_working/. The class file is in /com/mypackage/User.as
in my .fla file I have:
import com.mypackage.User;
var myUser:User = new User();
var i = User.getStatus();
trace(i);
That's all the code I have. Could someone please explain why it's giving me that error?
If I try to access the public var mainStatus through user.mainStatus that gives a similar error saying:
Error: Access of undefined property mainStatus through reference with a static type Class.
Thanks for any help!
jef3189

the public getStatus() function that you created needs to be referred to through an instance of the class.
So:
import com.mypackage.User;
var myUser:User = new User();
var i = myUser.getStatus();
trace(i);
Also, an aside. You can create a getter/setter for status, to avoid having to do the function as such.
package com.mypackage
    import flash.display.*;
    public class User extends Sprite
        public var mainStatus:int;
        public function get status():int
            return mainStatus;
        public function set status(value:int):void
             mainStatus = value as int;
          public function User()
            trace("User Created!");
            mainStatus = 0;
And then, you can call it as:
import com.mypackage.User;
var myUser:User = new User();
trace(myUser.status);
EDIT
I just noticed that you made the variable public as well, which means you can access it without getter/setter or function.
import com.mypackage.User;
var myUser:User = new User();
trace(myUser.mainStatus);

Similar Messages

  • Call to a possibly undefined method getClipboardContents through a reference with static type flashx.textLayout.edit:ISelectionManager.

    Hi Guys,
    As i am using the nigtly build of TLF 4.0.0.11073.
    I want to copy some text from the TLF, by copy operation. I am getting this type of Error.
    - Call to a possibly undefined method getClipboardContents through a reference with static type flashx.textLayout.edit:ISelectionManager.
    In the previous build, i dont use to get this type of error, but in this nightly builds i am getting this type of error.
    Can anyone help me to fix the same or any workaound.
    Thanks in advance.
    Krishna

    This functionality is still available, but it has moved. It's now in a TextClipboard class, in the same flashx.textLayout.edit package. So you should replace calls to getClipboardFormat() with TextClipboard.getContents().
    Hope this helps,
    - robin

  • If a  class method exporting a value with the generic type 'data'.

    Then how can I get the information?
    For exmple.
    cl_my_clss->get_value( exporting ev_data = .... ) .
    ev_data is a type of data.
    I can not use DATA : lv_mine type data. because generic data should be used in formal parameter, however , if I use a field symbol, how to assign value with out knowing the data type?
    Best regards,

    Hi Blake,
    As per my understanding,
    You are getting the data type from the database table....
    You want to use the same data type....
    Lets say for example:
    You have a db table x with field y having data type Z.
    What you do is that, while declaring the data type for the attribute in the method use the reference as table_name-field_name(x-y).
    Or....
    use ANY. This will give you a chance to map any field type to this method....
    Note: Using ANY will limit the syntax that you can use within the method......
    Regards,
    Kunjal

  • Line 41     1061: Call to a possibly undefined method hitTestObject through a reference with static type

    Im trying to use the hit test built into flash, but its failing. I have used this many time before! but this time flash is crying at me.
    I Think i know why but im not sure how to fix it.
    Here is my hit test code:
    stage.addEventListener( Event.ENTER_FRAME, handleCollision);          
    private function handleCollision( e:Event ):void
                   if (MissleMc.hitTestObject(Enemy))
                        trace("HIT");
                   else
                        trace("MISS");
    I have tried multiple things,  Changing instances, location of the code. I currently have 4 classes, Main, Missile, Enemy and House. House has nothing it in really. Missile make a missile, Enemy Makes a enemy. And main deals with adding it all to the stage, and making it randomly appear ect.

    Yes you are correct, MissleMc is a class, thats the name its exported to. But i have tryed various things.
    Well i completely cahnged it now. Cleaned up my code a little created a new Bullet class, that i am currently using.
    Here is the function that fire's the bullet
    private function fireBullet():void
    var newBullet:Bullet = new Bullet;
    stage.addChild(newBullet);
    newBullet.x = house.x;
    newBullet.y = house.y;
    aBulletArray.push(newBullet);
    trace(aBulletArray.length);
    So im making the instance bullet, yet still when i use the hit test it does not wotk.

  • 1061: Call to a possibly undefined method setSize through a reference with static type flash.display:SimpleButton.

    Hi all.
    I am trying to set the size of the buttons on my site:
    http://www.samtest09.nineteenseventysix.com
    i am using the script:
    imagesb_btn.setSize(width, height);
    imagesb_btn.setSize(100, 50);
    but i keep getting the above error message when i try to publish.
    As far as i am aware im using as3 script in an as3 movie.
    Thanks for any help

    thanks for that Raymond, it works fine.
    now what id really like to ask is, is there a way that now i have set the size, the button will stay that size no matter what size browser or screen your on?
    i.e. the site has the buttons on the left and is set to fullscreen. but if i restore down the button gets smaller the smaller the screen gets. i would like the button to stay the same size.
    Thanks for your help
    stuart

  • How can i access properties from APP server through JNLP with ot using JAR

    Hello
    i want to retrive a Properties file from WL-7 app installed location like :bea/home/externalized.properties
    now i want to use this properties file throgh out the application. if any property is changed in "externalized.properties" that could be reflect dynamically in my code.
    So my requirement is :
    The current implementaion is using the JNLP down load the required code which contains the properties in .jar files, i have around 500 properties which are embedded in differnet .jar files with differnt property name. So i want to make all 500 properties to get out side from the jar files. and keep that consolidated properties in a single location and access it dynamically after deployed my ear file in wl7 app server.
    my application is implemented in SWING and EJB now i want to create an ear file which can be deployed any instance or cluster of WL7 app server.
    My Q:
    1. How can i access properties file through JNLP? (not a single property, want to access all properties in externalized.properties)
    2. is thare any known issue with SUN to load properties file through JNLP?
    your help is highly appreciated.
    -Siva

    Hey Thanks for your response,
    My question is Still not answered,
    see infact i have different type of environments to launch my application.
    infact my weblogic is deployed at remote location whihch is installed in linux,
    code is exist in our local system.
    At the time of code build for my local system i'm not able to get the properties from remote WL server,
    so at the time of code compilation and making the EAR file i'm not having this externalized properties file in newly generated EAR file.
    so once i copied my EAR in to WL7 cluster and i'm running the application using startAdminserver.sh, in this script file i'm defining the
    java -DexternalizedProperty=$WL_HOME/externalizedProperty.properties so now i'm able to get this properties to 'externalizedProperty"
    But when i download my application required jars, at this time i does not having the property file in my downloaded JAR files.
    So i want to access the remote properties file in suh sistuation.
    now i'm runnig the application at my local side to launch and Server side as well.
    So i have 2 runtimes 1 is my local and another is my server. In this case using "-DexternalizedProperty" i'm able to get this in server side,
    once control is come to local system it is not able to find this "-DexternalizedProperty" [externalizedProperty].
    Hope now u get my scenario..
    Thanks,

  • Call to a possibly undefined method displays when using static function in Unit Test

    Hello!
    This has been driving me nuts. I am setting up unit tests for a static class which manages a collection of songs. This is how my unit test class looks:
    //START CODE
    package flexUnitTests {
              import com.myapp.managers.MusicManager;
              import flash.utils.Dictionary;
              import flexunit.framework.Assert;
              public class MyAppManagerTest {
                        [Before]
                        public function setUp():void {
                                  var songData:Dictionary = new Dictionary();
                                  songData["mn0012345"] = new Dictionary();
                                  songData["mn0012345"]["title"] = "All the Pretty Little Horses";
                                  songData["mn0012345"]["description"] = "by: American Traditional | Voice, Piano | 3 pages";
                                  MusicManager.setSongData(songData);
                        [Test]
                        public function test_getAuthorsBySKU():void {
                                  var expected:String = "American Traditional";
                                  var given:String = MusicManager.getAuthorsBySKU("mn0012345");
                                  Assert.assertEquals(expected, given);
    //END OF CODE
    You will notice two calls in red above. When I leave them in the code I see a variety of errors which look like this:
    "Call to a possibly undefined method '' through a reference with a static type com.myapp..."
    And
    "Access of possible undefined property '' through a reference with static type com.myapp..."
    Then, when I comment out the two lines in red above, these errors go away. Flash Builder seems really flakey to me. Often I notice that the error list varies, how can it just no longer be an error? Where did this new access error come from, in a no related part of the code, by adding or removing a function call to a static class which remains in the import statement.
    Note that the MusicManager contains no references to any of the UI mxml that is throwing these errors. It just simply loads data into a few globals and allows you to grab info.
    How is my usage of this function making foreign objects inaccessible?
    Please help!!! I am really hoping there is an answer but I have a bad feeling the answer is just that Flash Builder is flakey.

    I did some more work on the issue above. There are functions with in the MusicManager that call the UserManager to get a user's ID. When I comment out these calls then the access errors go away. Well the user manager has some calls back to mxml that tell the class that changes where made. My best guess is this is where it stems into the code that is randomly throwing errors. But, it compiles fine and runs fine on a device. Is there something with test cases which doesn't invoke the UI?

  • Call to a possibly undefined method setPropertyIsEnumerable?

    Hi,
      I am trying to accomplish using doubleClick events on dateChoosers. Below is the code that is working:
         <mx:VBox>
                  <mx:Label text="Simple DateChooser control."/>
                  <mx:DateChooser id="dateChooser1" doubleClickEnabled="true"
                      doubleClick="displayDate2()"
                      change="displayDate(DateChooser(event.target).selectedDate)"/>
                  <mx:Label id="selection"  color="blue" text="Date selected:"/>
              </mx:VBox>
      I tried putting in doubleClickEnabled as true in Actionscript, and then call the event, and this is the syntax I used:
         //enable the double Click Enabled Property
                        dch.setPropertyIsEnumerable("doubleClickEnabled",true);
                       dch.addEventListener("doubleClick", useDate2);
      This did not work, and I got this error instead: 1061: Call to a possibly undefined method setPropertyIsEnumerable through a reference with static type mx.controls:DateChooser.   
      I tried to find a suitable import statement to insert in my code, but I am not sure what to put there. Could anyone please give me a hint what to do here to get my code to accept the method?
    Thanks in advance.
    Alice

    Hi, Ryan:
      Thanks, I got that to work, but it seems like the doubleClick does not allow me to use it on the dateChooser. Here is the code:
        The MXML:
               <mx:VBox id="box2">
                <mx:DateChooser id="dch" doubleClickEnabled="true"
                      doubleClick="displayDate2()"
                      change="displayDate(DateChooser(event.target).selectedDate)"/>
             </mx:VBox>
        The same thing in Actionscript, but not working:
         dch = new DateChooser();
         dch.addEventListener("change", displayDate);
         dch.doubleClickEnabled = true;
        dch.addEventListener("doubleClick",displayDate2);
      //Got an error saying TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@20112769 to     
      //mx.events.CalendarLayoutChangeEvent.
         box2.addChild(dch);
       Could you give me some pointers on what I have wrong here?
    Thanks for your help.
    Alice

  • Attempted access of inaccessible method

    Attempted access of inaccessible method I cant see the problem as I pass a class with a mesh property .
    I am using AS3 and away3D. Everything loads fine .
    Description      Resource      Path      Location      Type
    1195: Attempted access of inaccessible method enemyMesh through a reference with static type ClassEnemyCube.     
          public function moveForward(amt:int,models:Array):void
                       var enemyMesh2:Mesh;
                      for each (var el:ClassEnemyCube in models) 
                      enemyMesh2=el.enemyMesh(); //error
    calls this property
          public function get enemyMesh():Mesh
                      return model5;
                }

    Syntax for accessors (getters and setters) is the same as for properties. So, you loop must be:
    for each (var el:ClassEnemyCube in models)
         enemyMesh2 = el.enemyMesh;
    Not - there are no parenthesis attached to enemyMesh.

  • Ant tests: undefined method runWithFlexUnit4Runner?

    Hi all!
    I am trying to automate AIR tests that run successfully via Adobe Flash Builder 4.
    I get the following error:
      Error: Call to a possibly undefined method runWithFlexUnit4Runner through a reference with static type flexunit.flexui:FlexUnitTestRunnerUI.
        [mxmlc]
        [mxmlc]                 testRunner.runWithFlexUnit4Runner(currentRunTestSuite(), "unit_tests");
    when I run the tests from command line via: ant -v clean package.
    The part of the build.xml responsible for this is:
    <target name="test" depends="compile">
    <!-- Execute FlexUnit tests and publish reports -->
             <mxmlc
                file="${test.src.loc}/FlexUnitApplication.mxml"
                output="${bin.loc}/FlexUnitApplication.swf"
                actionscript-file-encoding="UTF-8"
                keep-generated-actionscript="true"
                incremental="false"
            >
               <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
               <source-path path-element="${FLEX_HOME}/frameworks"/>
               <compiler.source-path path-element="${test.src.loc}"/>
               <compiler.include-libraries dir="${lib.loc}" append="true">
                <include name="pb3dlib.swc" />
                <include name="airframework.swc" />
                <include name="airglobal.swc" />
                <include name="airspark.swc" />
                <include name="applicationupdater_ui3.swc" />
                <include name="automation_airspark.swc" />
                <include name="automation_spark.swc" />
                <include name="flexunit_0.9.swc" />
                <include name="flexunit-aircilistener-4.1.0.swc" />
                <include name="flexunit-cilistener-4.1.0.swc" />
                <include name="flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc" />
                <include name="flexunit-core-flex-4.1.0.swc" />
                <include name="flexunit-uilistener-4.1.0.swc" />
                <include name="flexunitextended.swc" />
                <include name="hamcrest-1.0.2.swc" />
                <include name="spark.swc" />
                <include name="utilities.swc" />
                <include name="flexunit.swc" />
                <include name="FlexUnitOptional.swc" />
                <include name="FlexUnitTestRunner_rb.swc" />
               </compiler.include-libraries>
            </mxmlc>
    What swc do I need to include?
    Thanks,
    --Andreea

    Andreea,
    The actual tests created by Flash Builder are fine, it is really just the main application file they create. They don't ship the source, so modifying it is difficult.
    You can, however do something like this example:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
          xmlns:mx="http://www.adobe.com/2006/mxml"
          creationComplete="runMe()" >
    <mx:Script>
      <![CDATA[
        import compilationSuite.SuitesToRun;
        import org.flexunit.listeners.CIListener;
        import org.flexunit.runner.FlexUnitCore;
        import org.flexunit.runner.notification.async.XMLListener;
        private var core:FlexUnitCore;
        public function runMe():void {
            core = new FlexUnitCore();
            //Put this line in if you want to write the XML to disk for use in reporting or a CI server
            core.addListener(new CIListener());
            //Leaving this one in allows you to see the results in Flash Builder as well if it is open
            //Else, it will just fail and go on. The name in the quotes below is your project name
            core.addListener(new XMLListener("unit_tests"));
            //Finally, pass what you want to run to the core.run() method. This could be the result of your currentRunTestSuite() from the
            //previous code you pasted
            core.run( compilationSuite.SuitesToRun );
    ]]>
    </mx:Script>
    </mx:Application>

  • Flex problem - undefined method

    Hello!
    I was following the tutorial posted at http://www.adobe.com/devnet/livecycle/articles/lcdses2_mdd_quickstart.html but I'm getting an error just after I add the form. 
    I'm getting the following error message: 
    "1061: Call to a possibly undefined method commitRequiredOn through a reference with static type mx.data:DataService. ProductForm.mxml /FiberTest/src/FiberTest/forms line 89 Flex Problem" 
    This is in the code for ProductForm.mxml, and the same goes for lines 171, 178, 184 and 191. 
    Could anybody help me here?
    Thanks!!
    Marcos

    Hi saisri2k2,
    I'm using Flash Builder 4 Standard, build 272416.
    Thank you!
    Marcos

  • Undefined method addEventlistener

    ERRORS ON LINE 10 AND 11
    1061: Call to a possibly undefined method
    addEventlistener through a reference with static
    type FunButton.
    package
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    public class FunButton extends MovieClip
    public function FunButton ()
    this.addEventlistener (MouseEvent.ROLL_OVER, grow);
    this.addEventlistener (MouseEvent.ROLL_OUT, shrink);
    private function grow (event:MouseEvent):void
    this.scaleX = 1.5;
    this.scaleY = 1.5;
    private function shrink (event:MouseEvent):void
    this.scaleX = 1;
    this.scaleY = 1;

    use:
    addEventListener

  • Call to a possibly undefined method asyncResponder

    Hi, why would I be getting this error for this code
                token.addResponder(Async.asyncResponder(this, new AsyncResponder(onResult, faultHandler), 600));
    1061: Call to a possibly undefined method asyncResponder through a reference with static type Class. 
    my imports look fine
    import flexunit.framework.Assert;
        import org.flexunit.async.Async;

    that method is only available in the flex version of flexunit. since it depends of an flex library class, it is not included in the actionscriptonly build

  • Symbol 'LoseMessage', Layer 'Reset_btn', Frame 1, Line 15     1061: Call to a possibly undefined method

    Hi I have a game set up, when you deplete your lives it takes you to a lose screen (Symbol), on that screen I have a button called Reset Game.
    The button name is "Reset_btn"
    The button instance is "resetbtn"
    I have the code in the symbol and I am getting this error:
    Symbol 'LoseMessage', Layer 'Reset_btn', Frame 1, Line 15    1061: Call to a possibly undefined method addEventListener through a reference with static type Class.
    Here is my code:
    //Reset Button Code
    resetbtn.addEventListener(MouseEvent.CLICK, Reset_btn);
    function Reset_btn(event:Event):void
            gotoAndStop(1);
    I have given my button and instance name and a name for the button, why am i still getting this error, can anyone help?
    Casey

    Ok.. so
    This is on a separate timeline, its a movieclip which has a timeline inside it.
    on frame 1 of that timeline inside the movieclip I have my button inside the movieclip.
    The movieclip is activated when it meets a certain condition.
    In this case when lives have been depleted to 0 from 3 a gameover screen appears.
    A button is on that gameover screen which should take me back to the main menu or Frame 1 of the actual game in this case.
    Here is the code for the condition for when game over screen appears:
    if(cursor.hitTestObject(enemyAppear2))
                            enemyAppear2.parent.removeChild(enemyAppear2);
                            stage.removeEventListener(MouseEvent.CLICK, clickEnemy2);
                            life--
                            messageDisplay2.text = String(life);
                            if(life == 0)
                                enemyTimer2.stop();
                                var loseText:LoseMessage = new LoseMessage();
                                loseText.x = 0;
                                loseText.y = 0;
                                parent.addChild(loseText);
                                Mouse.show();
    This code is in my main gaming code timeline.
    The code im trying to show is inside the movieclip which i have set up.
    Is this a clear enough explanation?

  • Why Java doesn't allow to reduce the accessibility of a method du

    Why Java compiler does not allow to reduce the accessibility of a method during inheritance?
    ( Eg; If the base class has a public method and if that method is overridden in child class but
    with defuault access, it gives compile error)
    Supposed answer:
    Because in the runtime, it cannot check the access modifier.
    Suppose A is the base class. It has a method fun() as public.
    B is the derived class of A.
    Suppose in some other class (say C) there is a method myFun() which takes A as parameter and
    calls the fun() method of A. So that method can take B
    also as parameter (As it is derived from A).
    So if the fun() method's accessibility is reduced in B, whether "that can
    be called in C or not" is not known. that is why compiler does not
    allow the reduce the accessibility of a method during inheritance.
    Member variables do not have this problem as they can be checked at
    compile time.
    Is this explanation correct?

    You can give private access, sort of... you could fake it, if the goal is to prevent someone from doing what the method does. Of course, they could (as long as A isn't abstract) create their own A and do whatever they want.
    class A {
       public void doThis() {
    class B extends A {
       public void doThis() {
          // explicitly do nothing
    }But I think generally, this shouldn't be a problem. I'm not sure if it's something that is common for creating an API to subclass another class to hide the superclass's methods. Usually you are adding functionality to a subclass that is for more specific things then the superclass supports. I mention creating an API because if it's just for some application class, then you are writing it, so use or not use the methods as you want. It's APIs for library type classes that other people would use, and if you are extending the library, and really need people not to call methods for some reason, document it. Maybe a good place for an assertion?

Maybe you are looking for