Child .swf controlling parent timeline
Hello Captivate Heroes,
I've searched around, and can't seem to find any solid info on an issue my team is having. I'm a bit of a noob when it comes to Javascript, so I apologize if this question is too basic for this forum.
Is it possible for an embedded .swf (created in Captivate) to control the main timeline in a parent .swf? Consider the example below:
1) This window is an embedded .swf (another captivate file, which I’ll refer to as the “child”) that has an interactive walkthrough. It loads and begins playing immediately. I want users to complete this module and all interactions in it before continuing to the next slide in the “parent” file. Essentially, I want either the child or the parent timeline to play, but never both at the same time.
2) This is our normal continue button, and I don’t want it appearing until 1 has been completed.
My solution was to add a javascript call on the first slide of the child file that tells the parent file to pause its timeline (something like _root.rdcmdPause=1;). Then, do the opposite on the last child slide ( _root.rdcmdResume=1;). In this way, the parent slide would essentially pause on its first frame (which doesn’t have an active continue button) while the child animation continues to play. However, this isn’t working. It’s been a really long time since I’ve scripted, so I’m very rusty. Is that the proper way to manipulate parent variables in a child file? Do you have any other ideas on how to accomplish this task?
I have a backup solution -- providing a "password" at the end of the child animation, which users can use to unlock the continue button. I'd rather use a more graceful solution
Thank you in advance,
Jamie
Hi Jamie,
I don't think JavaScript is going to help you here. You need to be doing this in ActionScript 3.
For the non-scripting part, you can control the Captivate movie using system variables. To pause the main slide, you could assign rdcmdPause=1 on the Slide Entry action. You may want to adjust the slide transition to none so that it won't look faded out when it pauses the movie. You can also show/hide items on the slide using the timeline, but it sounds like you won't really know when the Learner will be done with the interactive child .swf.
From what you described, it sounds like the Child .swf (#1) needs to communicate with other objects on the slide... mainly the continue button (#2). In order to do that you'll most likely need to make the child .swf #1 into a widget so that it can communicate with the main movie and other objects on the slide. I would suggest 3 possibilities:
1. Learn to use a widget framework such as Widget Factory or CpGears to make this possible
2. Take a look at the Infosemantics Event Handler Widget. Not sure if it will meet all your needs, but it's worth a look.
3. Hire a Captivate Widget Developer to make this possible... and yes I am a Widget Developer (shameless plug )
Hope that helps,
Jim Leichliter
Similar Messages
-
Problems accessing child swf from parent class
First off: Hi. I'm new - to the forum and to Flash.
I'm currently writing a flash app that requests a XML feed
from a Java controller and loads child swfs into various parts of
the stage based on the settings/URL details received from the XML
feed.
Its nearly there and I've got my head round a couple of weird
things, but theres one thing left that I've found impossible to
solve. Once the loader class has loaded the swf, it can't access
its methods or set its variables and the child can't access the
parent either (or access the parent's variables full stop). From
what I've read this should be possible. Heres some of my code plus
pseudo code:
Note the Panel class is not linked to a symbol and uses
composition to act like a movie clip, rather than inheritance.
quote:
class Panel{
function Panel(owner:MovieClip, insName:String,
depth:Number){
initiates properties etc....
panelMovie = owner.createEmptyMovieClip(insName,depth);
listener.onLoadComplete = mx.utils.Delegate.create(this,
scheduleModule);
loader.addListener(listener);
loader.loadClip(moduleX.url, panelMovie);
function scheduleModule(){
trace(panelMovie.key);
trace(panelMove.keyTest());
panelMovie.key = "dave";
trace(panelMovie.key);
Child swf:
quote:
var key:String = "test";
As you can see I create an empty movieclip which I store a
reference to in this class under the field "panelMovie". I then use
this (instead of target_mc like you might do with an event handler)
to try to access the child swf. The output is:
trace(panelMovie.key); = "test" (Works fine)
trace(panelMove.keyTest()); = (Nothing returned)
panelMovie.key = "dave";
trace(panelMovie.key); = "test" (Previous line = no effect)
Is this something related to using a class? Really would be
preferentially to keep all code outside of the fla.
I've also tried a lot of different combinations of _root,
_parent and _levelx. None of which I truly understand.
Any help would be much appreciated! Plus any good tutorial
links on timeline and referring to objects in it!
(Couldn't find the code tag/button...)>>trace(panelMove.keyTest()); = (Nothing returned)
You have panelMove here instead of panelMovie
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
External SWF controlling main timeline
Hi all --
I have a main SWF file that I am loading a smaller, external
SWF file into (with loadMovie, if you care to know). Within that
smaller file, I have a button -- ideally, this button should
trigger an action within the main SWF file.
My problem is that I cannot get the external SWF file to
control an action within the main SWF. I'm guessing there must be a
way to do this, but I'm having some trouble here.
Thanks in advance... please advise!Well.... there may be a reason if it is set up correctly and
still doesn't work....
Is this external SWF hosted on another server?
If so, you might be running into crossdomain policy problems.
I've had the issue that remotely-hosted SWFs will not OBEY commands
from the root timeline while they are remote, but work just fine
when they are copied onto the same server as the main SWF.
Do a search on crossdomain policy XML in Flash help. It may
help you get around this problem. -
Need help with loading child .swf into parent .swf
Hello,
I am having trouble with an external .swf that isbeing loaded
into the master.swf. All of the files loads perfectly. However the
.swf that has the contact form movieclip in it will not work. The
combobox does that display any of the items listed and the form is
not being sent to the server. Can anyone give me a hand with
this?can you post your code
-
How a SWF Child can control a Parent's function/variable ?
For instance, in the below code a parent can control a SWF
child’s function “alert ()”.
But how a SWF child can control parent’s function
“ReceivingChildMsg()” ?Hi clbeech
I simplified the code to simply get the swf child controlling
its parent variable tp ( textfield ) and its content.
I used your suggestion (parent.ReceivingChildMsg( ) and
root.ReceivingChildMsg( )) but I get an error message:
quote:
“1061: Call to a possibly undefined method
ReceivingChildMsg through a reference with static type
flash.display:DisplayObjectContainer.”
Here is the code:
package
import flash.display.MovieClip;
import flash.text.*;
import flash.events.*;
import flash.display.SimpleButton;
public class Child extends MovieClip
public function Child():void
btn.addEventListener(MouseEvent.CLICK,clickHandler);
public function clickHandler(event:MouseEvent):void
//root.ReceivingChildMsg( "Received Child Message");
parent.ReceivingChildMsg( "Received Child Message");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
package
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.text.*;
import flash.display.SimpleButton;
public class Parent extends MovieClip
private var loader:Loader;
public function Parent():void
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onLoadComplete);
loader.load(new URLRequest('Child.swf'));
private function onLoadComplete(e:Event):void
var loaderInfo:LoaderInfo = e.target as LoaderInfo;
addChild(e.target.content);
var swf:Object = loaderInfo.content;
swf.x = 75;
swf.y = 50;
public function ReceivingChildMsg(msg:String):void
// tp textfield object is created directly in flash
tp.text = msg; -
RemoveChild in parent.swf from child.swf (AS3)
Hi! How do I remove a child from a parent timeline with an externally-loaded swf? Specifically, I have a main.swf that loads movie_1.swf and movie_2.swf. In the movie_1.swf, I have a button to remove movie_2.swf from main.swf.
//--------- main.swf code:
var loader1:Loader = new Loader();
var loader2:Loader = new Loader();
loader1.load(new URLRequest("movie_1.swf"));
loader2.load(new URLRequest("movie_2.swf"));
addChild(loader1);
addChild(loader2);
//------------- movie_1.swf code:
removeMovie2_btn.addEventListener(MouseEvent.CLICK , removeMovie2);
function removeMovie2(event:MouseEvent):void
this.parent.parent.removeChild(this.loader2); // this does not work (get error code 2007, "Parameter child must be non-null")
// Thank you!Here's how your code will change:
//--------- main.swf code:
var loader1:Loader = new Loader();
var loader2:Loader = new Loader();
loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, assignMovie1Listener);
loader1.load(new URLRequest("movie_1.swf"));
loader2.load(new URLRequest("movie_2.swf"));
addChild(loader1);
addChild(loader2);
function assignMovie1Listener(evt:Event):void {
MovieClip(evt.currentTarget.content).addEventListener("eventTriggered", removeLoader2);
function removeLoader2(evt:Event):void {
loader2.unloadAndStop();
removeChild(loader2);
//------------- movie_1.swf code:
removeMovie2_btn.addEventListener(MouseEvent.CLICK , removeMovie2);
function removeMovie2(event:MouseEvent):void
dispatchEvent(new Event("eventTriggered")); -
Parent SWF controlling Child SWF variables
1) The code below works but the browser sends an annoying
alert message
“Received Parent Message” and you are obliged to
click OK before the program can run. How can it be fixed ?
2) Why this code needs to use the
ExternalInterface class if the Child SWF gets loaded and
becomes incorporated in the Parent SWF ?
3) Is there a
simpler and more straightforward way for a Parent SWF to
communicate with a Child SWF ?
package
import flash.external.ExternalInterface;
import flash.display.Sprite;
import flash.text.*;
public class ChildMovie extends Sprite
public function ChildMovie():void
public function alert(msg:String):void
ExternalInterface.call('alert', msg);
txt.text = msg;
package
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.LoaderInfo;
import flash.display.Sprite;
public class ParentMovie extends Sprite
public function ParentMovie():void
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onLoadComplete);
loader.load(new URLRequest('ChildMovie.swf'));
private function onLoadComplete(e:Event):void
var loaderInfo:LoaderInfo = e.target as LoaderInfo;
addChild(e.target.content);
var swf:Object = loaderInfo.content;
swf.x = 75;
swf.y = 50;
swf.alert('Received Parent Message');Hi,
You can launch the SWF in new window with navigateToURL() available in flash.net package by passing the path of SWF as parameter to function as
navigateToURL(new URLRequest(domainPath + "/appmanager/login.swf")); -
Parent swf call function in Child swf not working
Hi all,
I'm having a problem with this and I just can't figure it out
:( (I've been trying different things and staring at it for hours
and I'm losing my mind...)
So I have a Parent swf that loads a Child swf (this goes
without any problems), but I want the Parent to call a function in
the child, now this is where it goes wrong...
The function the Parent has to call is named "lookupcar" and
needs to give the value "wagen" with it. The problem I think is
that the Parent wants to call the function but it still needs to
load (correct me if I'm wrong). Is there a way to check if the
Child swf is loaded completely before trying to call the function?
Could you give me an example of this please? Or any other
suggestions on what goes wrong?
Code in the Parent
root.inhoud.createEmptyMovieClip("thetext", "thetext",
this.getNextHighestDepth());
root.inhoud.thetext.loadMovie("uitrusting-wagenpark.swf");
root.inhoud.thetext.lookupcar(wagen);
Code in the Child
(the function lookupcar)
_global.lookupcar = function(carnr:String){
trace("LOOKUPCAR, with car nr: " + carnr);
Thanks in advance for all the help.Perfect....just to make sure i m taking care of it in a nice practical way....here is how i learned to access a file located in Child (researching other posts)
is this the way you recommend it?
(LoaderName.content as MovieClip).functionName(new Event("whatever"))
and in Child File we have
function functionName(e:Event)
i have seen other ways of calling a function in Child Swf , like using EmbedSWF and etc. wanna make sure which one is a better practice. Thanks -
Calling a parent function when child .swf closes
I am adding a child .swf from the parent with a simple button. If this button is then clicked multiple times, the child is added multiple times. So I added the ".visible = false" to the button when clicked so the button cannot be clicked while the child is open.
Now, there is "Close" button on the child .swf that uses "this.parent.parent.removeChild(this.parent);" and would now need to set the parent button back to ".visible = true".
I have tried MovieClip.parent.parent.resetButton(); and parent as MovieClip.resetButton(); and many variations of the code. I get no errors but the code doesn't work either.
Any ideas?
Thank you.Figured this out on my own (don't believe it) without the child/parent communication.
When the parent's button is clicked, I'm checking to see if the child already exists. If so, it won't create the child again.
I'd still like to know how to perform the communication between child and parent. -
Dispatching and Event in Parent SWF & Receiving it in Child SWF
Hi All...
I would like to receive an event(Dispatchd in Parent swf) in Child SWF, the bold italic text represents the piece of coding i require help with
//in PARENT SWF i have -----------------------------
dispatchEvent(new Event("CloseDoors"))
// in Child SWF --------------------------------
here i need a code that catches the event dispatched in parent.addEventListener("closeDoors",closedoor)
Please let me know if there are alternative ways to do it. I think some people prefer to listen to the event also in Parent file and run
the function in CHild from parent file....i would like to learn the best practive to INFORM CHILDREN through a PARENT FILE...
Thanks.Perfect....just to make sure i m taking care of it in a nice practical way....here is how i learned to access a file located in Child (researching other posts)
is this the way you recommend it?
(LoaderName.content as MovieClip).functionName(new Event("whatever"))
and in Child File we have
function functionName(e:Event)
i have seen other ways of calling a function in Child Swf , like using EmbedSWF and etc. wanna make sure which one is a better practice. Thanks -
IDE: Child movieclip timeline changes don't show in parent timeline?
Why does a child movieclip only show the first frame within the IDE, regardless of where you are in the parent timeline?
If you throw a movieclip with 25 frames onto the main timeline, which also has 25 frame, you don't see the nested movieclip's frame-progress while you scroll through the main timeline.
Is there a setting somewhere in preferences or somewhere that will enable you to see a nested movieclip's frame position from the main timeline? Like you do with After Effects composites?The best answer I can think of is that's the way it is. Movieclip symbols in a timeline only display their initial frame contents. If you traverse the containing timeline, you aren't traversing the timelines of the objects contained in it. That helps keep main/containing timelines small.
Darn, thanks Ned. I wish this were not the case, as it would be very useful to see what's actually going on. I've not looked into graphic symbols, maybe I can use them, thanks! -
Loaded child movie controlling container parent
hi,
i'm a designer trying to step up my flash skills and have a scripting problem that's causing me trouble.
essentially i have a child swf loaded into a container in a parent swf and want the child to be able to instruct the parent.
to explain in full, the child contains an flv with bespoke video player components. it's container sits in one frame of the parent.
when the flv finishes playing, i need the parent swf to move onto another frame.
as it's a controllable flv, it isnt possible to predict the exact length of time the child will need to be present, so it literally needs to tell the parent it's finished playing at that very point.
it's actionscript 2 for flash 8.
unfortunately my scripting isnt up to this, and i cant seem to find any info to help me out.
any help would be greatly appreciated.
thanks in advance!thanks, that's one half of the battle!
the remaining problem is i have a controllable flv in the child swf, therefore i can't guarantee the length of time the flv will run as it may be paused etc.
is there some script i can tag on first that recognizes when the flv has ended?
realistically this is a topic in itself, but if you can help it would be appreciated.
thanks. -
Child.swf to pass two variables to parent in global function
Hi, I have a parent.swf and wish to load a varying child.swf as a sub-menu. How do I establish a global function that will allow the child.swf to pass back two variables (storyName & storyType) to the parent and kick off a task.
The submenu (swf) items will change so I cannot explicitly add a listener to a child.button. The submenu is on a children’s library so will have numerous graphics and movieclips included so I don’t think it would be suitable to simply call xml data to build a menu at runtime (at my level of knowledge). There will be a number of child.swf depending on books available.
I am not familiar with package { and public class { etc...
In as2 I would have used a _global.function() and used that to pass the variables back to the parent and then start a parent.action.
Totally new to AS3, suggestions appreciated. I have no problem loading the child.swf.Hi Ned, thank you for your response. I don’t know if it is relevant, but the container clip is run via AIR. That seems to affect some things as I’ve lost fullscreen functionality somewhere.
I tried you suggestions, if I have translated it into place correctly I don’t know. Do I need to treat the parent.parent as a variable (yes this one is done via a loader) ?
I get an error if I leave the function call open, I can tell I’m getting into the call as the trace on each side is happening.
In the External Movie:
blob_b.addEventListener(MouseEvent.CLICK, ms_bF);
function MbRemEL(nameof:String):void {
blob_b.removeEventListener(MouseEvent.CLICK, ms_bF);
function ms_bF(event:MouseEvent):void {
var m_ar:Array = new Array();
m_ar=event.target.name.split("_");
MbRemEL("r");
trace("StoryMenu: "+event.target.name);
if (this.parent.parent != null){
MovieClip(parent.parent).story = event.target.name;
//MovieClip(parent.parent).gcr(event.target.name);
// = TypeError: Error #1006: gcr is not a function.
MovieClip(parent.parent).gotoAndStop("g_home");
In Container Movie:
function gcr(stry:String):void{
trace("gcr: "+stry); -
Hello,
Can a parent .swf listen for an event in a child .swf?
Thanks!
ErinExactly how you add listener to anything.
myLoadedMovie.addEventListener("eventType", myEventHadler); -
Controlling loaded swf from main timeline
Hello,
I'm working on loading external swf files for ios. I am able to load the swf files and set them to visible or invisible in different frames. I am having trouble controlling the loaded swf files from the main timeline. Specifically, I would like to have a button on the main timeline, that when clicked will move a loaded swf to frame 1.
Here is a code that loads one swf file:
var myLoader1:Loader;
var loaderContext1:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
if(myLoader1 == null)
myLoader1 = new Loader();
addChild(myLoader1);
myLoader1.load(new URLRequest("folder/file1.swf"),loaderContext1);
myLoader1.visible = true;
backbutton.addEventListener(MouseEvent.MOUSE_DOWN, backbutton1);
function backbutton1(myEvent:MouseEvent):void {???????????? myLoader1.gotoAndStop(1);} (this line does not work)
(Once I load file1.swf, within the file1.swf I click a forward button to move to different frames. My question is: how do I code the 'backbutton' on the main timeline so that it causes the loaded file1.swf to go to frame 1?)
Thank you for your help.sure.
if the movieclip on the loaded swf's main timeline has reference mc, you would use:
MovieClip(myLoader.content).mc.gotoAndStop(1);
p.s. you might find the following helpful, http://kb2.adobe.com/community/publishing/918/cpsid_91887.html
Maybe you are looking for
-
Applets not working in WLS 6.1
I am migrating an application from WLS 5.1 SP 9 to WLS 6.1 SP 1. This application contains several applets and ran without error or problems under WLS 5.1. However I'm seeing strange behaviour/errors under WLS
-
CAn I run Lion and snow leopard on the same computer with different sign-ins?
CAn I run Lion and snow leopard on the same computer with different sign-ins?
-
Mass activation of transformations in BI via Report?
Hello, I am wondering whether it might be possible to activate multiple transformations with one simple report. In BI 7.0 there are a lot of ABAP-reports for many Objects, but I can't find one for transformations. For example: I use the report RSDS_D
-
Installing new actions where is photo creations/photo effects folder?
Hi, I've purchased a new Windows 7 32 bit OS, installed PSE7 and now trying to install my favorite "actions" but cannot locate the appropriate folder to drop them into! Show Hidden files and folders is activated. Also not showing is the Mediadatabas
-
Testing a SP that returns a CURSOR
I'm using Oracle 11 and trying to use SQL Developer. However, I cannot seem to get the DEBUG to work to test calling a SP that returns a Cursor. I wrote a small test program to test, but it won't compile and I'm not sure why not. Can you assist? the