flashCS3 - notes #1
first part of my "migrating to as3" notes. lots of things have changed in new flashCS3. here are some i have to remeber about :
1. now its is possible to change parent of specified MovieClip (writing MovieClip i mean any subclass of InteractiveObject)
2. old MCs methods like attachMovie and createEmptyMovieClip are gone. now to achive the same effect you simply create MC instance and using method addChild append it to the parent MC.
oop with actionscript in flash
currently im developing some code using actionscript 2 in flash 8. so ive implemented a class lets say code 1:
class myclass extends MovieClip { public function myclass() { trace("myclass - constructor"); }; private function onLoad() :Void { trace("On Load from class"); }; } class </strong>myclass extends MovieClip { public function myclass() { trace("myclass - constructor"); }; private function onLoad() :Void { trace("On Load from class"); }; }in flash ive linked that class with some movie clip (this is the way you can extend movie clips in flash ;)). after putting clip on stage ive added it an action code 2:
onClipEvent (load) { trace("loading from IDE"); }and while running this script we can see that : I. code defined for object already placed on stage does not override function defined in class implementation ( that is both - code 1 and code 2 will be invoked ) II. code 2 will be invoked as the first one afterwards code 1 -- a friend of mine said : "well, its normal behavior ! didnt you know that ?!?" ;/ i didnt ... -- BUT... lets suppose ive placed my object in first frame and called it : tst. if i write, also in first frame, code shown as code 3 i will override onLoad function defined in class implementation. and new onLoad handler will also be invoked after code 2: code 3:
tst.onLoad = function() { trace("OnLoad from IDE - onLoad<-function"); };- i think that what flash do is that it treads onClipEvent as if it was method implemented for MovieClip. in my class, MovieClips descendant, flash modifies onLoad method adding
super.onLoad() code. this tip works also for other events that can movieclip handle.previous (newer) , 1 , 2