Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

drag inertia

New Here ,
Nov 08, 2014 Nov 08, 2014

Bonjour,

Je cherche a créer une navigation (Effet smart phones/tablettes) avec un déplacement vertical et inertie.

Mon FLA :

3 positions (1) (2) (3) et 3 calques (Navigation/Actions/Conteneur).

Calque 1 sur lequel j'ai placé ma navigation avec les boutons (Instance name / BTN_CHARGER_PDF01), le premier déplace la tête de lecture en position (2) :

Au dessus, le calque 2 (Actions) avec le code suivant :

BTN_CHARGER_PDF01.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event: MouseEvent): void {

    gotoAndStop(2);

}

BTN_CHARGER_PDF02.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_3);

function fl_ClickToGoToAndStopAtFrame_3(event: MouseEvent): void {

    gotoAndStop(3);

}

Calque  2 / image 2 sur lequel j'ai placé un conteneur nommé "content_mc"

Au dessus, le calque 2 (Actions) avec le code suivant :

import flash.events.MouseEvent;

import flash.events.Event;

content_mc.y = -900;

var currentStep:Number = content_mc.y;

var step:Number = 300;

var max:Number = 0;

var min:Number = -1800;

var distMin:Number = 100;

var nextY:Number = currentStep;

var startY:Number;

var offsetY:Number;

var moving:Boolean = false;

var smooth:Number = 0.15;

var mouseIsUp:Boolean = true;

content_mc.addEventListener(MouseEvent.MOUSE_DOWN,onDown);

function onDown(e:MouseEvent):void{

        offsetY = content_mc.mouseY;

        startY = mouseY;

        moving = true;

        mouseIsUp = false;

        if(!hasEventListener(Event.ENTER_FRAME))addEventListener(Event.ENTER_FRAME,update);

        stage.addEventListener(MouseEvent.MOUSE_MOVE,onMove);

        stage.addEventListener(MouseEvent.MOUSE_UP,onUp);

}

function onUp(e:MouseEvent):void{

        mouseIsUp = true;

        var dy:Number = mouseY - startY;

        if( dy < -distMin){

                currentStep -= step;

                if(currentStep < min) currentStep = min;

        }else if(dy > distMin){

                currentStep += step;

                if(currentStep > max) currentStep = max;

        }

        nextY = currentStep;

      

        stage.removeEventListener(MouseEvent.MOUSE_MOVE,onMove);

        stage.removeEventListener(MouseEvent.MOUSE_UP,onUp);

}

function onMove(e:MouseEvent):void{

        nextY = mouseX - offsetY;

}

function update(e:Event):void{

        if(moving){

                content_mc.y -= (content_mc.y - nextY) * smooth;

                if(mouseIsUp && Math.abs(content_mc.y - nextY) < 1){

                        content_mc.y = nextY;

                        moving = false;

                        removeEventListener(Event.ENTER_FRAME,update);

                }

        }

}

Enfin, sur la troisième image, un second conteneur nommé "content_mc"

Ce codage fonctionne parfaitement pour le premier bouton (déplacement et effet d'inertie)

Mais au clic sur le deuxième bouton, le conteneur s'affiche, mais sans déplacement ni effet d’inertie.

Pouvez vous m'aider ?

Merci

TOPICS
ActionScript
369
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2014 Nov 08, 2014

you probably have more than 1 keyframe with content_mc, and while it may appear to you that they are the same, flash does not.

to remedy, create a new layer > in frame 1 of that new layer add content_mc > remove content_mc from all other layers and all other keyframes.

test.

content_mc should work the way you want though it will probably be in the wrong position when your main timeline changes frames.

if that's true, add keyframes in that new layer (being careful to NOT remove content_mc from any of the keyframes).  reposition content_mc in those additional keyframes, as needed.  retest.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2014 Nov 08, 2014

Thank you,

Yes i have 2 keyframes with content_mc.
Each content_mc have a different content within a different movie clip.
What do you suggest me ?

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2014 Nov 08, 2014

Is it possible to send you the FLA ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2014 Nov 08, 2014
LATEST

you can send a fla for me to correct, if you want to hire me.

for free help, continue posting to this forum.

in response to your message #2, give the two different content_mc's different instance names and use code to apply to each.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines