S
S
Sergey Sokolov2012-05-15 06:27:29
OOP
Sergey Sokolov, 2012-05-15 06:27:29

How can :void cause an error? [AS3]

An unexpected situation: an error occurs and disappears if you add :voidafter a method definition. Moreover, this affects the next declared method in the same class.

Error:
1195: Attempted access of inaccessible method lightTwoOk through a reference with static type com.myApplication:myDoc.

Definitions:

public function lightOneOk():void {
    myMC.LightOne.goGreen();
}

public function lightTwoOk() {
    myMC.LightTwo.goGreen();
}


Those. if you remove the first void, the error disappears. Add a second one, and the list of errors will include the methods defined below, after these two.

Methods do not return values, the function inside is a wrapper for gotoAndStop().

The class structure is like this. The above code is from the document class ( myDoc). From its constructor, I access the application's Singleton ( class myApp) for the first time by creating it. myAppcontains properties Docand User. User, upon receiving data from a remote web service, calls "problematic" methods:

var App:myApp = myApp.getApp(); // получить ссылку на синглтон приложения
App.Doc.lightOneOk();
App.Doc.lightTwoOk(); // вот на это место указывает ошибка 1195

It's just UI: connected - turned on the green light.

CHADNT? OOP gurus, explain what "really" fundamentally changes when added :voidto the definition of a method?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad, 2012-05-15
@DaFive

void, ideologically, is set by default. And you swear not at the type of the returned value, but at the fact that there is no such function when you call it. Check the spelling of the function, rename it eventually.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question