Flash :: Passing Data From Parent To Child In ActionScript3?

Nov 10, 2011

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]....

View 3 Replies


Similar Posts:


AS3 :: Flash - Passing Variables From Parent To Child?

Oct 14, 2011

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.

View 2 Replies

ActionScript 2.0 :: Passing Variables From Parent Flash Into Child?

Jul 26, 2010

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.

View 2 Replies

ActionScript 3.0 :: Passing Information From A Child To A Parent?

Oct 29, 2010

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?

View 0 Replies

ActionScript 3.0 :: Passing Txt Variable Through Parent To Child?

Apr 7, 2011

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.

View 2 Replies

ActionScript 3.0 :: Passing Variables From Parent To Child SWF

Apr 17, 2009

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.

View 9 Replies

ActionScript 3.0 :: Parent.removeChild(child) Doesn't Update Parent Width / Height When Child Was Rotated

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

ActionScript 3.0 :: Child-parent Relationship \ Adding Them All As Children Of The Stage And Creating A Parent-child Hierarchy Between Them?

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

ActionScript 3.0 :: Parent.removeChild(child) Doesn't Update Parent Width/height When Child Was Rotated

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

Actionscript 3 :: Pass Data From Parent Swf To Child Swf?

Jul 22, 2011

I have two swf, A.swf and B.swf: B.swf is a child of A.swf. Each swf has its DocumentClass. Now: I must pass 4 arrays from A.swf to the DocumentClass of B.swf. Which could be the best way? Is a listener in B.swf a good idea? I noticed there's the possibility to send data over the querystring but I would like to avoid this solution, if possible.

View 2 Replies

Flex :: Passing Data From Modules To Parent Application To Switch Views In The Viewstack

Jan 11, 2010

I have application with a viewstack witch load 5 modules. each module is loaded via the moduleLoader tag and they all have an id.

Every loaded module has a context menu. the context menu has 5 menuItems. one menuItem for each view for the viewstack.

The context menu is loaded via xml.

this is my application file.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
backgroundColor="#b1b1b1"

[Code].....

the xml of the context menu is in the module but, the context menu is in a as file that extensiate a button.

View 1 Replies

Actionscript3 :: Loading A Swf Named In Xml Into A Parent Swf?

Aug 23, 2010

I have a situation where I use loadvars to load an xml file, which has the address of 2 swf's on the server. I can trace the xml items so know they are loading. So I'm trying to load the swf's but am running into problems. First problem, the swf always gives an error when I publish from flash, "TypeError: Error #2007: Parameter url must be non-null." as it can't find the mention of the xml file, as it's just being published. I'm not sure this affects the next issue which is the swf not loading when I try to load it like this:

var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest(loadswf1); // where I know loadswf1 = "myswf.swf"
loader.load(defaultSWF);

[code]......

View 1 Replies

ActionScript 3.0 :: Positioning Parent MC In Order To Center Child MC On Parent's Parent MC

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

Actionscript 3 :: Flash - Child Within Parent Within Parent?

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

Flash - Drag Child Mc Out Of Parent Mc And Add To New Parent Mc?

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

ActionScript 3.0 :: Remove Parent.parent.parent Child?

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

ActionScript 3.0 :: Add A Clip To The Stage As A Child And Remove The Parent And Set The Parent Equal To Null?

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

ActionScript 3.0 :: Tab Indexing Loop Through Parent, External Child Swf, Back To Parent?

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

ActionScript 3.0 :: SetChildIndex And SwapChildren - On Mouse Over Set The Parent Of The Moused Over Text Field To The Highest Depth Child Of Its Parent

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

Actionscript 3 :: Assign A Parent's Variable From The Parent's Child?

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

ActionScript 3.0 :: DropTarget Parent Child - Removechild Won't Remove A Child

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

Actionscript3 :: Xml - Appending Data To External Text File By PHP And

Sep 30, 2010

import fl.controls.*;

var MyText:TextArea = info_txt;
var score:XML = new XML(<score/>);
score.PlayerName = "Maged";
trace(score);

Here I create a new XML date , I want to write these data to an external text file to use it by PHP but I don't have much information about it .

Note i want to append to the text field n't write .

View 1 Replies

Flash :: AS2 Parent - Child Swf Communication

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

ActionScript 3.0 :: Flash - Should A Child Know Its Parent

Oct 30, 2010

I am working on a component framework for myself right now, and was wondering if a child component should contain a reference to its parent. Obviously flash itself does this as part of the movieclip parent/child structure, so I figure it's okay to do this, but does this present any memory problems or anything, having references to the parent in the child? Would it be better to do some sort of lookup tree, just passing each child an array of GUIDs or similar which I could use to trace a component back to all its parents?

View 14 Replies

Flash :: Data Integration - Xml.load() Failing - Passing All Of The Data Via A Query String Appended To The Movie's Url

Sep 5, 2006

We have implemented a Flash photo slideshow on our site and it works just fine for most of our users. Whenever the xml.load(success) returns false I have the Flash email me a debug report. For the life of me I can not find a common thread between all of these people having problems with the Flash. I don't think it's a cross-domain issue because it works for most people, and I have the crossdomain.xml files where they should be.

[Code]...

View 1 Replies

Flash :: Share Classes Between Parent And Child SWF?

Aug 13, 2011

So i have a situation where i want to pass a object of a class say 'MyBigAwesomeClass' from a child to a parent. I import the class definition into both the parent and child. Now, if i load the child swf from a location that is relative to the location of the parent , all is fine, however the moment i load it using a full absolute path, it treats the definitions for 'BigAwesomeClass' in parent and in child as different and does not allow an object of the type 'BigAwesomeClass' to be assigned to an object of the same in the parent class.I am totally stumped, and have banged my head over ApplicationDomains, including using this code

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded);
var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loader.load(new URLRequest(_file.url),context);

[code].....

View 4 Replies

Flash - AS3 Font Embedding From Parent To Child SWF

Jan 10, 2012

I have a parent swf with fonts embedded in the library, which have export for actionscript set and a class name assigned. The patent swf loads a number of child swfs to which I'm trying to pass a textformat object using a desired font from the parents library. How can this be achieved. I have tried Font.registerFont(font class) and created a new instance of the font before setting the textformat, but this only works on machines with the font installed. In the child swf, the textfield text is set, then the textfomat applied with setTextFormat();

View 2 Replies

Flash :: Animate A Child Independent Of Parent?

Feb 9, 2012

We are creating a system where elements in a display unit are defined through xml. This also means that the whole system is dynamic in nature. [code]...

View 2 Replies

ActionScript 3.0 :: Flash Calling Parent From Child

Jul 21, 2011

In my child constructor I use MovieClip(this.parent).blablabla() to retrieve info, yea I know I can pass it through the constructor, anyways I keep getting errors anytime I try to use MovieClip(this.parent) in the constructor, it gives a refrence error saying it's null.

Why doesn't that command work, is there a way around it (other than the constructor)? Is it because it's bad design? I'm calling a function that has alot of data, so I'm just passing this to the child and using the passed this data to call the parent atm, looking for a better MovieClip(this.parent) solution.

View 2 Replies

Actionscript 3 :: Flash - Change A Variable In The Parent From The Child?

Mar 6, 2010

I want to change a variable set to 0 in the parent to 1 when a button in the child is clicked.

This is the parent zero.swf:

var noPass:Number=0;
function getPass(event:onLoad, noPass):void {
if(noPass==0) {

[Code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved