ࡱ> Root Entryp|YrRASH\`NContentsPage 1{ Symbol 1 !"#$%&/Root Entryp|YrRASHLNContentsPage 16 Symbol 1 '()*+,-.Symbol 2%Symbol 3Symbol 4 CPicPage CPicLayer CPicFrame03'XD(4r<4<4r(?@ABCDEFGHIJKLMNOPQif (fr < .99) fr += .01 } Layer 2OO0jQ5(?2_ Layer 1OCPicPage CPicLayer CPicFrameCPicText C@spVerdana333"(CPicPage CPicLayer CPicFrameQ50jQ5(?2_ Layer 1OCPicPage CPicLayer CPicFrameCPicText C@spVerdana333"( cVerdana333"(speed: 'C@frVerdana333"( O#$@ Verdana333"(coefficient: CPicButton- -dbt_inc - -dJbt_dec  Verdana333"([ Verdana333"(Click on the ball!Verdana333"( ] ]`,@0@0]0 ?#H Layer 1O]0M,0R0?r Layer 3OO?,/* Simple Friction Example version 1.0 by Marco Lapi -- December 2003 www.gotoAndPlay.it */ //--- Setup variables ------------------------------------------------------------------- speed = 12 // ball speed constant sp = 0 // holds current ball speed fr = 0.95 // friction value stageW = 600 // stage Horiz. limit stageH = 197 // stage Vert. limit dir = 1 // move right = 1, move left = -1 //--- Attach Red Ball MovieClip ---------------------------------------------------------- _root.attachMovie("ball","ball_mc",100) px = stageW / 2 py = stageH - ball_mc._height ball_mc._x = px ball_mc._y = py //--- Attach Reflection mc --------------------------------------------------------------- _root.attachMovie("reflection","ref_mc",101) ref_mc._x = px ref_mc._y = py + ball_mc._height ref_mc._height = ref_mc._height / 2 ref_mc._alpha = 30 //--- Attach Event Handlers -------------------------------------------------------------- ball_mc.onPress = handleClickEvent ball_mc.onEnterFrame = mainThread bt_inc.onRelease = incFriction bt_dec.onRelease = decFriction //--- M A I N () Thread ------------------------------------------------------------------ function mainThread() { sp = sp * fr // multiplies speed * friction if (sp < .01) sp = 0 // stop calculation if sp < .01 this._x += sp * dir // move ball ref_mc._x += sp * dir // move reflection if (this._x > (stageW - this._width)) // check if ball is at the stage limit and dir = -1 // change speed if so else if (this._x < 0) dir += 1 } function handleClickEvent() { sp = speed } function decFriction() { if (fr > .80) fr -= .01 } function incFriction() { ) CDocumentPagePage 1Scene 1?j?Symbol 2butt_inc?Symbol 2?Symbol 3butt_dec? butt_inc copy?Symbol 1ball6?ballSymbol 1?Symbol 4 reflection? reflection ball copy?.hhhhh< CColorDef3PfP0PHP`Px333(3f<03CH3F`3Hxf0f30ff(0f5Hf<`f@x3330333xf3d03]H3Z  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRCPicPage CPicLayer CPicFrameQ50jQ5(?2_ Layer 1OCPicPage CPicLayer CPicFrameCPicText C@spVerdana333"(F;&$1MqFA ?m Layer 2OOCPicPage CPicLayer CPicFrame CPicShape03'wt r<4<4r( (stageW - this._width)) // check if ball is at the stage limit and dir = -1 // change speed if so else if (this._x < 0) dir += 1 } function handleClickEvent() { sp = speed } function decFriction() { if (fr > .80) fr -= .01 } function incFriction() { if (fr < .99) fr += .01 } Layer 2OO2_ Layer 1OCPicPage CPicLayer CPicFrameCPicText C@spVerdana333"() CDocumentPagePage 1Scene 1?k?Symbol 2butt_inc?Symbol 2?Symbol 3butt_dec? butt_inc copy?Symbol 1ball6?ballSymbol 1?Symbol 4 reflection? reflection ball copy?.hhhhh< CColorDef3PfP0PHP`Px333(3f<03CH3F`3Hxf0f30ff(0f5Hf<`f@x3330333xf3d03]H3Z`3Xx3333303f3PPH33Px`33Px33Pf30f33PHff3(PHf3<x`f3Cxf3Ffff`f03f0ffx0fkHfd`f`x3f033fPH3ffxPH3fdx`3f]x3fZff0f3fPHfff`ffP0xffPxffPH3HfHxH̙n`hx3H33x`3fx`3xx`3̙kx3dfHf3x`ff0xfx0xf̙dxf]`3`f``x`px3`33x3fx3x3xx3nf`f3xffxfxfxxfkx3xfxxxxx3x333f333xfxf3fffffxxH3 HfH(H2`8x`3 `f`̙`(`0xx3xfxx x(xPx3H33x`f3x`3(x`35x3<3`33xf3 x̙3x3(x323x33f3 333(xfH3fx`ff0xf(0xf<xfCf`3fxffx̙fxf(xf5fx3ffff ff((xH3x`f0x̙PPP`3xfx̙P̙(P<x3f̙(xx`3xfxPxPd`3xfx̙PPx3f(xx3fxx3f̙xx3f`3Xx3333303f3PPH33Px`33Px33Pf30f33PHff3(PHf3<x`f3Cxf3Ffff`f03f0ffx0fkHfd`f`x3f033fPH3ffxPH3fdx`3f]x3fZff0f3fPHfff`ffP0xffPxffPH3HfHxH̙n`hx3H33x`3fx`3xx`3̙kx3dfHf3x`ff0xfx0xf̙dxf]`3`f``x`px3`33x3fx3x3xx3nf`f3xffxfxfxxfkx3xfxxxxx3x333f333xfxf3fffffxxH3 HfH(H2`8x`3 `f`̙`(`0xx3xfxx x(xPx3H33x`f3x`3(x`35x3<3`33xf3 x̙3x3(x323x33f3 333(xfH3fx`ff0xf(0xf<xfCf`3fxffx̙fxf(xf5fx3ffff ff((xH3x`f0x̙PPP`3xfx̙P̙(P<x3f̙(xx`3xfxPxPd`3xfx̙PPx3f(xx3fxx3f̙xx3ff`zf*]ahf`zf*]ah