flash actionscript:
I've written a class that takes an instance name of any MovieClip and then builds a stage size background for it. I do this by: Taking in the instance name via the ctor. Then call "passedin_mc.createEmptyMovieClip( "_bgHolder_mc", -16834 )" then call "passedin_mc._bgHolder_mc.attachMovie( "somesymbol", "bgHolder_mc", 3 ); this seems to work for most movieclips ( at least the ones embedded in the swf ). Does anyone know why or what would cause attachMovie to fail (e.g. _bgHolder_mc can be seen in the list of objects, but _bgHolder.bgHolder is not seen when passing in certain MovieClips.). By certain MovieClips, I mean that the passedin_mc is calling "passedin_mc.loadMovie()" I've tried different depths for the "_bgHolder_mc.bgHolder_mc" - no luck. Am I going about this the wrong way? thanks - Fruber
The fla would be very big, here is the class. If you create some MC on your stage, then during then anywhere on your timeline you: var holder = new ClipHolder( "nameofinstance" ); holder.applyBackground(); it should create an instance of a symbol called "adBackgroundSymbol" - which is the size of the stage (any component you have registered for ActionScript should work) and put your MC on top of it. You'll also see the Fill and tile method, which do something similar. The theory behind this was for me to write a wrapper class for any MC object that will show a wall paper behind the MC. so that when viewing this clip - (which may be smaller than the stage) would have this around it's border instead of what's beneath it. (and of course take up the entire size of the stage). This seems to work just as I suggested above, but for some clips my attachMovie on the background seems to fail. and the only difference I've found between that and other clips is that I'm performing a loadMovie on the clip that I'm passing to the constructor. As a mater of fact, if I create the _bg_holder_mc before the movieclip is loaded (but it is already created by _root.createEmptyMovieclip - and then passing this new movieclip to the ctor of this class) - When the MC is finally rendered, the _bg_holder_mc is gone, but if I call applyBackground AFTER the MC has loaded, I at least get the _bg_holder_mc and am able to fill the background. Unfortunately no matter how I do it, when passing an empty movieclip (only empty at the time) to the ctor of this function, I can't get it to render the background with an image ( using _buildHolder() ). before or after the clip is no longer empty. Hope this helps.. i know this can sound confusing, I'll clarify anything you need. thanks - Fruber. // ClipHolder.as ClipHolder = function( strInstanceName, nDepth ) { // if we are given a depth, then we should create this MC as well if ( nDepth != undefined ) { _root.createEmptyMovieClip( strInstanceName, nDepth ); } this._strInstanceName = strInstanceName; this._clipHolder_mc = eval( strInstanceName ); this.addProperty( "surface", this.get_surface, null ); }; ClipHolder.prototype.applyBackground = function( ) { this._clipHolder_mc.createEmptyMovieClip( "_bgHolder_mc", -16834 );// want it below everything this._buildHolder( ); //this._buildHolderFill( ); //this._buildHolderTile( ); } ClipHolder.prototype.get_surface = function(){ return this._clipHolder_mc; }; ClipHolder.prototype._buildHolderFill = function( ) { var clip_mc = this._clipHolder_mc; var pt = new Object(); pt.x = 0; pt.y = 0; clip_mc.globalToLocal( pt ); var mcX = pt.x; var mcY = pt.y; var mcWidth = Stage.width; var mcHeight = Stage.height; clip_mc._bgHolder_mc.moveTo( mcX, mcY ); clip_mc._bgHolder_mc.beginFill( 0x000000, 100 ); clip_mc._bgHolder_mc.lineTo( mcX + mcWidth, mcY ); clip_mc._bgHolder_mc.lineTo( mcX + mcWidth, mcY + mcHeight ); clip_mc._bgHolder_mc.lineTo( mcX, mcY + mcHeight ); clip_mc._bgHolder_mc.lineTo( mcX, mcY ); clip_mc._bgHolder_mc.endFill(); }; ClipHolder.prototype._buildHolder = function( ) { var clip_mc = this._clipHolder_mc; var pt = new Object(); pt.x = 0; pt.y = 0; clip_mc.globalToLocal( pt ); clip_mc._bgHolder_mc.attachMovie( "adBackgroundSymbol", "bgHolder_mc", 3 ); trace( "ClipHolder._buildHolder(): bgHolder-mc = " + clip_mc._bgHolder_mc.bgHolder_mc ); clip_mc._bgHolder_mc._x = pt.x; clip_mc._bgHolder_mc._y = pt.y; }; ClipHolder.prototype._buildHolderTile = function( ) { var clip_mc = this._cliipHolder_mc; var pt = new Object(); pt.x = 0; pt.y = 0; clip_mc.globalToLocal( pt ); clip_mc._bgHolder_mc.attachMovie( "adBackgroundSymbol", "bgHolder_mc", 3 ); if ( clip_mc._bgHolder_mc.bgHolder_mc == undefined ) return; clip_mc._bgHolder_mc.bgHolder_mc._width /= 3; clip_mc._bgHolder_mc.bgHolder_mc._height /= 3; var nLogoWidth = clip_mc._bgHolder_mc.bgHolder_mc._width; var nLogoHeight = clip_mc._bgHolder_mc.bgHolder_mc._height; var nCols = Math.ceil( Stage.width / nLogoWidth ); var nRows = Math.ceil( Stage.height / nLogoHeight ); var strTarget = ""; var nDepth = 11; clip_mc._bgHolder_mc.bgHolder_mc._alpha = 7; for ( var nRow = 1; nRow <= nRows; nRow++ ) { for ( var nCol = 1; nCol <= nCols; nCol++ ) { strTarget = "bgHolder_mc_" + nRow + "_" + nCol; clip_mc._bgHolder_mc.bgHolder_mc.duplicateMovieClip( strTarget, nDepth++ ); eval( "clip_mc._bgHolder_mc." + strTarget )._x = pt.x + ((nCol - 1) * nLogoWidth); eval( "clip_mc._bgHolder_mc." + strTarget )._y = pt.y + ((nRow - 1) * nLogoHeight); } } clip_mc._bgHolder_mc.bgHolder_mc.removeMovieClip(); };
For some additional information: When I fill the "passedin_mc._bgHolder_mc" with a color instead of calling "attachMovie" - it does draw my square and fill the color. So I know that the _bgHolder_mc is valid. I also know that the symbol does exist. thanks - Fruber.
Don't see what you're looking for? Try a search.
|