ActionScript 3.0 :: Passing Information From A Child To A Parent?
Oct 29, 2010I need to pass information from a child component (Flashbuilder 4) up to its parent.
The information comes from an event object. Do I need to use a custom event?
I need to pass information from a child component (Flashbuilder 4) up to its parent.
The information comes from an event object. Do I need to use a custom event?
I'm trying to access some variables from my parent in my child MC.
Parent code:
var data_history:String;
function finish_checkUp(event:Event):void{
var checkUp_stat:String;
[Code]....
Now as you can see, i have tried the trace method, but with no luck. Flash doesn't report any errors regarding the trace method, but does report the two undefined vars (data_history). Ive tried to use the trace method above all the functions, at the top of the script, still the same errors though.
I have a simple BOOK script where I have 10 pages (for example purposes). Each page has a vocabulary word on it. Currently, I simply created a vocabulary MC separately for each page and it works fine. Problem is, that leaves me with 10 Vocabulary pages and I would rather have 1 that loads info based on a var on the main page.
WORKING SCRIPT
var loaderZ:URLLoader = new URLLoader();
loaderZ.dataFormat = URLLoaderDataFormat.VARIABLES;
loaderZ.addEventListener(Event.COMPLETE, loading);
[Code].....
I am getting the word "depressed" from page 1 (verified by trace) Unfortuntely this does not work.
If I change the last line of code to:
VocText.htmlText = loaderZ.data = word;
Then it outputs the word DEPRESSED to the text field VocText but does not return the value from the txt file.
I have a Parent.swf which loads a child.swf.this is a desktop application and the problem is
while loading the child.swf i have to pass a variable from parent.swf to child swf. how can i do it.can anyone give me an implemented code.
I have two swf, A.swf and B.swf: B.swf is a child of A.swf.i want to access the variable of a.swf in b.swf.Is it Possible?How Can i do this?
[Code]....
how can I pass a variable from a parent flash file to a child flash file which it calls?We have a parent flash file which imports various child flash files based on instructions in an XML file. It's probably easier to see an example - opg2DOTcoDOTuk/flash/yay.html (replace the DOTs, couldn't post an url due to restrictions) - the text above each page, and the 'enlarge page' lightbox links are all in seperate flash files (one per double page) which are brought in, depending on the pages you are looking at, based on the instructions in an XML file which looks like this...
<page ani_swf="pages/text1.swf">pages/white.jpg</page>
<page ani_swf="pages/text1.swf">pages/0001.jpg</page>
<page ani_swf="pages/text2.swf">pages/0002.jpg</page>
<page ani_swf="pages/text2.swf">pages/0003.jpg</page>
etc, where the swf is the header flash file containing the text and one or two lightbox links, and the jpg files are the page images that appear.We had to repeat the imported child flash file because of a glitch when you go backwards through the book otherwise.
This system has been fine for us up until now but recently we've had to look at making it a dynamic system, so the content of the book can be varied depending on a variable being passed into the parent file via FlashVars...
<param name="FlashVars" value="zone=1" />
<embed src="newbook3.swf" FlashVars="zone=1" ....etc
This makes the book load an xml file called "1"). This is fine, except we also need to vary the 'enlarge page' target images to match.The 'enlarge page' links are currently hard coded into each child flash file, like this...
on (release){
getURL("javascript:SWFDelegate('imagename.jpg','Ex ample');");
}
- What we've tried so far:
1. Trying to pass the variables in querystrings from the XML
eg.
<page ani_swf="pages/text2.swf?var1=image1&var2=image2">pages/0002.jpg</page>
<page ani_swf="pages/text2.swf?var1=image1&var2=image2">pages/0003.jpg</page>
with the child flash setting it's action like this...
on (release){
var image1 = var1 + ".jpg"
getURL("javascript:SWFDelegate(image1,'Example');" );
}
I'm not sure if the syntax here is correct. We have to add the ".jpg" in here because, as far as I understand it, you can't pass "." in a querystring.
2. Passing the variables for the child into the parent
I read somewhere that variables passed to a parent are automatically available to a child. Not sure if this is true, but it didn't work for me when I tried it like...
<param name="FlashVars" value="zone=1?var1=image1&var2=image2" />
<embed src="newbook3.swf" FlashVars="zone=1?var1=image1&var2=image2" ....etc
Combined with...
on (release){
var image1 = var1 + ".jpg"
getURL("javascript:SWFDelegate(image1,'Example');" );
}
...in the child button action.
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 Repliesi 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 RepliesI 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]
View 2 RepliesI 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 Repliesif 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
[Code]...
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]....
Is there any way to pass vairable or array information from flash either .swf or .exe to VB.net ?
If so can data be passed back to Flash from VB.net ?
I want to create a simple graphical application in Flash that when the user has chosen it passes the info to a VB.net application.
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].....
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]...
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?
giving a checkbox in a form a varibale.I'm passing the form to a CDONTS ASP page, and I have three checkboxes, which I need to appear in the retuened email as either blank or 'checked'.(I have read the tuts here btw - but cannot get them to return a value)My chk box is called 'chk1'.So my AS on my submit button looks like this:
on (release) {
chk1 = chk1.getSelectedItem().label;
getURL("http://www.holmes.7host.com/promise/mypage.asp", "", "POST");[code].....
I want to pass information to a Movie Clip (swf) loaded into a UILoader component on the stage. I need to be able to do this so I can synchronize the actions of multiple Movie Clips in the main movie clip. What's the proper way of accomplishing this?
An example of how I'd use it is when I'd load a video to the stage and I'd want to tell my audio player to mute the volume on the background audio.
I need to pass along a string with my FileReference, or provide that string as an argument when an event fires. To be clear, it really annoys me that AS3 doesn't allow you to pass parameters on events.Right now, I've extended the FileReference class to include an additional variable. I'm trying to get this to compile, but it won't compile; I think I don't know how to import this class correctly. If you can tell me how to import this class correctly so that I no longer get Error: Type was not found or was not a compile-time constant at compile time that would be great.
This is the extended FileReference class:
import flash.net.FileReference;
public class SxmFR extends FileReference {
[code]........
I have a main movie (main.swf). I load child1.swf and child2.swf into it with URLLoader. Is there any way to make a button to child1.swf which would take a user to some frame in timeline of child2.swf?
Something like
parent.child2.goToFrame(5);
I have tried different combinations without luck...
I am a bit of a noob, and I'm having a problem. I had posted about this before but I think I was explaining what I need to do in way to much of a complicated manner so I'm going to try and simplify this a bit. I have 5 swf's.
- main.swf (parent)
- child01.swf
- child02.swf
[code]......
Parent SWF to a Child SWF
View 6 RepliesI 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 RepliesIn an AdvancedDataGrid using an MXAdvancedDataGridItemRenderer, mouseover was not being passed on to the AdvancedDataGrid. After days of struggle, I wanted to share this: In your data setter, assign super.data with the new value for mouse events to be bubbled (?!)
[Code]....
[code]...
and I dont mean this: (which removes the parent)
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 RepliesSome 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