ActionScript 3.0 :: Talk To A Parent From A Child SWF?
Oct 20, 2009
I have an swf that is loaded in when a button is CLICKed, anyway inside the SWF file I want to access a function from the parent, how do I do this?
also can I access instance names from the parent file?
View 1 Replies
Similar Posts:
Jul 29, 2011
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.
View 10 Replies
Jun 6, 2011
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).
View 5 Replies
Jul 29, 2011
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.
View 1 Replies
Feb 5, 2010
[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]
View 2 Replies
Jan 3, 2010
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()
View 1 Replies
Aug 5, 2010
Need to make a character start to talk when the sound starts and stop talk when the sound stops so I'm using this:
[Code]...
View 2 Replies
Sep 11, 2010
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.
View 29 Replies
Nov 11, 2009
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.
View 2 Replies
Sep 29, 2011
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
[Code]...
View 3 Replies
Nov 7, 2011
i want to pass the variable from parent to child .How Can i pass the Variable.Here i paste my code.
My Parent Class
public class PlayerStrobe_domaincheck extends Sprite
{
private var myService:NetConnection = new NetConnection();
private var _loader:Loader;
[Code]....
View 3 Replies
Nov 10, 2010
I'm updating a course from a previous developer who is no longer here, and, of course, the code is not commented and difficult to follow, but, there's a "shell" that loads an "interface" file which has the navigation controls which load other movie files using addChild. The calls look like (slide is the variable with the swf name): Actionscript Code: iFace.screen.back.addChild(slide);
One of the loaded files is a "home" file, which has several interactive areas within it. The problem is that, if the user goes into the home file, selects an area, then hits the "menu" button on the interface, selects the home file again, it shows up with the area that the user selected previously still displayed. If they select another section and then go back to home, the file gets reset. how I can "reset" the loaded file? I tried putting the following on the menu button after the function call:
Actionscript Code:
iFace.screen.back.gotoAndPlay(1);
View 1 Replies
Aug 21, 2010
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.
[Code].....
View 3 Replies
Aug 24, 2010
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.
[Code]...
View 1 Replies
Oct 6, 2010
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?
View 2 Replies
Feb 4, 2011
Parent SWF to a Child SWF
View 6 Replies
Aug 16, 2011
I have 9 child mc's as buttons in the parent. How could the child discover what name the parent has given it? Can the child examine a parent variable?
View 2 Replies
Jul 29, 2009
[code]...
and I dont mean this: (which removes the parent)
View 9 Replies
Nov 11, 2009
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?
View 1 Replies
Sep 3, 2011
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?
View 3 Replies
Nov 8, 2009
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;
[Code]....
View 1 Replies
Apr 14, 2010
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?...
View 3 Replies
Aug 15, 2011
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.
View 1 Replies
Feb 29, 2012
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?
View 1 Replies
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.
View 9 Replies
Jul 9, 2009
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]...
View 1 Replies
Jul 15, 2009
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 ....
View 6 Replies
Jun 30, 2010
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.
View 3 Replies
Jun 24, 2011
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..
View 0 Replies
Mar 9, 2012
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
View 2 Replies