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

Problem: Animation publishing incorrectly, but working in Cp preview.

Participant ,
Nov 28, 2011 Nov 28, 2011

Copy link to clipboard

Copied

Hi,

I created an animation in Flash CS5 with some code in it (see below for the code). What the code does is it allows the user to play/pause the movie by pressing the spacebar. It allows that keyboard shortcut to be used on all slides except certain ones (in this case: slides 9, 13, and 15). I just need to drop this animation onto the first slide of my Cp project, and the function works throughout the rest of the project. When I hit F4 to preview, it works great, but when I publish it, it has problems: It won't work, for starters, but also, when I go to a slide, press the spacebar, and then go back to the previous slide, the play/pause button down on the playbar shows the 'play' icon (meaning the video should be paused), but the video continues to play. The play/pause button in the playbar and the keyboard shortcut do nothing. Keep in mind that it works perfectly when I 'F4' it, just not when I publish it and open the SWF. Usually when stuff works in Cp but not when published, its something in the publish settings that's the problem, but I can't find anything in there that would help. Plus, F4ing the project within Cp should factor in the publish settings. Just to be clear, all I need help with is making the published file work exactly like the F4 preview. The code is below, and thanks to anyone that can help.

// Keyboard Shortcut: Play/Pause (Space)

stage.addEventListener(KeyboardEvent.KEY_DOWN, keypressPause);

function keypressPause(event:KeyboardEvent):void

{

    switch(event.keyCode)

    {

            case Keyboard.SPACE :

            var myRoot:MovieClip = MovieClip(root);

            var mainmov:MovieClip = MovieClip(myRoot.parent.root);

            if (mainmov.cpInfoCurrentSlide != 9 &&

                mainmov.cpInfoCurrentSlide != 13 &&

                mainmov.cpInfoCurrentSlide != 15)

                    {

                    if (mainmov.rdcmndPause == 1)

                        {mainmov.rdcmndResume = 1;}

                        else

                        {mainmov.rdcmndPause = 1;}

                    break;

                    }

    }

}

TOPICS
Import export

Views

1.4K

Translate

Translate

Report

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

correct answers 1 Correct answer

Advisor , Dec 09, 2011 Dec 09, 2011

The issue is the way the code is obtaining Captivate's main time line (mainmov).  When you F4 the movie, it's being loaded differently than when you F12 web preview... thus the main time line is obtained differently.  Here's a way to search for the main time line and the rest of the code:

import flash.display.DisplayObject;

import flash.display.DisplayObjectContainer;

import flash.utils.describeType;

import flash.display.MovieClip;

var mainmov:MovieClip = findMainMovie();

// Keyboard Shortcut: Play/Pa

...

Votes

Translate

Translate
Participant ,
Nov 28, 2011 Nov 28, 2011

Copy link to clipboard

Copied

Alternatively, I would be able to do the same thing directly thru Cp without having to use code if someone could tell me how to assign the spacebar as a clickbox shortcut. It would seem that (for some reason...) the spacebar is not an option as a Cp keyboard shortcut. I don't know why, but if I knew how to get around that, I could do the same thing with advanced actions without even having to use the code. Both methods are useful though, so if someone can answer both, that would be awesome. Thanks.

Votes

Translate

Translate

Report

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
Advisor ,
Dec 02, 2011 Dec 02, 2011

Copy link to clipboard

Copied

Are you externalizing your animations / widgets?  Try publishing with them not externalized.

CropperCapture[11].jpg

Votes

Translate

Translate

Report

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
Participant ,
Dec 07, 2011 Dec 07, 2011

Copy link to clipboard

Copied

No, they are not externalized.

Its been weeks now and I'm still stumped, so if anyone happens to know the answer, I'm still in need.

Thanks.

Votes

Translate

Translate

Report

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
Advisor ,
Dec 09, 2011 Dec 09, 2011

Copy link to clipboard

Copied

I can take a look if you want to send over the .fla and .cptx files.  Jim AT Captivate Dev dot com.

Votes

Translate

Translate

Report

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
Advisor ,
Dec 09, 2011 Dec 09, 2011

Copy link to clipboard

Copied

LATEST

The issue is the way the code is obtaining Captivate's main time line (mainmov).  When you F4 the movie, it's being loaded differently than when you F12 web preview... thus the main time line is obtained differently.  Here's a way to search for the main time line and the rest of the code:

import flash.display.DisplayObject;

import flash.display.DisplayObjectContainer;

import flash.utils.describeType;

import flash.display.MovieClip;

var mainmov:MovieClip = findMainMovie();

// Keyboard Shortcut: Play/Pause (Space)

stage.addEventListener(KeyboardEvent.KEY_DOWN, keypressPause);

function keypressPause(event:KeyboardEvent):void

{

    switch(event.keyCode)

    {

                    case Keyboard.SPACE :

                   

                    if (mainmov.cpInfoCurrentSlide != 9 &&

                              mainmov.cpInfoCurrentSlide != 13 &&

                              mainmov.cpInfoCurrentSlide != 15){

                                        if (mainmov.rdcmndPause == 1){

                                                  mainmov.rdcmndPause = 0;

                                                  mainmov.rdcmndResume = 1;

                                        }else{

                                                  mainmov.rdcmndPause = 1;

                                                  mainmov.rdcmndResume = 0;

                                        }

                    }

                    break;

    }

}

//Returns the Captivate MainTimeLine

function findMainMovie():MovieClip

{

          var cpMovie:MovieClip;

          //cpMovie = parent.parent.parent;

          cpMovie = findParentByType(this.parent, "CaptivateMainTimeline") as MovieClip;

          return cpMovie;

}

//Iteratively finds a parent object by type

function findParentByType(source:DisplayObject, parentType:String):DisplayObjectContainer {

          var currentTarget:DisplayObjectContainer = source.parent;

          while (currentTarget != null) {

                    if (describeType(currentTarget).@name.indexOf(parentType) >= 0) return currentTarget;

                    currentTarget = currentTarget.parent;

          }

          return null; // We're at the root

}

The code to search for the main time line was gleaned from CpGears written by Whyves

I'd encourage you to think about making this into a Captivate static widget using the CpGears framework or the WidgetFactory framework by Tristan Ward.  Either framework will make your life much easier.

I usually set the two variables in tandem: rdcmndPause and rdcmndResume so that all variables stay in sync.

When I dropped the animation into the Cp project, I had to set it to display for "rest of project" in order for it to work across all slides.

Report back and let us know how it goes.

Jim Leichliter

Votes

Translate

Translate

Report

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
Resources
Help resources