Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes the flash/actionscript runtime error "WatcherSetupUtil is not defined"?

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");
}
like image 876
Russ Avatar asked Jun 07 '11 14:06

Russ


1 Answers

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.

like image 148
J_A_X Avatar answered Nov 15 '22 06:11

J_A_X