ActionScript 3.0 :: Accessing MC Children By Name On Loaded SWF
Jul 14, 2010
Im loading SWFs into my AS3 application. My SWFS are all the same and contain this structure:
root
-item
--color
--overlay
When i load up a SWF file into AS3, This is analogous to the root. So i can say:
[Code]....
I have tried everything i can think of to access this second depth by instance name. Whats wierd is that MovieClip(loadedSWF.item).numChildren returns 2. So Flash knows that theres 2 MovieClips inside of item.... But it just cant reference them by instance name. Since loadedSWF.item works, i assumed that loadedSwf.item.color would work too.
EDIT: I seem to be able to access the MC via getChildAtIndex(0); However this isnt ideal because it create a rule for the designer that he must follow a layering order. Id prefer to do it by name.
View 0 Replies
Similar Posts:
Mar 15, 2010
enter code hereI am loading an external swf into an component. It loads everything fine and I can see buttons working in the swf, I can add a movieclip to the but I can't then access that movieclip (or don't know how), and it keeps telling me numChildren = null when I try to trace it out. This is set up as a custom component like this:
<cynergy:imageZoom
id="zoomComponent"
borderStyle="solid"
source="{_data.map.@url}"
[code]....
how I would access the children in the loaded movieclip?I have tried
mycomponent.image.getChildAt(2) and it returns and error that the index is out of bounds.
View 1 Replies
Jan 11, 2011
for some reason STORAGE[0].getChildAt(0) works whereas liner.getChildAt(0).getChildAt(0) does not. STORAGE is a movieclip and a child of liner. the error is something about not being able to use getChildAt on a display object. what's wrong? is there any other approach i could use? PS: liner.getChildAt(0) works and does indeed seem to refer to STORAGE[0]
View 2 Replies
Oct 19, 2010
Okay, here is the relevant files for a game I am making and their structure: -Stage -->MainMenu.as --> NewGame.as --> beachArea -->barrel.as.................................................. ......-->player.as.................................................. ......--> pistolBullet.asSo, am trying to detect when a bullet hits a barrel. I was going to use the hitTestObject() functionI got as far as trying to actually access the properties of an instance of barrel from the pistolBullet.as and seem to be a little confused as to my findings.. Can anyone explain to me why the last trace function returns undefined?pistolBullet.as:
Code:
trace("pistolBullet.parent: " + this.parent);
trace("pistolBullet.parent.beachArea: " + MovieClip(this.parent).beachArea);
[code].....
View 1 Replies
Apr 15, 2010
when I try to loop through the children of a List component that has buttons in it, I can't seem to access those children. I try
for(var btnNum:Number = 0; btnNum < myList.numChildren; btnNum++)
{
trace(myList.getChildAt(btnNum);[code]......
View 1 Replies
Jan 23, 2010
How do you access a child that has been added to an object?For example if I have a movieClip on the stage and I add a child to it, how do I then access that child?
Code:
var newClip:MovieClip = new MovieClip();
newClip.addEventListener(Event.ADDED, checkClip);
[code]......
View 4 Replies
Jul 23, 2011
Okay, here is the relevant files for a game I am making and their structure:
[Code]...
View 2 Replies
Jan 8, 2011
Code:
function saveAction(evt:MouseEvent):void{
var choice=evt.target.name;
var inputText:String = saveName.text;
}
I have this and I am trying to make a variable from the contents of the input box. Simple ya? The issue is that it is a child of another clip that is being added dynamically, so it doesn't think the input exists. How do I declare the input? How can I target it's contents? Also I have a remove function that is meant to remove this same parent clip.
Code:
function closeSaveWindow(evt:MouseEvent):void{
removeChild(saver);
}
'saver' is a variable created in another function, so I think there is a scope issue there. To try to fix that I declared 'saver' as a movie clip as a global var.
View 1 Replies
Nov 18, 2009
I'm making a OSX-finder-type file browser in CS4.The Structure for the folder and files is being generated by a PHP in a XML, heres an example:(sorry the xml is not sorted, but the command i'm using in php doesn't sort it)
Code:
<root>
<dir name="images">
[code]....
View 2 Replies
Dec 28, 2009
I'm trying to load a SWF I created with Flash CS4 into Flash Builder with the SWFLoader class, but I can't seem to access the loaded SWF's children. Everytime I try to change the property of a child it'll ignore it.
I tried loading the SWF with the Loader class, but it doesn't allow me to add it to the stage. How can I load the SWF and access it's children?My code atm (m is a child of the loaded SWF (SWFToLoad)):
ActionScript Code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
[code]....
View 2 Replies
Jun 15, 2011
My problems comes in when you have to open a different image album and have to eliminate all the previously loaded children in the movieclip. When i load a new album i used a code you posted here: AS3 How to remove previous loadersbut the problem is that sometimes the user leaves the album page before ALL the pics laod so when they click on a new album to open it a new image is placed somewhere else cause the loader has already been launched. I've tryd to close() the loader but it doesn't seem to work.Here you can see the working site to see what im talking abouy you have to click on an album, leave before all the pictures load and open up another one.
getImage(dataList[0].file)
function getImage(href:String):void {
var loader:Loader = new Loader();
[code].....
View 3 Replies
Mar 10, 2012
I have 2 swf files. One is loaded and loading an externally loaded swf into it.Here is the code in the first loaded swf: #1
var logo:Loader = new Loader();
logo.load(new URLRequest("images/Logo.png"));
logo.contentLoaderInfo.addEventListener(Event.COMPLETE, LoadLogo);
function LoadLogo(e:Event):void
[code]....
EDIT:I am having major SANDBOX issues now when I make the clip load from an external URL. I am also coding for an ANDROID using FLASH CS5.5. Its not allowing me to use Security.allowDomain("*");
View 1 Replies
Jun 15, 2011
0 down vote favorite
This is the code i used in a gallery that loads images sequentally. My problems comes in when you have to open a different image album and have to eliminate all the previously loaded children in the movieclip. The problem is that sometimes the user leaves the album page before ALL the pics laod so when they click on a new album to open it a new image is placed somewhere else cause the loader has already been launched. I've tryd to close() the loader but it doesn't seem to work. Here you can see the working site www.barbarabritvin.com (to see what im talking about you have to click on an album, leave before all the pictures load and open up another one.
getImage(dataList[0].file)
function getImage(href:String):void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, imageReady);
[code]....
View 1 Replies
Jun 1, 2011
I'm using this code to bring in another swf into a movieClip called "movieLoader":
var myLoader:Loader = new Loader();
movieLoader.addChild(myLoader);
var urlMovie:URLRequest = new URLRequest("movie1.swf");
myLoader.load(urlMovie);
The movie loads just fine, but how do I access it?
I tried:trace(movieLoader.totalFrames);
and it just gave me "1". I know the movieclip has more than 1 frame.What do I do to access the swf called "movie1.swf" I just brought into that movieClip?
View 4 Replies
May 20, 2011
I'm loading an external AS3 SWF using the Loader class but i need to access a method inside the loaded SWF. how can i do this?
View 1 Replies
Oct 13, 2010
So I want to access another loaded SWF. How can I have ChildA talk to Child B? All are external SWFs.
[Code]...
View 1 Replies
Mar 30, 2009
I am using a zoom component which i purchased recently to load different external swfs on different button clicks. But instead of loading separate external swfs I would like to load a single swf and go to frame labels - "one", "two", etc. - I've been reading about casting the external swf as a movie clip, but I am confused how this would work with the code I have at the moment.
var image:String="introlocal.swf";
function loadContent () {
var myLoader:Loader = new Loader();
[code].....
View 1 Replies
Jan 6, 2009
finding the url of the swf filefrom which it has been loaded? The purpose of the url is, I amloading some flv files using relative path. I just want to achievethe same by appending the relative path to the parent swf url fromwhere the parent was loaded. I am a newbie to AS3
View 5 Replies
Sep 15, 2008
I have a problem accessing a variable loaded from another swf. Actually the variable is a singeltone class, which needs to be initialized.It has structure presented in the last part of the message.The project has the following structure:
- main.swf - this loads all the other swf files and is their holder.
- assets.swf - contains some common elements and initializes the SingleTone class
- interface.swf - contains some interface elements and needs to use the SingleTone class
- all the three swf files have access to a common class structure, where the SingleTone class is defined.
Now, the problem I have is accessing the SingleTone class from the interface.swf file. If I try to send the SingleTone.singleTone. property parameter to the class I get "Type coercion failed: cannot convert from ClassName@.. to ClassName". If I try to access the SingleTone class directly from the interface.swf file i get "Cannot access a property or reference of a null object...". Both errors I get seem logical:
- if I send a parameter, I send the reference to that object, but the interface.swf file does not have access to the assets.swf domain;
- if I try to access the SingleTone class directly from the interface.swf file, I get the null error because the class is not initialized over the interface.swf domain.
Is there any work arround? I know a simple solution may be to initialize the variable over the interface.swf domain, but what if there is a variable that can only be instantiated in the assets.swf? Can I access that variable from another swf, or can I change the ApplicationDomain?
View 1 Replies
Nov 14, 2010
I am trying to load swf file with Loader class into AIR application. The broblem is that the loaded swf can not access web cam (it can when I run it standalone). Is there any security settings I have missed.
AIR loader code:
loader = new Loader(); loader.name = "moduleLoader";loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
[Code]....
View 3 Replies
Nov 23, 2011
In Flash Professional, I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.
Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.
Below is my main application's code. Errors thrown are mentioned in comments.
public class MovieClipTest extends Sprite
{
public function MovieClipTest()
{
[Code]...
View 11 Replies
Mar 4, 2012
I have a SWf application built in flex 4. One part of the application relies on accessing a public variable ("step1") set at the application root, and is accessed with
var app:Object = FlexGlobals.topLevelApplication;
trace("step one is "+app.step1);
This, while not optimal, has worked fine. Now, hoever, I need to load this entire application into another application, and I can't figure out how to access my step1 variable any longer.I have been loading the swf into the new parent application like so:
public var myLoader:Loader = new Loader();
public var pizzaContainer:UIComponent = new UIComponent();
private var myUrl:URLRequest = new URLRequest("chickensoup.swf");
[code]......
View 1 Replies
Jul 1, 2009
I am creating a flash program to open other flash programs (load swf files), and change their textfields to my own extended textfield class. This is to capture all text written to screen using a textfield object. Here is what I am doing:
1. If a textfield has been created, the event is captured
2. I want to replace the textfield with my own class extending textfield
*3. Any further access to the original textfield for value changes can be captured, and would update the replaced extended textfield object
The problem is if in their original code, at sometime, the text value of textfield is changed (mainly through textFieldObj.text = some_value) , I don't know how to capture this event.
This cannot be captured by event.CHANGE which requires the user input (ie: keyboard strokes) into the actual text field and changing the text through the code: textFieldObj.text = some_value does not trigger the event.
Here is a simplified example:
// FlashMovie.fla START -------------------------------------------
// any DisplayObjects (such as a created textfield) created will be captured
// by ChildAdded()
this.addEventListener(Event.ADDED, ChildAdded);
[Code]....
View 0 Replies
Jul 22, 2009
I have a movie called crime_scene.swf that is loaded onto another swf.
Code:
this.createEmptyMovieClip("myContainer", 1);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip)
[Code]....
It seems like it's not working. I tried just myContainer.evi_1.onRelease and _level1.evi_1 but nothing seems to work.
View 2 Replies
Jun 30, 2010
I have a file which loads a series of SWFs. It loads one, allows it to play to completion, then stops. Right now, it will just wait for the user to press a button and select the next one. However, I need it to play them sequentially. Is there any way for the SWFs which get loaded to access the functions which control the SWF loading?
View 4 Replies
Nov 23, 2011
In Flash Professional,I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.Below is my main application's code. Errors thrown are mentioned in comments.
ActionScript Code:
public class MovieClipTest extends Sprite[code].............
View 3 Replies
Jan 12, 2011
I'm having a SWF call functions from another SWF loaded in the first one with the Loader class. There are no problems as long as the target SWF does not contain any TLF TextFields created on stage by authoring time interface. As soon as I place a dynamic textfield on the stage of the loaded SWF, the main SWF (the loader) fails to call any of the functions within the SWF that is being loaded.Static text does not seem to present problems and neither do TextFields created via ActionScript.Also, is it possible to access variables of the parent SWF?
View 2 Replies
Dec 5, 2003
I am having a problem accessing variables in a loaded flash movie.
As my understanding goes (someone please correct me if I am wrong), if I load a flash movie into a parent movie (i.e. 'loadMovie("myMovie", emptyClip);'), I should be able to access the loaded movie's variables using dot-syntax.
As an example, say I have two movies: MainMovie.swf, and SubMovie.swf. SubMovie.swf contains a (global) variable called someText. After loading SubMovie into an empty movie clip called "emptyClip", MainMovie.swf should be able to access the aforementioned variable by saying "emptyClip.someText", right....? Well, when I try this I keep getting an undefined value for the variable.
View 7 Replies
Mar 25, 2006
I loaded an external swf into flash using loadMovie. The loaded movie has a hidden button which does some actions. How can I, by clicking on a button on flash execute the actions of the button which exists on the loaded swf?
View 1 Replies
Sep 8, 2008
I'm sorry if this has been answered 1,000 times, but I am so confused with everything!! In the main timeline of my movie, I have a container movieclip called "content". I want to load an external swf into content, and then access the functions in that swf. I can load it no problem, but I can't for the life of me figure out how to access the functions, I can't seem to find it anywhere!
View 3 Replies