Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/ab29539ab9.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, Errors, How to

getDefinitionByName Error: “Variable … is not defined.”

Andrei Ionescu | 01.05.09 | 10 Comments

Google Buzz

I’ve been playing with Tweensy these days. Tried to understand how it works and how to create effects using particles generator. At some point I run into an error like the following one:

ReferenceError: Error #1065: Variable Box is not defined.
at global/flash.utils::getDefinitionByName()

What triggered it is this part of code:

var myClass:Class = getDefinitionByName("Box") as Class;

The error is saying that the it cannot retrieve the class code because the class is not compiled with the application. Even though you put something like

import mx.containers.Box;

the class is not compiled with the application because the linker and the compiler do not add classes that are not referenced in the code.

What is the solution… Pretty simple and straight forward:

private var _dummyVarToAddBoxToAppCompilation:Box;

Even though you’ll never use the _dummyVarToAddBoxToAppCompilation variable it is necessary to use that line to instruct the compiler to include mx.containers.Box in the compilation.

You’ll find the same answer on multiple blogs and forums but still needed to make an article on it. More is always better and easier to find.

Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites




Tags: ,

This post was written by Andrei Ionescu

Views: 5121

related

10 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


«
»