0

I am trying to convert someone else's flash application to ActionScript 3. I've never had to deal with ActionScript before now. I've tried to do what the error messages tell me to but they are running me in circles. So here is a simplified version of the situation. I have an action script in the base folder that looks like this:

class IF12345
{
    var a0:controls.Button;
    var a1:controls.TextArea;
    var a2:controls.TextInput;
}

Now the controls look like this:

dynamic class mx.controls.Button extends mx.controls.SimpleButton
{
    var enabled;
    function Button()
    {
    }
    function draw()
    {
    }

    var borderW = 1;
}

First error I got was it complaining that an action script must have one externally visible class so I added public to the class in the base file. Then it said you can't have a public class without a package so I wrapped it in a package.

After that it said that an action script must have one externally visible class for a control so I added public to the control class. Of course it then complained about needing to be in a package but then when I put the control class in a package it said I can't have a nested package. So at this point I don't know what to do?

1
  • Last I checked "Class names must only contain letters, numbers, "_", and "$"." Not sure what that dynamic class is doing since mx.controls package contains the Button class. What is that class trying to accomplish? Commented Jan 20, 2014 at 21:43

1 Answer 1

1

Looks like you're mixed up on a few points, but the main one I see is it looks like you're trying to make the class name include the entire package. A working example of what I think you want would be:

package controls
//      ^^^^^^^^ The controls package is defined here, not when providing the
//               class name like in your example.
{
    import flash.display.SimpleButton;
    //     ^^^^^^^^^^^^^ In ActionScript 3, SimpleButton is in the
    //                   flash.display package, and needs to be imported with an
    //                   import statement above the class definition.

    public class Button extends SimpleButton
    //           ^^^^^^ We only use the class name here. You can do the fully
    //                  qualified class name for the extended class, but the
    //                  import statement is cleaner and makes that unnecessary
    //                  except for in uncommon circumstances.
    {
        private var enabled:Boolean = false;
        private var borderW:int = 1;

        public function Button()
        {
            // Constructors must be public.
        }

        public function draw()
        {
            //
        }
    }
}

And your other class:

package
{
    import controls.Button;
    //     ^^^^^^^^^^^^^^^ Need to import your above Button class.

    public class IF12345
    {
        public var a0:Button;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.