Actionscript 3.0 error#1010

Discussion in 'Web Design and Development' started by ks2000, Oct 6, 2010.

  1. ks2000 macrumors newbie

    Oct 6, 2010
    I made an interactive atlas of health facilities. Each facility is displayed with a symbol on the map. when the user rolls over the symbol it magnifies it by 2. when the user clicks on the symbol is remains magnified and information about that facility pops up. There are two functions used for the magnification (zoomIn and zoomOut) as follows.

    function zoomIn(evt) {
    this[whichDot+"Array"][, eName.length)].scaleX=2;
    this[whichDot+"Array"][, eName.length)].scaleY=2;

    zoomOut(evt) {
    this[whichDot+"Array"][, eName.length)].scaleX=1;
    this[whichDot+"Array"][, eName.length)].scaleY=1;

    they work great except for when the user clicks a new tab in the Atlas (which is actually a movie clip containing the information of the tab) until which the zoom functions stop working and I get an error message about a term being undefined (zoomIn and zoomOut)

    the zoom functions are defined on the main Timeline and work great, i just don't understand why they stop working in the movie clip?

    you can see the application at the problem happens when you click on the "view by service" tab and check the box for nursing homes for psych beds and then click a symbol on the map..the symbol stays magnified and stuck in the "up" state, which should not happen. The symbols behave great on the "view by facility" tab.

    i can provide more code to this as well.

    if the functions exist, why would they only work part of time?

    any insight into this problem would be greatly appreciated.

  2. whatsgooddan macrumors member

    Apr 6, 2009
    NY, USA
    i have to admit, when i first saw that you were posting about some non xhtml type thing for the web i thought "oh no this is going to be bad" but it is actually really cool. i would love to see the code behind it! though i've never used action script before, i wonder if you are programming with objects and if so, perhaps if a function is only working part time, then somewhere there is an issue with inheritance.
  3. lucidmedia macrumors 6502a

    Oct 13, 2008
    Wellington, New Zealand
    Impossible to say without the source code, but a really common problem.

    One problem is that you are using AS3, but are still coding with an AS2 mindset. I know that may not be the most helpful advice, but it is one reason you are getting these types of errors.

    Developing an app like this would be much easier if you got rid of things like sprite naming, and moved to a more object oriented approach (i.e. objects stored in arrays)

    This would allow you to shift the responsibility of the event listeners into the objects themselves... you will have less opportunity of events trying to talk to stuff that is either not there or out of scope.
  4. kustardking macrumors regular

    Jul 22, 2008
    New York
    "slice" is destructive, methinks

    lucidmedia is correct in that you need to become a different kind of programmer to successfully use AS3.

    But, to your problem at hand, I believe it is related to your use of slice(), which is literally changing the "internal" name of the sprite, thus making it inaccessible as originally named. slice() is destructive, so use substr() or substring() instead to get the result you're looking for.

    Or, you could use an object lookup table, such as

    var nurseByDotHash:Object = {};
    var dot: Dot = new Dot();
    var nurse:Nurse = new Nurse();
    nurseByDotHash[ dot ] = nurse; // obviously you could loop through this with an array of dots and nurses
    function zoom( e:Event ) {
    var nurse:Nurse = nurseByDotHash[ ]; // depending on your env, you may need to do an "... as Nurse" here
  5. ks2000 thread starter macrumors newbie

    Oct 6, 2010

Share This Page