ActionScript 3.0 :: Child Swf Talking To Parent SWF?
Aug 1, 2008
I have a SWF file that I call the a parent, it imports a number of SWF(children) which I can switch through. is it possible to have a function in the parent SWF that the child SWF can launch?
The reason I need this is because each child SWF is a sort of small game, so when each game is finished I need some kind of way to let the parent SWF know that the player can continue.
I got a Parent Sprite, let's name it SpriteP, which holds inside it two other Sprites. Sprite1 and Sprite2.[code]Sprite2 is a rectangle. When I rotate it, of course, the height of its parent, SpriteP, GROWS. But I would expect that height to go back to what it should be when I'm removing Sprite2!And it does! If I remove Sprite2 while NOT being rotated, the height of the parent drops back to normal, 200.
i am slightly confused about the parent and child relationship. lets assume we have several different instances, what would be difference of adding them all as children of the stage and creating a parent-child hierarchy between them(other than the access path).
I got a Parent Sprite, let's name it SpriteP, which holds inside it two other Sprites. Sprite1 and Sprite2.
When Sprite2 is NOT rotated:
Code: trace(SpriteP.width + ' ' + SpriteP.height); //100 250. SpriteP.removeChild(Sprite2) trace(SpriteP.width + ' ' + SpriteP.height); //100 200. -> works, 200 is good. When Sprite2 is rotated at 90:
[Code].....
And it does! If I remove Sprite2 while NOT being rotated, the height of the parent drops back to normal, 200. But if I rotate Sprite2, the Parent won't update its bounds.
[code]All clips are squared.Ok, on the PlayerPlane, there are little soldiers, which have hotkeys. The effect I'm trying to create is I want to position the GameStage so that the currently selected soldier appears in the center of the GameClicker clip.The GameStage is movable by the player (to scan other areas of the map)by holding the CTRL key, so it's easy to kinda lose track of where your players are.I have tried using localTo Global and globalToLocal techniques, but I think I'm lost on the actual math of getting the GameStage to move the correct distance so that the selected soldier is centered to the GameClicker.[code]
I got a "preloader" that creates an movieclip and loads an SWF. Now in the loaded SWF i want a close button to go back to the "preloader". The preloader isn't an actuall preloader but some sort of mainclip.Now i tried this:removeChild(MovieClip(e.currentTarget).parent.pare nt.parent)But i get error:ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.at flash.display::DisplayObjectContainer/removeChild()at MethodInfo-6()
if I add a clip to the stage as a child and remove the parent and set the parent equal to null, does the child get collected and removed from memory? What if the child has an image loaded into it as its child?
In my application I'm loading a series of png images as overlays that can be tinted for customizing in this app. When I trace my memory, the basic app idles at 64,000 k. The exact second I load those overlay images it goes up to 205,000k. If I remove those clips and "clear" the stage I should go back down to 64,000 k if everything is removed and collected correctly, right? It's not, it's hanging at 215,000 k. Are my images being cached and that is the reason for the memory staying up? If so, how do I prevent that. Or upon removing the parent of the image how can I un-cache the image.
If a user switches between models and loads several different items then the application actually crashes the Flash environment because of too much memory usage. It also does the same to browsers.
I have a parent swf which loads many child swfs (though only one is displayed at a time). My intention was to use the loaded SWFs document class to retrieve an array of objects to be assigned a tab index, combine this with the parent's own array of objects and apply sequential tab indices to them all. But what happens is actually that the parent's objects are assigned an index, but the external swf is unaffected. In fact, the external swf retains its automatic tab indexing, when I would expect that having set a value for InteractiveObject.tabIndex, automatic tab indexing would be disabled.
I've seen similar tales elsewhere. Most posts I've read are wanting to load an external swf, give it focus and loop through those objects, then close the swf and return to looping through the parent. However I would like loop through all objects as one. including manipulating the focus manager(s), and basically fiddling with every tab-related property I know.
trying to on mouse over set the parent of the moused over text field to the highest depth child of its parent i tried both of these: [code] private function
I have an issue where removechild won't infact remove a child. I think its something to do with my dropTarget.parent issues. The concept of the code is that you drag a source onto a destination. When you drop the source onto the destination you will get a text field that says "Hello" or "Goodbye". The objective i want to achive is that once i drop a source onto the destination, removechild will remove any previouse textfields added. This is proving difficult.
I am trying to make a calculator where a user can select from a list of items. If a user clicks say "ITEM1", it should add the item to a "CONTAINER_MC". The problem i have is all my data is set inside an array containing names and prices like the code below.
Here is a working script to drag drop a ball from the stage into another target mc:
ball.addEventListener(MouseEvent.MOUSE_DOWN, pickUp); stage.addEventListener(MouseEvent.MOUSE_UP, dropIt); function pickUp(event:MouseEvent):void{ [code]...
It works well but I'm new to AS3 and I am having difficulty amending this script to drag the ball out of a parent mc (instead of the stage) and onto another mc (the target mc). To explain: imagine a ball, a box, a tri, + more shapes all within a scrolling mc (initial parent), the user scrolls to select a shape, then drag-drops onto a target mc on the stage.The scrolling is no problem, but how would you amend the script above so that the ball can start inside a parent mc rather than on the stage itself?
i have added an movieclip as a background and added another movieclip to it. Now i want it to be placed a bit outside the bg. movieClip.x = -50; movieClip.y= -40; But if i do this, then it just gets cutoff, is there a way to make overflow visible?
Some forums suggested to simple add the child to the new parent and it would automatically be removed from the old parent. However, these were Actionscript 2.0 forums and the suggestion didn't work - it removed the child but never added it back.MovieClip(root).bmc.addChildAt(currentLetter, 0);Is it possible to take a child from one parent and add it to another in AS3?
I have a MovieClip instance which can be moved around the stage using startDrag() and stopDrag(). The instance also has some child MovieClips using addChild(). The parent moves the children when dragging, which is fine. The children have there own startDrag() and stopDrag() which should apply only to the child object, however it also moves the parent and other children. When clicking a child the MouseEvent of the child is being called but so is the parent.
public class Component extends MovieClip { private var nodes_array:Array = new Array(); public function Component() { x = 60;
Im using the following code to place an object inside a container:
testParent = new MovieClip(); testParent.graphics..beginFill(0x0000FF); testParent.graphics.drawRect(50, 50, 300, 300);
[Code].....
this gives the testParent object a margin of 50 from top and left. The testChild object should have have the same margin relative to stage. But doesnt.. The child object is at 0,0 relative to stage. Whats causing this?...
how do I get a value from another mxml.I have a vaule in the child mxml that i would like to parse to the parent mxml.Then use the vaule to create a search method.
How do I do this? Inside the parent swf myVar value is set by query string value loaded in by swfobject var myVar = _level0.part; // i have the value 123 here ..all good so far
[Code]...
Always childLog.text is undefined :( - so how to access the value of myvar from the child?
I have a Flash file below and I am wondering what is the best way to do clicking on multiple objects. I know it has something to do with a parent and it's children, but I'm still unsure. [code]...
In Move1.swf I am loading Movie2.swf like below: ActionScript Code: var myvalue:Number = 0; var UploadLoad:Loader = new Loader(); UploadLoad.load(new URLRequest("Movie2.swf")); UploadLoad.contentLoaderInfo.addEventListener(Event.COMPLETE, endNavListener); function endNavListener(e:Event):void { var UploadForm=MovieClip(UploadLoad.content); stage.addChild(UploadForm); UploadForm.x=0; UploadForm.y=0;}
But I am having one variable in Movie1.swf which is called myvalue, I want to assign some value for myvalue from Movie2.swf. So I have coded like ActionScript Code: MovieClip(parent).myvalue = 100; But the value is not passing ....
I have a blank fla with a symbol in its library. The symbol, a MovieClip, has timeline action in it. It's about 15 frames long. I want it to tell the MainTimeLine when it's done.I must be going about it the wrong way.First, I make a variable to hold the child.I call the MovieClip from the library, a new instance of itself, declare it a child of the MainTimeLine, and add it.From within the child, I trace it's parent. I get "MainTimeLine".I create a Boolean on the mainTimeLine.When I ask it to set the Boolean, I get the error message:1119: Access of possibly undefined property currentFrame through a reference with static type flash.display DisplayObjectContainer.I've attached a zip of the fla.
I have a parent that loads a child that contains a ScrollPane. The ScrollPane then loads another child (timeline) that has buttons. I would like to be able to click the button within the timeline and have it load the SWF in the ScrollPane child. Making it easier to visualize..
Each of these children has an index value assign to it for the purpose of relating to an XML file, but that's beside the point. Those children have other children eventListeners that call a tween function. That tween function wants to tween the first child.First question: what is the proper syntax for referencing the parent and getting that index value? Does this work, with currentTarget being the child that called the function:var something = e.currentTarget.parent.index;If not, how can I get that index value?Second question: In order to determine which of the first children the tween is applied to, I could write a conditional that checks the index value and tweens based on that. Is there an easier way to do this? And what conditional would work best? I'm thinking if() else() but I'm relatively new to as3 so if there's something more efficient I'd love to hear it
I'm creating a tree menu, and when you click a parent, it populates a MC inside that parent - children that you can also click on. The parent is a chapter and the child is a screen.clicking on the parent closes the children. clicking on the children should load a screen. But instead, when I click on a child, it acts as if I'm clicking on the parent.[code]
I have a function (let's call it testFunction for right now ) on the actions layer in the main timeline There is a movie clip with 15 frames long in the library
i want to add a child of the movie clip on the stage, and call testFunction when it finishes playing
how can i do? i tried to call it in the child but nothing works
Or, is there any way to show child on the stage for only a period of time like 1 second and then remove it automaticly?