Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorIan
    • CommentTimeMar 13th 2008 edited
     
    here's a little trick i came up with a few weeks ago. it assumes CS3 and AS3 knowledge.

    create a continueBtn class which controls the timeline of its parent, like so:


    package com.davita.buttons
    {
    import flash.display.*;
    import flash.events.*;

    public class ContinueButton extends MovieClip
    {
    public var _myParent:MovieClip;

    public function ID_ContinueButton()
    {
    super();
    addEventListener(Event.ADDED_TO_STAGE, initialize);
    addEventListener(Event.REMOVED_FROM_STAGE, removed);
    addEventListener(MouseEvent.CLICK, clicked)
    _myParent = (this.parent as MovieClip);
    }

    function initialize(event:Event):void
    {
    this._myParent.stop();
    removeEventListener(Event.ADDED_TO_STAGE, initialize);
    }

    function removed(event:Event):void
    {
    removeEventListener(Event.REMOVED_FROM_STAGE, removed);
    }

    function clicked(event:MouseEvent):void
    {
    _myParent.play();
    }

    }
    }


    create a document class and declare an array to hold user interactions:

    public var interactions:Array = new Array();

    then, whenever the student clicks the ContinueBtn, store that frame # in the interactions array:


    private function init(event:Event):void
    {
    removeEventListener(Event.ADDED_TO_STAGE, init);
    _myParent = parent.parent as MovieClip;
    hasAudio = false;
    allowsNavigation = true;
    this.addEventListener(MouseEvent.CLICK, clickHandler);
    }

    private function clickHandler(event:MouseEvent):void
    {
    trace(getQualifiedClassName(event.target));
    trace(interactions);
    switch (getQualifiedClassName(event.target)){

    case "Continue" :
    removeChild(event.target);
    interactions.push(this.currentFrame);
    break;

    case "BackBtn" :
    this.gotoAndPlay(interactions.pop());
    break;

    default:
    trace("event.target: " + event.target);
    trace("event.target.name: " + event.target.name);
    }
    }


    obviously this assumes a BackBtn class as well, which can be assigned to any mc from within the flash ide.

    hopefully this makes some sense. basically, we've created a button class which stops the main timeline when it is added to the stage and plays the timeline when it is clicked. then, in the document class, each time the ContinueBtn is clicked, it stores a frame # in an array. when the BackBtn is clicked, it returns the timeline to the last stored frame #.

    tl/dr: continue and back buttons without writing any stop() gotoAndPlay() actions.
    • CommentAuthorphilip
    • CommentTimeMar 13th 2008
     
    basically, we've created a button class which stops the main timeline when it is added to the stage and plays the timeline when it is clicked.

    that sounds like a handy trick!
    • CommentAuthorIan
    • CommentTimeMar 13th 2008
     
    in case it needs some more illustration, here is an example which demos the use of the continue button as well as some of my workflow:

    continue buttons:
    http://imstillrad.com/podcasts/01_coursefile.mp4