1
votes

I've got this class where I declare two public static constants:

package com.xxx.videoplayer_v2 {    
    import flash.display.DisplayObject;
    import flash.display.MovieClip; 
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.text.TextField;

    public class ControlBar extends MovieClip 
    {
        public static const VOLUME_PRESSED:String = "volumePressed";
        public static const PLAY_PRESSED:String = "playPressed";        
        ...

The declaration looks good to me but when I call the constants from any other class in my project (below an example from the stage)

import com.xxx.videoplayer_v2.ControlBar;

trace(ControlBar.PLAY_PRESSED);

I get this error:

1119: Access of possibly undefined property PLAY_PRESSED through a reference with static type Class.

Why does this happen? I've done this thousands of times with other classes, with the same syntax but I've never had this problem before.

1
are you sure you are getting the right version of the class at runtime? (the one with PLAY_PRESSED defined) - mamapitufo
Your code is perfectly right, so is your call to the constant. The issue might be somewhere else. Did you try it with "Delete ASO files and test movie" from the control menu? - inhan
@inhan: I've tried it now and nothing changes unfortunately. - Andrea Silvestri
@mamá pitufo: how can I check that? If you mean to ask if I'm sure that the class I'm compiling is the version with the constants, yes I checked multiple times - Andrea Silvestri
I got it! I'm answering myself to let you know. - Andrea Silvestri

1 Answers

1
votes

I figured it out!

I have an instance of ControlBar on the stage wich in its properties I exported for ActionScript.

The problem was this: I filled in the Class textfield exactly the same name as the base class (ControlBar) and in the Base Class textfield I inserted "com.weborama.videoplayer_v2.ControlBar" which is right.

I fixed filling in the Class textfield "VPControlBar" instead of "ControlBar". Now I know that I can't put the same name of the base class in there.

Thanks to everyone who tried to help me!