Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code working for Flash player 6 settings but not for 8....

Status
Not open for further replies.

michanagel

Technical User
Jun 23, 2007
34
US
Hi,

I'm pretty new to Action script and I have a problem here that I can't seem to figure out.

I have this Action Script Code which is attached to a simple movieclip, and it all works IF the general settings are set for Flash Player 6.

It does not work for Flash Player 7 or above, which is probably because this is Actions Script 1 Code...

I attached the .fla file and also here's the code:

Code:

onClipEvent (load) {
accel =0;
rate = 0.05;
trace(_y)
_root.ykoord=0;
}

onClipEvent(enterFrame) {
y=y*accel+(_root.ykoord-_y) * rate;
_y+=y;
if(Math.abs(_root.ykoord-_y)<1) { _y=_root.ykoord; }

}

Do I need to change the code ?

I wanna publish in Action Script 2 for either Flash player 8 or 9.

Thanx for your help in advance !!!

Mike
 
One thing, Flash players are backward compatible, FP9/8/7 can play AS1 with no problems. Further, AS1 and AS2 are basically the same from the Flash Player's point of view, it won't create compatibility issues like you're talking about.

Your code has a problem: [tt]y=y*accel+(_root.ykoord-_y) * rate;[/tt]
Because "y" is not defined, the above code produces NaN (undefined * Number = NaN).

Since accel = 0, y*accel = 0 anyway, so why not just do:
[tt]y=(_root.ykoord-_y) * rate;[/tt]?

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top