PDA

View Full Version : strange issue subclassing



jazgold
March 3rd, 2008, 10:40 AM
i just came in on a project and i'm working off of some files i didn't create. i'm working off the same codebase, making a new fla, and simply subclassing the main document class.

things are going wrong, and i'm confused because i've already done something similar on another project.

after running into a bunch of compile and runtime issues, i decided to strip it down to the basics.

i made a new fla, with new geometries that have the same instance names. if i keep the same document class, SlideShow, it compiles and runs. if i switch the document class to BSlideShow, which contains only:


package com.tierra.billboard {
import flash.display.MovieClip;
public class BSlideShow extends SlideShow {}
}

i still get the runtime error:


ReferenceError: Error #1065: Variable winOverlay is not defined.
at com.tierra.billboard::SlideShow/startTheShow()
at com.tierra.billboard::SlideShow/waitForParameters()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

winOverlay is the instancename of a movieclip defined within the FLA. it is defined in the original fla, and within the new one in which i changed the document class. why would it all the sudden be undefined when subclassing the document class?

i'm jumping right in from as2, have worked with java, but am probably making a lot of assumptions about classes referencing movieclips on the timeline, or their children. i'm assuming this is a no-no now, and will have to dig for tutorials.

thanks in advance

jazgold
March 3rd, 2008, 11:12 AM
ok, having perused some threads it seems that getChildByName() is now the safest way to go... the problem no longer persists. i still would appreciate if someone could explain why, or what rule i was breaking. constantly using getChildByName() is also a little irritating because it just gets a bit verbose, but if that's the protocol... i'll abide.

any tips?

Dazzer
March 4th, 2008, 03:37 AM
Names are names. Variables are variables.

Variables refer to the actual "object", while the name is simply a property of an object. Hence you cannot simply access an object via its name, hence the need for a method "getChildByName()".

Hence, you need to create a variable that points TO the object itself, then refer to it like that.