Parent SWF to a Child SWF
d
You can probably skip the function call and just assign directly to the child after it has loaded. Try changing...
child_loader.content.callFunction("Child has loaded");
to
MovieClip(child_loader.content).txt.text = "Child has loaded";
txt is merely an example here, so whatever variable(s) you intend to assign should be substituted.
Similar Messages
-
Send varible vaue one swf to another(child) swf??
Hi I have made my project in diffrent flash files but now i m stuck to get data from child.swf to index.swf.
In your index file declare variables like
var datafromchild:String="";
and from your child swf write as:
MovieClip(root).datafromchild="your name";
MovieClip(root) depends upon the level sometimes it would be MovieClip(parent.parent).datafromchild="your name" based on the nested movieclips.
This is a simplest method, but if level increases it will be worst to store and retrieve. also have others feedback also may be you will get some simple methods too.
Note: there is no global variable in AS3 like AS2 -
Problem: Unable to call a function in parent swf from the child swf.
I am working on a site right now that has a parent loader
(all it contains are the menu bar [which is as3 tweened] and the
functions for calling all of the other pages.) The problem that I
am having right now, are some of the internal or child pages, need
to call functions that are in the parent loader. For what ever
reason, I am unable to do any of that.
I have attached the code so you can look at that.
Let me see if I can explain it any better.
The code I just posted is for the Main Stage swf called
loader.swf. It has the menu, and all the functions that control the
menu's movement and when to load all the other swfs. The easiest
way for me to ask this, is to show you.
click
http://dev.locallinux.com/mystictan/layout2.html
When you get there, you will see the menu bar, and it is
loading home.swf onto the stage behind the menu.
Mouse over "The Perfect Tan" and click on "1: Base"
You will notice it just loaded a new swf called ptbase.swf.
Well in that swf is a button for "Products" That button
basically needs to take you to "Products > 1: Base" on the menu
(not working yet, I know. But theres no point in me making that,
until I could get this working"
What I would like is when you click on "Products" in
ptbase.swf, it calls the function clickedProductsBase(), which does
its thing. But that function is back in the loader.swf. Does that
make sence?
What am I missing here?RyanORo, thank you very much for your response.
I try that, and I get this sort of error when I click on it:
TypeError: Error #1006: fwd is not a function.
at ptbase_fla::MainTimeline/testing()
I know all that code that I posted was a bith much, but here
is the movie loading part:
function loadComplete(event:Event):void
loaderbar.visible = false;
mainbody.removeChild(thisMC);
thisMC = MovieClip(myloader.content);
myloader.unload();
mainbody.addChild(thisMC);
thisMC.gotoAndStop(1);
TransitionManager.start(thisMC, {type:Fade,
direction:Transition.IN, duration:5, easing:Strong.easeOut});
mainbody is an empty mc under the menu, so that the loaded
swf file appears under the menu.
You know what, scratch all that . *MOOWHA* I could KISS you
right now. "(parent as MovieClip).clickedProductsBase()" did not
work because it was calling it out of the wrong parent. Just did
"(this.parent.parent as MovieClip).clickedProductsBase()" and that
did the magic I needed. Thanks... -
Is there anyway to load a flex (or any swf with AIR capabilties) into a parent swf?
I just found out you can load the flex SWF directly into the swfLoader... I feel very stupid now. Should have tried that a longggg time ago.
-
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 -
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,
JamieHi 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 -
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. -
Running a function in a parent at the end of a child.swf
question: How do I call a function that is inside a
parent.swf from a child external swf (class Loader)?
In my menu.swf, there is a child (Loader class) of a
content.swf that gets loaded below it on run. Then when a button is
clicked, it makes a string that contains the name of the content
file to load next, then initiates an ending function on the child,
which does some outro animation.
function buttonClick(event:MouseEvent):void
nextContent = event.target.name + ".swf";
MovieClip(newContent.contentLoaderInfo.content).endSequence();
after the ending sequence has executed in the ccontent.swf I
need to know how to make a call to a function back in the menu.swf
so that I can load the nextContentquote:
Originally posted by:
abeall
Where is the function, on the timeline? You could try:
MovieClip(parent).functionName()
Thank you for the help.
It compiles but I get a runtime error: TypeError: Error
#1034: Type Coercion failed: cannot convert
flash.display::Loader@248b5791 to flash.display.MovieClip. -
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 -
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); -
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")); -
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/ -
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")); -
Rendering of SWF Loader child SWFs
I am using the swf loader with an Xcelsius OpenDoc link (http://<server>:8080/Xcelsius/opendoc/documentDownload?sIDType=CUID&iDocID=<CUID>&sKind=Flash&CELogonToken=<CELogonToken>) and it works beautifully so long as the parent swf is also opened using and OpenDoc link. However, if the parent swf is opened via InfoView, the child swf does not render properly (either way too large or too small). Has anyone else come across this or have any ideas for resolution?
Regards,
Alison"whomba" <[email protected]> wrote in
message
news:glq6j0$b20$[email protected]..
> Hello all,
> I have a Flex app that loads in a swf using 'SWFLoader'
tag. the SWFloader
> and
> the swf being loaded in are the same height and width
(see attached code)
> Now,
> the SWF getting loaded in is also 468 X 351 however the
designers that
> made it
> have crazy amount of random Movie Clips EVERYWHERE that
isn't on the
> stage. My
> guess is that the actual height and width of the SWF is
close to 1000 X
> 1000.
> When I load this SWF in to my SWFLoader it scales
everything down so all
> of the
> MovieClips are inside of this SWFLoader rather than just
the SWF's Stage.
> Any
> Suggestions?
>
> <mx:SWFLoader id="mainMovieSWF" height="351"
width="468"
> source="{mainMovieSrc}" scaleContent="false"/>
Try wrapping it as a component with the Flex component kit.
That way you
get to specify the bounding box.
HTH;
Amy
Maybe you are looking for
-
HT4623 I did the update to my iPhone 4 and I loose my voice memos how can I recover them?
I did the update to my iPhone 4 and I loose my voice memos how can I recover them?
-
Usage dependency is created at Build time and installation time
Hi, The infrastructure guys have selected the usage dependency as Build time and Installation time, while creating software components. "Y" SWC is created as depedency for "X" software component. In SLD(software catalog), we are able to view the Y c
-
Under settings I choose "edit names and passwords". I create a new name and password and click OK. The dialog window dismisses, but the name and password is not created. Anybody else having the same problem?
-
Xfinity connect 5.2 won't update on my android 4.4 tablet.
Any idea why xfinity connect won't update on my Android 4.4 tablet? It is Insight flex 8. Non rooted standard update tablet.
-
how to delete oracle database from OEM? regards wire