Hello Paul,
If you already have an instances of Boiler on the stage you can use
boiler's self-registering in your game class.
For example you have in library:
"Game_mc", linkage - Game_mc, AS 2 class - Game.
"Bolier_mc", linkage - Boiler_mc, AS 2 class - Boiler.
On the stage you have an instance of Game_mc contained instances of
Bolier_mc inside
in example you needn't to know instance name of your boilers
example of self-registration:
======================
import Game;
class Boiler extends MovieClip {
private var game_mc : Game;
private function Boiler() {
this.game_mc = Game(this._parent);
this.game_mc.registerBoiler(this);
}
}
========================
class Game extends MovieClip {
private var boilers : Array;
private function Game() {
}
/**registerBoiler (Game.registerBoiler method)
* public registerBoiler (boiler_mc:Boiler) : Void;
* <pre>
*
* </pre>
* @param boiler_mc:Boiler ≈
* @return Void ≈
* <pre>
*
* </pre>
* <B>Example:</B>
* <pre>
* import Game;
*
* </pre>
**/
public function registerBoiler (boiler_mc:Boiler):Void {
this.boilers.push(boiler_mc);
// other actions
}
}
=========================
PS> I do not want to create the boiler movie clips as these are already on the
PS> stage.
PS> Basically I want to be able to control a nested movie clip within each
PS> boiler, that is called "needle_mc"
PS> And I want the boiler object to store unique properties for each of the
PS> boilers.
PS> Your code looks very complex for my requirements - can I not simply
PS> dynamically create the boiler movie clip path reference and pass it to the
PS> boiler instance similar to how I passed the path to the Game class?
PS> Thanks
PS> Paul
PS> -----Original Message-----
PS> From: [EMAIL PROTECTED]
PS> [mailto:[EMAIL PROTECTED] On Behalf Of Iv
PS> Sent: 03 December 2006 14:30
PS> To: Flashcoders mailing list
PS> Subject: Re: [Flashcoders] Create movieclip path within a class
PS> Hello Paul,
PS>> var vBoiler_Obj:Boiler = new Boiler(vBoilerRef);
PS> - this line incorrect.
PS> use create method
PS> public static function create (this_mc:MovieClip, name:String, depth:Number,
PS> init_obj:Object):Boiler {
PS> var new_mc:MovieClip = this_mc.createEmptyMovieClip(name, depth);
PS> var current_constructor:Function = Boiler;
PS> new_mc.__proto__ = current_constructor.prototype;
PS> var out_mc:Boiler = Boiler(new_mc);
PS> for (var i:String in init_obj) {
PS> out_mc[i] = init_obj[i];
PS> }
PS> current_constructor.call(out_mc);
PS> return out_mc;
PS> }
PS> and call:
PS> var depth:Number = this.getNextHighestDepth();
PS> var vBoiler_Obj:Boiler = Boiler.create(this, vBoilerRef, depth)
PS> PS:
PS> Template for FDT:
PS> public static function create (this_mc:MovieClip, name:String, depth:Number,
PS> init_obj:Object):${enclosing_type} {
PS> var new_mc:MovieClip = this_mc.createEmptyMovieClip(name, depth);
PS> var current_constructor:Function = ${enclosing_type};
PS> new_mc.__proto__ = current_constructor.prototype;
PS> var out_mc:${enclosing_type} = ${enclosing_type}(new_mc);
PS> for (var i:String in init_obj) {
PS> out_mc[i] = init_obj[i];
PS> }
PS> current_constructor.call(out_mc);
PS> return out_mc;
PS> }
--
Ivan Dembicki
______________________________________________________________________
[EMAIL PROTECTED] | http://www.artlebedev.ru | http://www.sharedfonts.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com