Tuesday, October 5, 2010

Flash in the smooth scrolling examples of analytic theory and


Smooth up and down scroll bar example:




Technical Data:

How to use:

Film clips scrollMC the onLoad event:
showHeight = 350;
myHeight = 350;
speed = 13;
targetMovie = "show.testMC";

showHeight used to specify the display a high degree of binding of MC, myHeight specify the height of the scroll bar itself. sliding speed is the speed, the greater its value, sliding more slowly. targetMovie MC specified binding path (relative).

Technical Insider:

ActionScript main focus in an empty movie clip:

onClipEvent (enterFrame) (
mcMoved ();
)


onClipEvent (load) (
a = eval ("_parent._parent." + _parent.targetMovie);
function mcMoved () (
whereY = - (a._height-_parent.showHeight) * (_parent.dragMC._y / (_parent.myHeight-38));
var tempK = whereY-a._y;
if (Math.abs (tempK)> 1) (
a._y + = tempK / _parent.speed;
nowY = _parent.dragMC._y;
)
)
)

a = eval ("_parent._parent." + _parent.targetMovie); used to bind the MC designated location. Later you can use a._x, a._alpha to access the movie clip, and with this technology are similar _parent ["myMC"].

whereY = - (a._height-_parent.showHeight) * (_parent.dragMC._y / (_parent.myHeight-38)); mainly used to calculate the binding of the MC should scroll to the position.

function goArea (a) (
dragMC._y = (showHeight-38) * a;
)

This is more important, is directly related to the occupancy rate of the CPU. First of all, if (Math.abs (tempK)> 1) determine the current position to scroll to whether a pixel from the current location of the difference. Math.abs () is to calculate the absolute value of the function. If not, that has to scroll to the location should be accessible, not to redraw the frame. (Flash to draw a frame image to consume considerable CPU, a matter of fact, CPU spent most of the use of display above. AS implementation as long as the little CPU, so necessary to judge, to remove unnecessary re- draw. can reduce the CPU usage. at least in the mouse can not re-interact well reduce the CPU utilization). If its value is greater than 1, it will bind the MC position recalculation.

a._y + = tempK / _parent.speed; is a formula often used for sliding, in fact, is this true formula: a._y + = (whereY-a._y) / _parent.speed here only in the previous step to simplified.


function goArea (a) (
dragMC._y = (showHeight-38) * a;
)

Function corresponding to the three buttons "scroll to the 1 / 3, scroll to the 1 / 2, scroll to 2 / 3," The principle should not be difficult to understand think about.






Recommended links:



UTM Revolution - Who can not have both fish and bear's paw?



Hart governance "disease" Hewlett-Packard



Compilation Of Various Source - Frespace



My favorite Printer



Thread contact mechanism



Record 2 room to visit a new generation of IDC



3GP to WMV



Compare Printer



TS to MKV



Simple Games Arcade



download unlimited psp games for free



Recommend Covert Surveillance



A domestic room, map description IDC



DivX to IPod



"Soldier of blood," the official version of the game experience and EVALUATION



No comments:

Post a Comment