This should be pretty straightforward math, but I'm missing something.
Desired effect:
===========
I have a movieclip, and using XML, I am populating that movieclip with
little dots... each representing an "item" - afterwards the main clip is
centered on the stage.
Now, run a function to check proximity to the stage center, the closest (2
if uneven # items) is scaled to 200%. Trailing away from the center on both
sides, the clips diminish in scale until a minimum of 50% scaling.
Once that is done, when the main movieclip is moved, I need to update the
dots inside it, maintaining the scaling nearest the Stage center. The dot
movieclips are 18.5 x 18.5 in size... thats where the 37 comes from (
18.5x200%).
I don't want to use onEnterFrame for this. Its been a long day and I'm
looking for the most straight-forward way to adjust the dot clips in
relation to the stage center... but my mind is mush for the day. It seems
like it wouln't be that hard, but... for now it is.
Any suggestions/help appreciated!
The code to initially place the scaling (thanks to owid's help) is like
this:
// This parses XML & generates the UI
function createMenu( oXml ):Void {
var posX:Number = 0;
this.createEmptyMovieClip("musicItems", this.getNextHighestDepth() );
musicItems._y = Stage.height/2;
var nLen:Number = oXml.firstChild.firstChild.childNodes.length;
nItems = nLen;
var even = !(nItems%2);
var middle = nItems/2;
if (!even) middle = Math.round(middle);
for( var i=1; i<nLen+1; i++ ){
var mc = musicItems.attachMovie( "dot", "dot_"+i, i );
mc._x = posX;
mc.indx = i;
mc.num_txt.text = i;
var cent = i-middle;
if ( cent > 0 && even ) cent--;
cent = Math.abs(Math.abs(cent)-middle);
cent = (cent-1)/(middle-1)*150
mc.scale = 50 + cent;
posX += 37;
}
musicItems._x = ( Stage.width - musicItems._width + 18.5) / 2;
checkScales();
}
// Initial proper scaling
function checkScales():Void {
for( var i=1; i<nItems+1; i++ ){
var mc = musicItems["dot_"+i];
mc._xscale = mc._yscale = mc.scale;
}
}
// THIS NEEDS CODED:
function adjustScales( nNum:Number ):Void {
for( var i=1; i<nItems+1; i++ ){
// Adjust the scalings on the clips
}
}
// Move the main clip around - need to adjust the dots in the main clip...
right.onRelease = function():Void {
musicItems._x += 37;
if( musicItems._x >= Stage.width/2)
musicItems._x = Stage.width/2;
adjustScales(1);
}
left.onRelease = function():Void {
musicItems._x -= 37;
if ((Stage.width/2)-musicItems._width >= musicItems._x )
musicItems._x = (Stage.width/2)-musicItems._width;
adjustScales(0);
}
_______________________________________________
[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