ActionScript 3.0 :: Accessing Parent From A Loaded Swf
Jun 8, 2010
Well, I know how to access the loaded swf variables from its parent, but how do I access the parent SWF variables from a loaded SWF?! I'm trying it.. But get no results.
I have a "MainSWF", that loads and places other SWFs "LoadedSWF". The LoadedSWF has buttons that are supposed to make some layers in the MainSWF visible/invisble. These layers are in a placed navigation bar that is defined as a symbol, was placed on the Main Stage and given the instance name "FlashStageMainNavigation". I have a hard time figuring out how to address the layers in the MainSWF, because it seems I am missing something.
When I use a loop to trace all the child instances on the stage of the MainSWF with:
I have a shell swf that is loading a swf. How do you have the loaded swf tell the parent loader to unload itself after the loaded swf finishes playing?
Im working on a project that has a main swf file associated with the document class. It loads XML that provides the text content for the project, then it loads a swf that contains a font in its library, then it loads the first of several content module swfs. When the font swf has inited, I'm registering its library font with Font.registerFont(), and using it in a TextFormat object. After everything is done, I can add code to the document class to create a text field on the stage of the main swf and format it successfully with the TextFormat object, but when I try to do the same thing inside the loaded content module swf, the text doesn't show up there at all.
I'm working on a project that has a main swf file associated with the document class. It loads XML that provides the text content for the project, then it loads a swf that contains a font in its library, then it loads the first of several content module swfs. When the font swf has inited, I'm registering its library font with Font.registerFont(), and using it in a TextFormat object. After everything is done, I can add code to the document class to create a text field on the stage of the main swf and format it successfully with the TextFormat object, but when I try to do the same thing inside the loaded content module swf, the text doesn't show up there at all.
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.
I'm doing some work with JSON in as3 using as3corelib (very useful) and was wondering if it is possible to get an object if all you have is one of its properties, also an object.Here's an example of some JSON:
This is probably a fairly easy answer, but I can't figure it out. I have a dynamically added child, and I have a dynamic text box on the parent. I'm thinking that it should be possible for me to add to the text box from the child timeline, but I don't know how to target the text box.
I've been using greensock classes in a parent movie, but am now looking to use the same classes from within some child movies, but it doesn't work (I presently have to import them into each child movie - what a waste).
Do I need to create the classes as a shared library object perhaps? If so, how would I go about it? as I've only ever done this for MCs or MP3s.
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.
I have a .fla file with some code in the actions panel.A bit of code calls a function in a class from the actions panel .The function in the class is run, but I want to be able to call a function in the main actions panel code from the function in that class .The class doesn't extend anything so (parent as MovieClip).function() does not work.
I have several custom components all of which are included in the parent application.When I try to change state from a custom component, I get an error saying "undefined state: state name". How do I change the state of the application from within a custom component ?
ActionScript Code: function createMaskBox():void { var maskBox:MovieClip = new MovieClip(); galleryContainer.addChild(maskBox); }
creates maskBox under the function therefore not accessible form outside of this function from what i understand. Is there a way to create a var WITHIN a function which would exist as if defined outside of it, directly in code?
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?
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.
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).
how to access a movie clip/s in a parent swf from a child swf. for example:Interface swf has buttons as mc's (home, about, services, portfolio e.t.c.) and loads in a swf when one of the buttons in the interface swf is pressed. When a button in Interface swf is pressed none of the other buttons can be pressed until the swf of the button that was pressed has loaded.
The reason for this is so that if the user tries to press the buttons quickly lets say the user pressed services button but changed thier mind right after pressing it and wanted to press lets say portfolio button they couldnt press the button until the services swf has loaded. Ive seen websites that dont do this and is makes it all mess up. Ive been able to do this in the past in AS2 but i cant figure it out in AS3.This is the code i would use in AS2:
Interface swf code is: ActionScript Code: _level5.btn_1.enabled = false;[code]...........
I'm also relatively new to programming with actionscript, so my code might look quite messy to you Here is my function. It loads the contents of an .xml file and creates a playlist for a video player. Now my problem is that i want to set the "onRelease" function dynamicaly for each playlist item. but inside the onRelease-function i cannot access the variable i. do you have a hint / workaround for me?
I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!
inside snow_mc I am trying:
PHP Code:
if(this.hitTestObject(this.parent.bauble_mc)){ }
to which flash says:
1119: Access of possibly undefined property bauble_mc through a reference with static type flash.displayisplayObjectContainer.
What is the code to make you jump to a "Label" in a parent movie clip, when clicking on a button.Lets say the buttons name is push_btn and I am in mc2 and the label is located in mc1.
var lightBox:mc_lightbox = new mc_lightbox(); lightBox.x = 300; lightBox.y = 200; addChild(lightBox);
I get a lightbox up on the screen, within the lightbox is some more script, there are three menu options for that new window. So far when you click on it the loading part comes up just fine but whenever I have it go to another scene it leaves behind the lightbox above. I'm able to removeChild(loading) because its right there just a function above but I'm unable to removeChild(lightBox) because it's one up. How can I access that child? I tried many variations of parent, MovieClip, and root relationships but still couldn't get flash to find it.