RE: [Flashcoders] porting to Flash 8

2007-08-17 Thread Jesse Graupmann
Only you know your project, and that works just fine.

One idea to consider would be to try and minimize the memory footprint. 

By not messing up the MovieClip prototype, you keep your adjustments to only
relevant MovieClips that need those properties rather than every MovieClip.
Creating a single and central function for bounceMC and INIT_bounceMC
eliminates 10 extra functions and 8 extra properties in memory. Unless Speed
and Bounce change per MC, sharing 1 instance of each is better.

IMHO,
Jesse



function bounceMC ( mc:MovieClip )
{
mc.x = (mc.x * BOUNCE) + ((mc.xpos - mc._x) * SPEED);
mc.y = (mc.y * BOUNCE) + ((mc.ypos - mc._y) * SPEED);
mc._x += mc.x;
mc._y += mc.y;
}

function bounceEnter ( )
{
bounceMC ( mc );
bounceMC ( mc2 );
bounceMC ( mc3 );
bounceMC ( mc4 );
bounceMC ( mc5 );   
}

function INIT_bounceMC ( mc:MovieClip )
{
mc.x = mc.xpos = mc._x;
mc.y = mc.ypos = mc._y; 
}

function INIT ()
{
BOUNCE = 0.4;
SPEED = 0.9;

INIT_bounceMC ( mc );
INIT_bounceMC ( mc2 );
INIT_bounceMC ( mc3 );
INIT_bounceMC ( mc4 );
INIT_bounceMC ( mc5 );

onEnterFrame = bounceEnter;
}

INIT ();




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of coker todd
Sent: Thursday, August 16, 2007 10:42 PM
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] porting to Flash 8

rather than having onClipEvents on each MC, why
wouldn't this work?

this.onLoad=function(){
mc.mcbounceload();
mc2.mcbounceload();
mc3.mcbounceload();
mc4.mcbounceload();
mc5.mcbounceload();
}


this.onEnterFrame = function(){
mc.mcbounceenter();
mc2.mcbounceenter();
mc3.mcbounceenter();
mc4.mcbounceenter();
mc5.mcbounceenter();
}

___
Flashcoders@chattyfig.figleaf.com
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


[Flashcoders] porting to Flash 8

2007-08-16 Thread coker todd
Can someone please give me some tips as to what needs
to be changed in this script so it works with Flash 8,
I wrote this long ago in Flash 5, worked great, now I
need to publish a Flash 8 project and it does not
work??

Movieclip.prototype.setSpeed = function() {
federn = 0.4;
speed = 0.9;
xpos = _x;
ypos = _y;
};

Movieclip.prototype.theMover = function() {
x = x*theMover+(xpos-_x)*speed;
_x += x;
y = y*theMover+(ypos-_y)*speed;
_y += y;
};


   

Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.
http://farechase.yahoo.com/
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread Jesse Graupmann
AS 2.0 is case sensitive. You can start by changing Movieclip to MovieClip

Not sure why you are using a function as a multiplier, so you might want to
get rid of theMover reference inside itself.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of coker todd
Sent: Thursday, August 16, 2007 7:38 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] porting to Flash 8

Can someone please give me some tips as to what needs
to be changed in this script so it works with Flash 8,
I wrote this long ago in Flash 5, worked great, now I
need to publish a Flash 8 project and it does not
work??

Movieclip.prototype.setSpeed = function() {
federn = 0.4;
speed = 0.9;
xpos = _x;
ypos = _y;
};

Movieclip.prototype.theMover = function() {
x = x*theMover+(xpos-_x)*speed;
_x += x;
y = y*theMover+(ypos-_y)*speed;
_y += y;
};

___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread coker todd
so the new code reads:

MovieClip.prototype.mcbounceload = function () { 
bounce = 0.4;
speed = 0.9;
xpos = _x;
ypos = _y;
};

MovieClip.prototype.mcbounceenter = function () {
x = x*bounce+(xpos-_x)*speed;
_x += x;
y = y*bounce+(ypos-_y)*speed;
_y += y;

};

on each MC this is the code:

onClipEvent (load) {
mcfedernload();
}
onClipEvent (enterFrame) {
mcfedernenter();
}

code on each button:

on (release) {
_parent.mc2.xpos = 26;
_parent.mc2.ypos = 247;
_parent.mc3.xpos = 26;
_parent.mc3.ypos = 267;
_parent.mc4.xpos = 26;
_parent.mc4.ypos = 287;
_parent.mc5.xpos = 26;
_parent.mc5.ypos = 307;

Does this help??



--- Jesse Graupmann [EMAIL PROTECTED] wrote:

 AS 2.0 is case sensitive. You can start by changing
 Movieclip to MovieClip
 
 Not sure why you are using a function as a
 multiplier, so you might want to
 get rid of theMover reference inside itself.



   

Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=listsid=396545469
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread Kerry Thompson
Coker Todd wrote:
 
 so the new code reads:
 
 MovieClip.prototype.mcbounceload = function () {
   bounce = 0.4;
   speed = 0.9;
   xpos = _x;
   ypos = _y; snip

That's not a bad way of updating AS1. Just be aware that it's still AS1. If
you're going to need to maintain it, I'd go to AS 2. I'd subclass
MovieClip--it's not hard at all. You just put your functions (methods) in a
.as file, lose the MovieClip.prototype part, and use something like this
snippet from a movie I'm working on:

var ageSlider:AgeSliderClass = myRoot.attachMovie(SliderBead_and_Shadow,
AgeSliderClass, myRoot.getNextHighestDepth());

It's probably better to use DepthManager, especially if you're going to have
components, to get the depth. Regardless, you'll have much more maintainable
code with AS2 (or AS 3, if FP 9 is your target). They're much more
OOP-oriented.

Cordially,

Kerry Thompson


___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread Jesse Graupmann
This works, but it's not really doing anything specific to AS2.0.


MovieClip.prototype.mcbounceload = function() 
{
this.bounce = 0.4;
this.speed = 0.9;
this.x = this.xpos = this._x;
this.y = this.ypos = this._y;
};

MovieClip.prototype.mcbounceenter = function()
{
this.x = (this.x * this.bounce) + ((this.xpos - this._x) *
this.speed);
this.y = (this.y * this.bounce) + ((this.ypos - this._y) *
this.speed);
this._x += this.x;
this._y += this.y;
};


mc.mcbounceload ();
mc.onEnterFrame = function()
{
this.xpos = _xmouse;
this.ypos = _ymouse;
this.mcbounceenter();
}


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of coker todd
Sent: Thursday, August 16, 2007 8:15 PM
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] porting to Flash 8

so the new code reads:

MovieClip.prototype.mcbounceload = function () { 
bounce = 0.4;
speed = 0.9;
xpos = _x;
ypos = _y;
};

MovieClip.prototype.mcbounceenter = function () {
x = x*bounce+(xpos-_x)*speed;
_x += x;
y = y*bounce+(ypos-_y)*speed;
_y += y;

};

on each MC this is the code:

onClipEvent (load) {
mcfedernload();
}
onClipEvent (enterFrame) {
mcfedernenter();
}

code on each button:

on (release) {
_parent.mc2.xpos = 26;
_parent.mc2.ypos = 247;
_parent.mc3.xpos = 26;
_parent.mc3.ypos = 267;
_parent.mc4.xpos = 26;
_parent.mc4.ypos = 287;
_parent.mc5.xpos = 26;
_parent.mc5.ypos = 307;

Does this help??

___
Flashcoders@chattyfig.figleaf.com
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


回复:RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread 方林勇
 can u give me the fla file, thanks!i really don't know what do u want ?when i 
see your fla file  ,maybe i'll know what do u want?  
在2007-08-17,coker todd [EMAIL PROTECTED] 写道:
so the new code reads: MovieClip.prototype.mcbounceload = function () { bounce 
= 0.4; speed = 0.9; xpos = _x; ypos = _y; }; MovieClip.prototype.mcbounceenter 
= function () { x = x*bounce+(xpos-_x)*speed; _x += x; y = 
y*bounce+(ypos-_y)*speed; _y += y; }; on each MC this is the code: onClipEvent 
(load) { mcfedernload(); } onClipEvent (enterFrame) { mcfedernenter(); } code 
on each button: on (release) { _parent.mc2.xpos = 26; _parent.mc2.ypos = 247; 
_parent.mc3.xpos = 26; _parent.mc3.ypos = 267; _parent.mc4.xpos = 26; 
_parent.mc4.ypos = 287; _parent.mc5.xpos = 26; _parent.mc5.ypos = 307; Does 
this help?? --- Jesse Graupmann [EMAIL PROTECTED] wrote:  AS 2.0 is case 
sensitive. You can start by changing  Movieclip to MovieClip   Not sure why 
you are using a function as a  multiplier, so you might want to  get rid of 
theMover reference inside itself. 

 Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=listsid=396545469 
___ 
Flashcoders@chattyfig.figleaf.com 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
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread Kerry Thompson
Jesse Graupmann wrote:
 
 This works, but it's not really doing anything specific to AS2.0

:-)


___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread coker todd
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
 
 :-)
 
 
 ___
 Flashcoders@chattyfig.figleaf.com
 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
 



   

Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=listsid=396545469
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread Kerry Thompson
coker todd wrote:
 
 Thanks Kerry, what would make it specific?

As I said in my earlier e-mail, I would lose the .prototype. Everywhere.
That's pure AS 1.

I would subclass MovieClip. That's a pretty standard technique. Write a
class (that is, a .as file) that starts something like this:

class Calculator extends MovieClip
{

   public function init (// whatever args you want to pass)
   {
  // Initialize your vars
   }

   function onRelease()
   {
  // do what you want when the MC is clicked
   }

   function onRollOver()
   {
 this.gotoAndStop (Over);
   }

   function onRollOut()
   {
  this.gotoAndStop (Up);
   }
}

And so on. You can override any or all of the MovieClip Class methods and do
what you want in them.

To associate a MC with a class, you need to right-click its symbol in the
library and set the linkage to the class. Your class will be exactly the
name of the .as file, case-sensitive.

Then, you use AttachMovie() to attach it to the timeline of whatever movie
clip it's in (that could be the main movie), passing the name of the class
like I did in my example a few minutes ago. It's all in the help file, under
AS 2 classes. Or, if you tell me your class name and movie clip name (the
library symbol), I'll give you the line of code to attach it to your movie
clip, subclass and all.

Cordially,

Kerry Thompson


___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread Jesse Graupmann
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: flashcoders@chattyfig.figleaf.com
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
 
 :-)

___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] porting to Flash 8

2007-08-16 Thread coker todd
rather than having onClipEvents on each MC, why
wouldn't this work?

this.onLoad=function(){
mc.mcbounceload();
mc2.mcbounceload();
mc3.mcbounceload();
mc4.mcbounceload();
mc5.mcbounceload();
}


this.onEnterFrame = function(){
mc.mcbounceenter();
mc2.mcbounceenter();
mc3.mcbounceenter();
mc4.mcbounceenter();
mc5.mcbounceenter();
}


  

Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 

___
Flashcoders@chattyfig.figleaf.com
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