ActionScript 3.0 :: Using Variables From Parent Movie?
Feb 3, 2009
What I am trying to do used to be very simple. I have a variable set in move A. Movie A embeds another move (Movie B) into a movie clip. Is there a simple way to call a varaible from movie a through movie b?If you need a little more detail here is what I am trying to accomplish. Movie a loads a list of information from a xml file and uses that data to set some variables within the content. (ie. based on the data it might caculate that the user listed in the xml file likes golf) Then it sets golf to true in Movie A. My problem is i need this variable throughout several of my movies and I dont want to do the calculation in ever single movie clip. I am sure I am making this much harder than it needs to be.
View 3 Replies
Similar Posts:
Nov 10, 2009
i am trying to make a basic preloader for an AS3 site. I followed the tutorial on this site (Preloading actionscript 3 the easy way) where its similar to AS 2 - create a Preloader movie and load the whole .swf into it.
only problem is i need some variables that i pass to the movie via QueryString parameters in the Object and embed tags. Is there any way to get this in my loaded movie?
i have tried
root.loaderInfo.parameters
and
stage.loaderInfo.parameters
and
parent.loaderInfo.parameters
none of them work. Can i create a variable in the prelaoder and just go "parent.thevariable" ? or does parent even work when something is loaded into a loader?
View 1 Replies
Aug 4, 2010
I've build several movies which all work fine, but ultimately they need to run inside a Main movie which acts as a holder for the various child movies which load into it.Everything is working fine but not when they're loaded into the main movie. The main problems seems to be that the main movie has common component which relate to all the loaded child movies.Consequently the main movie has several instances - but how do I refer back to them in the child movieclips?I can't get the child movie clips to compile if I remove the references but ultimately the child movie clips need to speak to instances and functions in the main movie.Also, I've got a global function to hold the global variables but this method seems frowned on. But I need the global variables all the time and in all the movie clips.
View 3 Replies
Apr 20, 2009
I have a child class that is loaded into the parent class when the swf begins, like so: var myvar = 'hello'; public function Parent() { this.child = new Child(); }; How can I retrieve the variable 'myvar' from within child?
View 1 Replies
Feb 12, 2009
I Have 3 Movies:MAIN.SWF, contains loading movie actions for Nav.swf and Home.swf.NAV.SWF, contains navagation menu loaded on Level 2 in Main HOME.SWF, contains slideshow for home page loaded on Level 1 in Main In NAV.SWF, there is a MOVIE CLIP "graphmc", which contains a BUTTON "graphicbtn", When this button is clicked, I'd like the HOME.SWF (which is loaded into Main.swf on Level 1) to fade out and unload, and load and fade in Graphics.SWF in place of it.
View 6 Replies
Mar 8, 2010
I'm trying to access the AchievementScreen's textfield from a medal object. Point being to have a mouseover event of the medal, change the content of the textfield shown. I tried a trace first: trace(this.parent.parent.parent.parent.textLineCon tainer); 1119: Access of possibly undefined property textLineContainer through a reference with static type flash.displayisplayObjectContainer. trace(this.parent.parent.parent.parent) shows me it is a AchievementScreen object. textLineContainer is the instance name of the MC nesting the textfield (I actually drew the achievement screen then exported it to actionscript.
[Code]....
View 11 Replies
Jul 13, 2010
var some="someone" some main.swf. mc:MovieClip.mc in main.swf. Iam load a mainMenu.swf file into mc. how can call some variable in mainmenu.
View 1 Replies
Feb 8, 2010
I have loaded a movie clip into the "root" from the library using addChild. Inside this loaded movieclip, I need to populate a variable, but this variable is in the main time. The value must be sent when the user click on the clip that has been loaded. I have tried the following using a mouse click event listener.
MovieClip(this.parent).currentScore = 20;
but it won't work.
View 6 Replies
Jun 17, 2009
I have a loaded SWF into a simple "holder" empty movieclip I have on the root stage. Inside that SWF I have two variables that have "stage.stage Height" and "stage.stageWidth" in them. If I leave them on the code and test the root movie I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.So basically I can't seem to get the variables to get the parent stage. Anyway to get around that?
View 2 Replies
Sep 6, 2010
What's the strategy for getting a child to access variables in a parent.I have a Main class.In that class I create instances of a Unit class and save those to an array.In the Unit class, I want to access the x and y coordinates of other instances of the Unit class.So I'd like to access that array I made in the Main class.I tried:this.parent.theArray[i].xbut that doesn't work. I tried using the get command, but I don't really know how to, so my efforts failed.
View 3 Replies
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
Feb 11, 2010
Look at this example [code]...
How come the trace in the SlotsSetup function is printing out NaN ?
View 1 Replies
May 4, 2010
I have TestA.as the base class file for my TestA.fla that has nothing but a movie clip with instance name box.
TestA.as
ActionScript Code:
package
{
import flash.events.MouseEvent;
import flash.display.MovieClip;
[Code].....
View 0 Replies
Nov 22, 2010
I have a movieclip walls and a movieclip character (both on the same timeline). I want to access and change a variable inside character from the walls timeline.
ActionScript Code:
MovieClip(parent).character.somevariable = true;
...not working.
View 2 Replies
Feb 11, 2011
Wondering how to do this:
Parent swf has a class loaded, lets call it 'GlobalUtilities'. Parent swf loads in child swf. Child swf wants to use some of the 'GlobalUtilities' class that is in the parent.
How can I accomplish this? The problem I'm having right now is, when I export the child swf, I'll just error out since it can't find the reference (obviously, since it's not loaded into the parent yet).
View 3 Replies
Mar 8, 2012
im working with my main FLA and a script for it child.as i have created a variable in the parent, "svar:Number = 0;" i would like the child to be able to modify this variable when certain triggers are met i've tried something like this in the "child.as" but im assuming its probably much more complicated
[Code]...
im wondering if there is a simple command such as this to call upon an existing variable in the parent? if not, is there a way i can import the variables using the import command?
View 9 Replies
Jun 21, 2008
The external swf is located at:[url]....In the parent.swf, I put System.security.allowDomain(url....)When you click a button on the child.swf it's suppose to trace data from the parent.swf, but it returns undefined.What am I doing wrong? I MUST access data from the parent.swf
View 4 Replies
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
Jun 24, 2009
here's what I have (simplified to only show necessary code):
Main Timeline:
var currentItem:String = 'applesauce';
(then some code to load an external swf)
[Code].....
View 1 Replies
Apr 11, 2010
i'm trying to assign a parent's variable from the parent's child
//Parent
public class Main extends Sprite
{
public var selectedSquare:Sprite;
[Code]....
i'm receiving this error, but i'm casting parent from displayObjectContainer to a Sprite so i have no idea why it's not working.
1119: Access of possibly undefined property selectedSquare through a reference with static type flash.display:Sprite.
View 2 Replies
Sep 20, 2011
I have some variables defined in a child MC:
var first_nme = data.return_first;
var second_nme = data.return_second;
var email_addr = data.return_email;
var user_domain = data.return_domain;
var user_name = data.return_username;
I'm trying to use those variables in a parent movieclip/another movieclip.
[Code]...
View 9 Replies
Oct 31, 2011
I'm having some trouble getting to grips with how a child can refer to the variables of parents. Here is my Main.as :
package
{
import flash.display.MovieClip;
public class Main extends MovieClip
[code]....
Using trace(MovieClip(parent).i) instead I get:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Child()
at Main()
View 2 Replies
Oct 25, 2009
From the two .as files below, I get the following error when I run: 1119: Access of possibly undefined property importantNumber through a reference with static type flash.display:Sprite.
[Code]...
View 2 Replies
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
Nov 7, 2010
I have several .as files. The first that loads is Main.as;
package
{
import flash.display.MovieClip;
public class Main extends MovieClip
{
[code]....
So this MC gives the user the ability to type in their name and store it into the parents playerName variable. With the intention that I can refer to it at any point later in any other MC. It stores it okay, a trace proves that, but a problem comes when this movieclip is replaced by the new one ZoneSelector;
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
[code]....
As you can see, there's hardly anything in the this .as file. But everytime the trace(MovieClip(parent).playerName) tries to run I get the following error;
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ZoneSelector()
at Setup/onbeginGameButtonClick()
It's as if the ZoneSelector runs its entire script before the playerName is set..or something like that.
View 7 Replies
May 4, 2009
I am new to flash."I am unable to access the variables of child swf in parent swf after an action(button is clicked) is performed in child swf".
My problem is i had 2 swfs parent.swf and child .swf and i loaded the child.swf file in parent.swf using Loader class there is a textbox and a button in child.swf when we enter text in the textbox(say,notepanel_txt) and click on the button(say, mySubmit) the text present in textbox(notepanel_txt.text) is saved in the database using URLLoader and an variable called success(which is String type) must be available to parent. the code is as follows[code]...
View 8 Replies
Jun 25, 2009
I have an external swf (sub.swf) that loads into my main swf. The external swf has buttons of its own...that I would like to use to load additional external swf's in its place. I click on the buttons and nothings happens.
My current code is as follows:
All of the following code is in my main.swf
================================
//Location where the external SWFs will load
var Xpos:Number=18;
var Ypos:Number=10;
[Code]...
External swf has no code except for a stop action.
I pieced this current code based on various articles I've found on the net.
View 4 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
Jul 30, 2010
I am loading external swf's into a main load.swf, using a Moviecliploader object. What I basically want to do is that, after an external movie, say home.swf, loads another external swf, say about.swf, home.swf should be unloaded.
home.swf is loading about.swf into the _root.mc_holder, which is placed inside load.swf. I want all external files to be placed within this holder. Now this is working with some files, but not with others. My standard code within all files is this:
//code within home.swf to load about.swf
var loader:MovieClipLoader = new MovieClipLoader();var ldrlistener = new Object();loader.addListener(ldrlistener);ldrlistener.onLoadStart =
[Code]......
View 3 Replies
Jun 16, 2003
I'm working on a Flash MX application which involves a Parent movie and a Child movie.
I've loaded the Child movie into the Parent movie using LoadMovie. The instance name of the Child movie is Child1.
In the Child movie I have a user-defined function called getChildXML (we don't need to get into more details about the function).
The point here is that I want to call the getChildXML function from the Parent movie. I've tried something like Child1.getChildXML(); but with no luck.
View 4 Replies