Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting doesn't work outside class scope #3

Open
p-kolacz opened this issue Oct 2, 2014 · 8 comments
Open

Syntax highlighting doesn't work outside class scope #3

p-kolacz opened this issue Oct 2, 2014 · 8 comments

Comments

@p-kolacz
Copy link

p-kolacz commented Oct 2, 2014

For ex. for global functions or variables.

@skoch
Copy link
Owner

skoch commented Oct 2, 2014

@Pitru Can you give me an example file?

@p-kolacz
Copy link
Author

p-kolacz commented Oct 2, 2014

function testFunction():String
 {
    var s:String = "Test String"
    return s
 }

@skoch
Copy link
Owner

skoch commented Oct 2, 2014

In ActionScript 3.0, every object is defined by a class.

http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9e.html

If you aren't defining a class (with or without a package) then I suggest you switch to the included ActionScript plugin to have syntax highlighting for your non classed functions.

@p-kolacz
Copy link
Author

p-kolacz commented Oct 2, 2014

For e.x: I have some initialization function, that I use in almost every project, like

MovieClip(root).contextMenu = new ContextMenu();
MovieClip(root).contextMenu.hideBuiltInItems();

and so on. I can't use class for this, its just some lines of code. I could use build-in AS2 plugin for this, but is there way to automatically enable included plugin for this file, and keep yours plugin for everything else?

@skoch
Copy link
Owner

skoch commented Oct 2, 2014

I think this depends on your text editor of choice. I'm using Sublime Text 3 and I have the ability to set the syntax on a per file basis.

I'm curious how you're setting up your projects if you aren't using classes for your initialization functions.

@p-kolacz
Copy link
Author

p-kolacz commented Oct 3, 2014

I just include "init.as" with some functions calls and prototype declarations for extending base classes like Array or String.

@skoch
Copy link
Owner

skoch commented Oct 3, 2014

I'd recommend writing some utility classes that you can reuse in all your projects, a la:

package com.pitru.utils {

    public class StringUtils {

        public static function foobar( $string:String ):String
        {
            // manipulate $string and then...
            return $string;
        }
    }
}

@martixy
Copy link

martixy commented Feb 23, 2015

I've recently encountered the exact same issue.
None of the AS3 packages I found handle that type of file.
It is still a completely valid approach of doing things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants