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.
Similar Messages
-
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 -
I'm using aperture 3/mobile me to set up photo galleries which I send to friends. My question. Will icloud allow me to do the same or will I lose this function when mobile me closes down in July. If this function isn't part of icloud does anybody have any suggestions how I can do this in future through aperature. Thank you
You will have to find a new hosting service for your galleries, when MM is gone; but you will still be able to create the galleries with Aperture. Export them to your disk and upload them via FTP to your new hosting service.
See these support articles: Migrating from Mobile Me
http://www.wilmut.webspace.virginmedia.com/notes/migrate/frommobileme3.html
and this FAQ about Mobile Me and iCloud Transition http://support.apple.com/kb/HT4597 -
HTML5 Canvas: Calling a parent function
Hey guys
I'm currently banging my head against a brick wall trying to call a parent function with the HTML5 Canvas.
I have the following code on the stage:
function fromStage()
console.log("This is on the stage");
fromStage();
This correctly outputs that message to the console in the browser.
However, I have a button within a movie clip that I want to call this function from, my code in that movie clip is as follows:
this.theButton.addEventListener("click", fl_MouseClickHandler.bind(this));
this.theButton.name = "theButton";
function fl_MouseClickHandler(e)
this.parent.fromStage();
However, this doesn't appear to be working, any ideas?
Thanksuse:
on the stage:
this.fromStage=function()
console.log("This is on the stage");
this.fromStage();
code in that movie clip is as follows:
this.theButton.addEventListener("click", fl_MouseClickHandler.bind(this));
this.theButton.name = "theButton";
function fl_MouseClickHandler(e)
this.parent.fromStage(); -
Trigger function when loaded swf finishes
I'm making a site that loads external swfs based on which
button is clicked. When the swf loads it plays an intro and then
stops at a certain point. My goal is that when you click another
button the current swf plays an outro before the next one loads.
The problem I'm having is making the outgoing movie trigger the
function that loads the next.
At first I tried just adding loadNextMovie(); to the last
frame of the loaded swf. But for some reason this causes the two
stops in the file from working so the thing just keeps looping. I
have no idea why adding this function call would prevent stop();
from working.
Is there another way to have the end of movie trigger the
function? Also, why doesn't adding loadNextMovie(); to the last
frame of the loaded swf work?Ok, sure. I have main.swf that loads external.swf. Main.swf
has a function that loads a different movie. Like this:
function loadMovie():void {
trace("movie loaded")
This function is to be called from external.swf by putting
this in the last frame:
stop();
loadMovie();
But when I actually put loadMovie(); into external.swf the
stop no longer works and it just loops. What am I doing wrong? Is
trying to put this function call in the external swf the correct
approach? -
Calling a private function when inside another class?
Can't help it but im curious how classes seem to be able to
call private functions inside other classes. I'm mainly thinking
about the addEventListener() here. When adding a listening function
to a class, that function can be private, and yet it seems to be
called magically somehow. Or maybe its all internal? I dunno.
Anyone? :DHi Kenchu1,
You can grab a copy of the open source API here:
http://www.baynewmedia.com/download/BNMAPI10.zip
(feel free to drop by
the main site for documentation as well :) ). The main class
is the
Events class, "broadcast" method. This method broadcasts
events in a
decoupled fashion, meaning that listeners can listen to
messages that
aren't bound to a specific sender. The AS3 version works in
much the
same way except that I still haven't fully fleshed out the
cross-SWF
communication that this version can do (broadcast across all
movies on
the same computer using LocalConnection).
Basically, the broadcaster works like this:
1. Add event listener and bind to function A (called from
within the
class so the reference is available)
2. Event listener pushes this into the listener array. It was
provided
by the class so the reference is valid and is now a part of
the events
class as well.
3. Broadcast runs through all associated events when it comes
time to
broadcast and calls the function by using the array
reference:
this.listeners[message].call(classInstance,someParameter);
In other words, the class that adds the listener "allows"
the event
broadcaster to use the reference because it passes it out.
You can do
the same thing by calling:
someOtherclass.functionRef=this.privateFunction
someOtherClass is the class that will store the private
reference,
functionRef is some variable to hold the reference, and
privateFunction
is the private function. Then, in someOtherClass, you can
call:
this.fuctionRef(someParameter);
Hope this helps.
Patrick
Kenchu1 wrote:
> Patrick B,
> exactly! Something like that is what im looking for. I
have my own rather
> simple system right now with listeners and classes
calling these, but since i
> dont know how to call a private function, i had to make
all the listening
> classes functions public - something id rather avoid.
Exactly how did your
> event broadcasting system work? Oh, and we're talking
AS3 btw.
>
> How do i call a function via a reference? (to the
function? To what?)
>
http://www.baynewmedia.com
Faster, easier, better...ActionScript development taken to
new heights.
Download the BNMAPI today. You'll wonder how you ever did
without it!
Available for ActionScript 2.0/3.0. -
Using Parent Functions from Child
I have created an application utilizing numerous components.
Each component encompasses it's own functions. This has become an
issue as the application has grown and I need to refresh components
based on the click of a tab navigator.
Being very new to flex 2 I am wondering how I could put all
of the functions now in the components on my main.mxml and call
them from the children (components)? I believe that this would
allow me an easy way to refresh the different components utilizing
a large init() function in main.mxml.
Also, is it possible to call the init() functions of my
components from the main.mxml. This would also allow me to refresh
components. If it's possible I would like to see a simple example
of the process.
Thanks for the help. I appreciate it.
MarkThis code may help:
components/init/InitButton1.mxml---------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Button xmlns:mx="
http://www.adobe.com/2006/mxml"
label="ButtonOne" creationComplete="init()">
<mx:Script>
<![CDATA[
public function init():void {
setStyle("fontWeight", "bold");
setStyle("fontSize", "10");
setStyle("color", "0xFFFFFF");
]]>
</mx:Script>
</mx:Button>
components/init/InitButton2.mxml---------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Button xmlns:mx="
http://www.adobe.com/2006/mxml"
label="ButtonTwo" creationComplete="init()">
<mx:Script>
<![CDATA[
public function init():void {
setStyle("fontWeight", "bold");
setStyle("fontSize", "5");
setStyle("color", "0x000000");
]]>
</mx:Script>
</mx:Button>
----------------------------- Test.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:comp="components.init.*"
horizontalAlign="center" verticalAlign="middle">
<mx:Script>
<![CDATA[
import mx.controls.Button;
public function changeBtn1Styles(event:Event):void {
if(event.target.id != "btn1" && event.target.id !=
"btn2"){
btn1.setStyle("fontWeight", "normal");
btn1.setStyle("fontSize", "30");
public function changeBtn2Styles(event:Event):void {
if(event.target.id != "btn1" && event.target.id !=
"btn2"){
btn2.setStyle("fontWeight", "normal");
btn2.setStyle("fontSize", "40");
public function resetStyles(event:Event):void {
var currBtn:Button = Button(event.currentTarget);
if(currBtn.id == "btn1"){
btn1.init();
if(currBtn.id == "btn2"){
btn2.init();
]]>
</mx:Script>
<mx:TabNavigator>
<mx:VBox label="Button One" width="300" height="150"
backgroundColor="0x0000CC" horizontalAlign="center"
verticalAlign="middle" click="changeBtn1Styles(event)">
<comp:InitButton1 id="btn1"
click="resetStyles(event)"/>
</mx:VBox>
<mx:VBox label="Button Two" width="300" height="150"
backgroundColor="0xCC3333" horizontalAlign="center"
verticalAlign="middle" click="changeBtn2Styles(event)">
<comp:InitButton2 id="btn2"
click="resetStyles(event)"/>
</mx:VBox>
</mx:TabNavigator>
</mx:Application> -
Calls garbled or dropped when standing too close to wifi router
I'm having a problem with dropped calls that I could never figure out. Until I finally noticed the pattern. It seems that whenever I'm close to my Linksys router (even though I'll have full bars) my iPhone 3G calls will start to get a bit garbled. It sounds like the signal has bad reception. In a few cases all of the voices literally start to sound pretty close to a fax machine, you can still make out that there is a voice, just can't understand it. Once the "garbled" effect gets going it's a pretty sure thing that the call will be dropped, despite a full signal.
I finally noticed that this only happens when I'm at my computer desk, near my wireless router. If i'm anywhere else in the house, or for that matter, away from the house, I've never had a problem with a dropped call. The only other item that I suspect could have an interference effect is the Wacom tablet. I've noticed that certain wireless mice loose signal when they're too close to it. But I'd be surprised if that signal would be reaching out 2 to 3 feet.
Any thoughts?I think I'd try some settings in the router. Experiment with channels on the 2.4Ghz band. Try a low channel number. If you have 5Ghz capablity try it. Some routers also have a transmit power setting, if it's set higher than 100% then lower it. If you don't need range, consider lowering below 100%.
Just some ideas,
Regards,
Captfred -
How to call jquery function when i close modal dialog box ?
Hello,
I need to call one jquery function when I click on close button of modal dialog box.Can anyone please let me know how can I implement it ?
Thanks,
Dipti ChhatrapatiHi Dipti,
If my understanding is correct, you are using SP Modal Dialog and want to track the close event of this dialog. Then you may use
dialogReturnValueCallback parameter of Options variable. Follow is the code sample:
function ShowModal() {
ExecuteOrDelayUntilScriptLoaded(function () {
var options = {
url: 'page1.aspx',
tite: 'Add Title',
width: 800,
height: 450,
allowMaximize: true,
showClose: true,
dialogReturnValueCallback: scallback
SP.UI.ModalDialog.showModalDialog(options);
}, 'sp.js');
function scallback(dialogResult, returnValue) {
if (dialogResult == SP.UI.DialogResult.OK) {
// call your Jquery method here...
Thanks, Ram -
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 -
IFRAME in portlet question - possible to call parent function from iframe?
From the iframe I tried to call the parent function by doing this parent.myFunc(). I got a permission denied javascript message. Just curious if anyone has successfully done this. If so please share your thoughts and comments.
Hi,
You will get "Persmission denied" error due to cross site scripting. Either you need to change browser settings to allow cross site scripting or you need to make sure both the URLs fall under same parent domain like both URLs ending with "*.abc.com".
Thanks -
Tableview: Call Javascript-Function when row is selected
Hi everybody,
I have created a tableview with selectionmode lineedit.
Now, I'm looking for a way to call a Javascript function when a row is selected.
The value of the selected row shall be passed to this function.
How can I sove this.
Best regards
AlbertoHI Alberto,
referr to JavaScript to check if any row is selected or not..!...
Even I am waiting for an answer...Now atleast I have a partner in th wait..!!
Thanks,
Tatvagna... -
Where to call the javascript function
Hi,
I am using JSF and ADF.
I have a javascript function called by the body onload.
The javascript is to set the first the first column of a table fixed.
But when I click the next page link which is generated by defaut,
the function from the javascript disappears.
Can I call a javascript function when pressing the next page link which is
generated by default ?
Thanks.
IvanHi Frank,
My javascript function is to make the first column of the table fixed which
is something like the function in the Excel.
The function is called by body onload.
But when the 'next page' link is clicked, it will not refresh the whole page.
The above cannot be called.
So I wanna add it during the action of pressing the link.
any alternatives ?
Ivan -
How can I remove a child swf and stop all sounds when parent closes?
Hi All,
I am new to actionscript 3 and trying to learn as I go. The problem I am having is the following:
I have a carousel of images that load an external swf movie with a FLVPlayback component on it. The problem is that when the external swf unloads the sound of the FLVPlayback component continues to play. I am using a carousel component I found online to load the images and each image loads an external swf file. here is the code for it.
import com.carousel.DegreeCarousel;
import com.carousel.data.CarouselDO;
import com.carousel.data.AngleDO;
import com.carousel.data.ItemDO;
// DEFINING THE CAROUSEL OBJECT
var carouselSettings:CarouselDO = new CarouselDO();
carouselSettings.radiusX = 300;
carouselSettings.radiusY = 0;
carouselSettings.fov = 50;
carouselSettings.transitionTime = 1;
carouselSettings.ease = "easeInOutQuint";
carouselSettings.useToolTip = 0;
carouselSettings.useBlur = 1;
carouselSettings.maxBlur = 8;
carouselSettings.reflectionAlpha = 0.2;
// DEFINING ANGLES SETTINGS
var angleSettings_arr:Array = new Array();
angleSettings_arr[0] = new AngleDO({angle:0,alpha:1,scale:0.5});
angleSettings_arr[1] = new AngleDO({angle:90,alpha:1,scale:1});
angleSettings_arr[2] = new AngleDO({angle:180,alpha:1,scale:0.5});
// DEFINING THE ITEMS
var prefix = "content/thumbs/"
var galleryItems:Array = new Array();
galleryItems[0] = new ItemDO({thumb:prefix + "image_1.jpg", content:prefix + "swf1.swf", contentType: "flash"});
galleryItems[1] = new ItemDO({thumb:prefix + "image_2.jpg", content:prefix + "swf1.swf", contentType: "flash"});
galleryItems[2] = new ItemDO({thumb:prefix + "image_3.jpg", content:prefix + "swf1.swf", contentType: "flash"});
// PLACING THE CAROUSEL TO STAGE
var carousel:DegreeCarousel = new DegreeCarousel(carouselSettings,angleSettings_arr,galleryItems);
carousel.x = stage.stageWidth * .5;
carousel.y = stage.stageHeight * .5;
this.addChild(carousel);
// KEYBOARD NAVIGATION
// KEYBOARD EVENTS
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
function keyDownHandler(e:KeyboardEvent):void
// left
if(e.keyCode == 37)
carousel.left(1);
// right
if(e.keyCode == 39)
carousel.right(1);
// top
if(e.keyCode == 38)
carousel.prevCycle();
// Down
if(e.keyCode == 40)
carousel.nextCycle();
// Space
if(e.keyCode == 32)
The external movie loads fine. Then the external swf calls for a second swf containing a video. This is the code that is used to load the swf:
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.display.MovieClip;
import flash.events.MouseEvent;
var myVideo:URLRequest = new URLRequest("myvideo.swf");
var video:Loader = new Loader();
video.load(myVideo);
this.addChild(video);
When the carousel unloads, it unloads both movies but the sound keeps on playing.
Is there any way to stop the sound from keep playing?
Thank you very much!!
-MYou want to stop the audio from playing and also downloading more video/audio if it is still downloading when you go to a new keyframe where the video display/component or mp3 player is removed from the stage because it's keyframe ended or do not exist anymore but you still hear the audio.
Add an event listener to your video playback component that calls a function when the flash player tries to remove the video plaer from the stage that stops the netstream or at least stops/pauses the video playback.
[link removed]
//sample NetConnection and NetStream classes when the video player is removed from the stage tell the NetStream to stop playing or downloading the content with .close();
var connection:NetConnection = new NetConnection();
connection.connect(null);
var stream:NetStream = new NetStream(connection);
addEventListener(Event.REMOVED_FROM_STAGE, videoRemovedFromStage);
function videoRemovedFromStage(e:Event){
stream.close(); -
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.
Maybe you are looking for
-
Hi all, I am searching for a FM which will say 3rd work day of a factory calendar or 4th work day of a factory calendar etc. I could see there are few FMs to say first work day - last work day but not the Nth work day. If we input some date and facto
-
Security restrictions on offline form
In my application, I have a form with a submit button of control type 'regular'. It can be downloaded on local hard disk filled and saved. But for the same form, I changed the control type of submit button to 'submit' and ran the application again. N
-
I have recently updated to iOS 7.1 - which seems to be the start of the problem. The bar at the bottom of the summary page in itunes when your device is plugged in is only orange symbolizing "other". It does not show audio, pictures, movies etc.
-
WMIC Diskdrive Get Signature - question
Hi I'm running Win 7x64 Home Premium. I have a question about the WMIC return information when using diskdrive get signature query. Drive 0 is my "C" HDD (MBR OS drive and most of my data), a Seagate 1Tb SATA spinner drive. Drive 1 is a 500Gb MBR Se
-
HT202879 keep a .doc a .doc
is it possible to maintain a MS word file when opening it in Pages as .doc instead of automatically converting it to .pages?