Something more like...
//
// in FLA
//
//
// linkageID: clip
// AS2.0 Class: Ball
//
INIT ();
function INIT ()
{
var sx = 26;
var sy = 227;
var my = 20;
var mx = 0;
len = 6;
list = [];
for ( var i = 0; i < len; i++ )
{
var x = sx + ( i * mx );
var y = sy + ( i * my );
var posInfo = {
_on: { x:50, y:y },
_off: { x:x, y:y }
}
var mc = this.attachMovie ( 'clip', 'mc_' + i,
this.getNextHighestDepth(), {posInfo:posInfo} );
mc.addEventListener ( "press", create ( this, pressHandler )
);
list.push ( mc );
}
}
function pressHandler ( e:Object )
{
for ( var i = 0; i < len; i++ )
{
var mc = list [ i ];
if ( mc != e.target )
{
mc.bounceTo ( mc.offPos );
}
else
{
mc.bounceTo ( mc.onPos );
}
}
}
function create (s:Object, func:Function):Function
{
return function():Void{ func.apply(s, arguments); };
}
//
// in Ball.as
//
class Ball extends MovieClip
{
// dispatcher
private static var EventDispatcherDependancy =
mx.events.EventDispatcher.initialize ( Ball.prototype );
public var addEventListener:Function;
public var removeEventListener:Function;
public var dispatchEvent:Function;
// STATIC
public static var BOUNCE:Number = .4;
public static var SPEED:Number = .9;
// velocity
private var vx:Number = 0;
private var vy:Number = 0;
// destination
private var dx:Number = 0;
private var dy:Number = 0;;
// position info
// example... {_on:{x:10,y:10} , _off:{x:0,y:0} };
private var posInfo:Object;
public function Ball ()
{
INIT();
}
public function get onPos( ):Number { return posInfo._on; }
public function get offPos( ):Number { return posInfo._off; }
public function bounceTo ( pos:Object ):Void
{
if ( !isNaN (pos.x) ) dx = Math.round(pos.x *20)/20;
if ( !isNaN (pos.y) ) dy = Math.round(pos.y *20)/20;
onEnterFrame = centerBounce;
}
private function centerBounce ( ):Void
{
if ( _x != dx || _y != dy )
{
vx = ( vx * Ball.BOUNCE ) + (( dx - _x ) *
Ball.SPEED);
vy = ( vy * Ball.BOUNCE ) + (( dy - _y ) *
Ball.SPEED);
_x += vx;
_y += vy;
}
else
{
onEnterFrame = null;
}
}
private function onPress_EVENT ()
{
this.dispatchEvent ( {type:'press', target:this});
}
public function INIT( ):Void
{
// set on/off pos
_x = posInfo._off.x || 0;
_y = posInfo._off.y || 0;
// reset destination
dx = _x;
dy = _y;
// interaction
onPress = onPress_EVENT;
}
}
_____________________________
Jesse Graupmann
www.jessegraupmann.com
www.justgooddesign.com/blog/
_____________________________
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of coker todd
Sent: Thursday, August 16, 2007 9:17 PM
To: [email protected]
Subject: RE: [Flashcoders] porting to Flash 8
Thanks Kerry, what would make it specific?
--- Kerry Thompson <[EMAIL PROTECTED]> wrote:
> Jesse Graupmann wrote:
>
> > This works, but it's not really doing anything
> specific to AS2.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