getDefinitionByName() produces ReferenceError: Error #1065: Variable is not defined
Date: Thursday 3rd September 2009
Time: 16:44
Category: ActionScript 3.0
Views: 585
Comments:
Scenario
Something we often do here is get the “id” of a clicked menu button and instantiate a section of a site, depending on the ID passed. Usually all sections of a site inherit from a generic “Section” class, then have additional specific capabilities depending on the section. So, depending on the ID passed, we need to create an instance of the particular class. This means we need to get the class name dynamically from the string passed by the button.
Let’s imagine the “music” button was pressed. We’ll either have a listener for this or we’ll directly call a method called loadSection(), passing the ID (the name of the button usually). We name instances in camel notation, so that’ll be “music”.
This string goes over to the loadSection() method and in here we use a custom StringUtils class to covert the first letter to upper case, getting us the required class name as a string. So this gives us “Music”. A string is no good on its own though – we need to get the class reference for this, as follows:
// required "dummy" ref to ensure class is compiled...
var dummyRef:Music;
...
// get class reference
var classRef = getDefinitionByName(id);
// instantiate class instance as current section
section = new classRef();
Problem
All well and good. The trouble is sometimes it just doesn’t work and you’ll get:
ReferenceError: Error #1065: Variable Music is not defined
There’s a thread here where the person was getting this, and it drifted off into another debate without being solved. The import statement is there. The dummy class reference is there, but still it doesn’t work.
Solution
What is not immediately clear is that you need to provide a fully qualified class path to getDefinitionByName() – even though you have set up an import.
Amend as follows (for example) and your problem is solved:
// var classRef = getDefinitionByName(id);
var classRef = getDefinitionByName("sections." + id);
“sections.” here is a reference to our package structure.
We hope this helps you.

/rating_start.png)
/rating_on.png)
/rating_on.png)
/rating_on.png)
/rating_on.png)
/rating_on.png)
(1 votes, average: 5.00 out of 5)
Shadowbox not loading images or flash
Date: Saturday 29th August 2009
Time: 12:45
Category: Other
Views: 482
Comments:
An excellent alternative to the Lightbox script is Shadowbox, because it enables the display of multiple formats, including Flash. We use it on our projects page.
The trouble is, you might find that it just isn’t loading images – or Flash content. Yet again this seems to be a side-effect of Adblock Plus. It seems like avoiding ads comes at a price! Just disable Adblock Plus in Firefox and the problem will go away.
We don’t have a work-around for this yet, so if you do, please comment.

/rating_start.png)
/rating_on.png)
/rating_on.png)
/rating_on.png)
/rating_off.png)
/rating_off.png)
(1 votes, average: 3.00 out of 5)
Fullscreen Flash Player on dual monitors
Date: Wednesday 12th August 2009
Time: 11:23
Category: Adobe Flash
Views: 824
Comments:
If you are using dual monitors, as many developers do, it might be that you sometimes want a video running, fullscreen, on one monitor while you work on the other. The trouble is, Flash Player 10 is so designed that once the former monitor loses “focus” (i.e. you click on the other one), it will exit fullscreen. Some people even consider this a bug.
Luckily, there’s a fix available. Since it is not obvious how this issue could be a security concern, perhaps Adobe will consider implementing the functionality in the next Flash Player.

/rating_start.png)
/rating_on.png)
/rating_on.png)
/rating_off.png)
/rating_off.png)
/rating_off.png)
(1 votes, average: 2.00 out of 5)
Taylor Swift plays our game
Date: Wednesday 5th August 2009
Time: 00:26
Category: Other
Views: 186
Comments:
We designed and programmed a Love Calculator for the BBC back in 2001. The algorithm inside it mimics a children’s playground game by sorting through the letters in names.
The game still pulls in traffic to the BBC’s site 8 years later, and here you can see none other than country/pop star Taylor Swift playing it live on air.
AS3 training course
Date: Wednesday 29th July 2009
Time: 11:11
Category: ActionScript 3.0
Views: 121
Comments:
Due to popular demand, we are scheduling another ActionScript training course for 26-28th August 2009, in central London.
If you would like to reserve a place please get in touch.