6
votes

I have a flex application ("MyApp") I'm working on where I'm seeing some very odd and inconsistent errors. One of the errors I sometimes see immediately on application launch is

"Variable _MyAppWatcherSetupUtil is not defined."

The full error output is at the bottom of the question.

What makes this error particularly strange is that I get it immediately and consistently after doing a project build (ie: run the swf many times and it always happens), and the only thing I need to do to make the error go away (I won't say "fix it") is to build the project again.

Does anyone know what this error is about? The best I can gather so far is that it might be related to binding variables somehow (which is what WatcherUtil seems to imply), but I don't get why it would be inconsistent between builds.


Compilation is with mxmlc from flex_sdk_4.5.0.20967.

Full error output for a recent build where it happened:

Exception thrown: ReferenceError: Error #1065: Variable _MyAppWatcherSetupUtil is not defined.
    at global/flash.utils::getDefinitionByName()
    at MyApp()[C:\code\Sandbox\MyApp\src\MyApp.mxml:6]
    at _MyApp_mx_managers_SystemManager/create()[_MyApp_mx_managers_SystemManager.as:50]
    at mx.managers.systemClasses::ChildManager/initializeTopLevelWindow()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\systemClasses\ChildManager.as:311]
    at mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\SystemManager.as:3063]
    at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::kickOff()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\SystemManager.as:2849]
    at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::preloader_completeHandler()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\SystemManager.as:2729]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.preloaders::Preloader/timerHandler()[E:\dev\hero_private\frameworks\projects\framework\src\mx\preloaders\Preloader.as:542]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()

Update per J_A_X's request..:

The first 7 lines of the MXML file are:

<?xml version="1.0" encoding="utf-8"?>
<s:Application height="100%" width="100%"
               xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               initialize="InitData();">
<fx:Script source="MyApp.as"/>

And the InitData() code (with other relevant script lines) is in the MyApp.as file:

import classes.RpcServerProxy;
public var SP:RpcServerProxy;

public function InitData():void {
    SP = new RpcServerProxy("http://192.168.1.102:1234");
}
1
I'd have guessed something in your code is causing this, but iti s odd that nothing in the stack trace is a custom component. WatchterUtils is indeed related to binding. - JeffryHouser
I do have a custom (and complex) pure actionscript class in the project, but I've made nothing in it bindable. Thanks for confirming the binding relation. The biggest mystery for me that is making this tricky to nail down is the build-to-build inconsistency... - Russ
If it's a pure ActionScript project; why did you tag this with Flex? Are you using Flex Components? - JeffryHouser
Sorry to confuse things by mentioning the pure AS class... it is absolutely a flex application. It is just that I have a beefy actionscript class in it that is doing most of the behind-the-scenes work (rpc calls) and I tend to suspect it. It is where the majority of the code is, although like I said... nothing is bindable. All data exchange is via AsyncTokens. Probably irrelevant. - Russ
I would not expect the AS3 class that just does remote calls to be the cause of this error. I would suspect that this relates to how your MXML is turned into AS3; but it's just one big guess at this point. - JeffryHouser

1 Answers

4
votes

I don't know what RpcServerProxy is, but it might be doing something before everything is instantiated. Instead of calling the function in the initialize event, use creationComplete instead.

You might always want to look at the code within that class cause it's definitely doing something funky.