Trouble with classes in actionscript. Be gentle, I'm self-taught and new.


i have object on stage, , have given instance name "jim".

 

i have document class named "jimulator" refers "jim" without issue.

 

i have class script class "wall" because want program behaviour when "jim" collides "wall".

 

when in "wall", if copy/paste refers "jim", error 1120.

 

if change "jim" "jimulator.jim" error 1119: "access of possibly undefined property of jim through reference static type class"

 

i'm still new actionscript, , none of making sense me. please help.

opinions vary shouldn't referencing jim in wall class.

 

the wall class should contain code references wall , maybe how interacts stage.  honestly, can't think of commonly go in wall class, maybe want each wall subclass explode if it's contacted number of times.  go wall class.  use public variables, public functions , getters , setters interact wall class outside wall class.

 

jim should contain stuff that's needed jim.  maybe how many lives starts when added stage , keeping track of how many lives remain etc.  again, use public variables, public functions , getters , setters interact jim class outside jim class.

 

you might have level class adds jim , various walls stage , contains code game play , communicates jim , walls via public variables, functions , getters/setters.

 

but, if want learn hard way, can reference items on stage class that's on stage using reference stage.



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

Reader DC

AdobeIDの作り方

Adobe InDesign CC 2017 has stopped working