GetChildByName - Access a movieclip instance name inside
This works:
layerMenu.duplicateMov(LHolder.L1Holder, layerMenu.getChildByName("layer1"));
This doesn't work:
layerMenu.duplicateMov(LHolder.L1Holder, layerMenu.getChildByName("layer1").L0Dup);
L0Dup is an instance name of a movieclip inside getChildByName("layer1")
Any clues for a workaround?
Error Message:
Scene 1, Layer 'Layer 1', Frame 1, Line 20
1119: Access of possibly undefined property L0Dup through a reference with static type flash.display:DisplayObject.
L0Dup is always visible, thus playing.
here is the function that creates "layer1" and more.
function createLayerBoxes()
for (var i:int = 0; i < NUM_LAYERS; i++)
var box:Box = new Box( i + 1 );
box.y = (box.height + LAYER_SPACING) * i;
box.name= "layer" +( i + 1);
box.buttonMode = true;
box.addEventListener( MouseEvent.MOUSE_DOWN, onLayerPress );
box.addEventListener( MouseEvent.MOUSE_UP, onLayerRelease );
addChild( box );
_boxes.push( box );
Similar Messages
-
I want to access that BEA instance variable inside of a external java class
Hi,
This is N.pradeep. I am a java programmer, and I am new to BEA AquaLogic BPM studio5.7. I have a question regarding how to retrieve an instance variable of BEA Aqua Logic to an external Java Program. i.e. I want to access that BEA instance variable inside of a external java class, and vice versa.You can use PAPI or PAPI-WS for accessing BPM instance variable from a Java code, thougt I am not sure how the reverse will be done. Assuming that you are aware aof PAPI-WS and have created the necessary stubs out of the PAPI-WS WSDL using Axis, you can access instance variables using the API's or operations defined therein.
Thanks and Regards
Vivek Nandey
BEA Certified Developer for Integration Solutions
[email protected] -
Accessing a movieclip instance created with AS.
If I attach a new movie clip and give it a name by concatenating the instance name with a variable number (such as "myMovie + myVar" so that I get "myMovie1", "myMovie2", etc.), how do I then access the resulting instance in order to assign properties? MyMovie + myVar._x = 500 not surprisingly doesn't work. I presume I need to assign the value to a string variable, and then somehow assign that variable as the instance name of the movieclip?
Thanks.that's incorrect syntax and contains a typo. try:
var myVar:Number = 1;
this.attachMovie("Square_mc","Square_mc"+myVar,this.getNextHighestDepth()) ;
this["Square_mc"+myVar]._x = 300; -
Acquiring movieclip instance names
I need to write a function that retrieves the instance names of movie clips without knowing what those instance names are.
Here's the scenario:
The timeline reaches a frame which has a movieclip with an instance name of "bigClip"
bigClip itself holds a number of movieclips, each with its own unique instance name. On the enterFrame of bigClip, I want to retrieve all the instance names that are on bigClip and put them in an array.
I can't seem to figure this out. Any guidance would be much appreciated.
Thanks,
DavidWell I doubt you want to do it on the enterframe of bigClip. Do you really need to find the names of all the clips 30 times a second every second that big clip exists? I'm guessing/hoping you just mean when bigClip starts.
In any event you can make a function that returns an array. Perhaps something like this:
function findChildrenClips(clip:MovieClip):Array{
var theClips:Array=new Array();
for(var a in clip){
if(typeof(clip[a])=="movieclip"){
theClips.push(clip[a]);
return theClips;
Then on the frame where big clip exisits you can do this:
var foundClips:Array=findChildrenClips(bigClip);
Now if you really want to do this onEnterFrame you could probably do it, but there is probably a better way to structure your file in that case. -
AS 3:calling all instance names with similarities
As the title suggests I am looking to RegExp as a means to
find similiarities between diffferent movieclip instance names. I
have many clips that have an instance name that begins with "step"
that reside on the maintimeline. The logic written out should be:
If a movielcip exists on the timeline, whats its name, does
it have this string within its instance name, if so do this.
Unfortunately my code does not accomplish this quite
yet.I'd think this would be the same in 3, but in 2 you'd use
array access
notation like so:
var myIndex = 3;
this["step_" + myIndex].moveUp();
this would call moveUp within step_3. You can interate
myIndex in a loop, of
course, to call the function in a group all at one time.
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
Flash CC HTML5 Get instance names on click?
I make escape games and often have lots of items in a scene each with flash instance names that on mouse over or mouse click make some event happen or some text is displayed.
I'm using Flash CC and HTML 5 output and cannot get it to output the instance names in the log, is this not possible? Can anyone suggest an alternative method of responding to lots of movieclips/buttons etc
Here's my test code:-
//stage.enableMouseOver(24);
var clicked = "";
var clickedname = "";
//NEED TO FIND OUT MOVIECLIP INSTANCE NAME??
var key1 = exportRoot.key1
//key1.name = "key1"
//console.log(key1ref.name)
stage.on("click", function (evt) {
//clickedname = stage.getObjectUnderPoint(evt.stageX, evt.stageY)
//clicked = evt.target
clicked = evt.target
console.log(clicked)
//output result to log
/*if (clicked == "key1"){
console.log("clicked key 1")Thanks Ned, I really appreciate the help as I've been stuck on this seemingly obvious thing for a few days now and can't progress until I can figure it out...
Basically using currentTarget it outputs this:-
a {id: 24, _matrix: a, _rectangle: a, children: Array[1], canvas: canvas#canvas…}
so comparing it to a name/instance name is not going to work ;-)
using evt.target gets me this:-
lib.key1 {id: 21, _matrix: a, _rectangle: a, image: img, x: -40…}
so again useless, a reference to the key1.png in the library but not to the named instances placed on the stage!!
Am I assigning the instance name correctly??
var key1 = exportRoot.key1
key1.name = "key1"
Any help from anyone appreciated!! -
MovieClip Name inside other MovieClip Compiler Error
I have a movieClip called "mcUnitedStates" inside another mother movieClip.
I have two instances of the mother movieClip. One entitled "mcWorldMapTop" on its own layer and the other entitled "mcWorldMapBottom" on its own layer.
I thought having two instances of the same movieClip and applying different filters to the mcUnitedStates movieClip in each.
Error I get is:
Access of unidentified property mcWorldMapBottom
I'm doing this because the colorTransform is making the glow the same color as the colorTransform instead of the color I want the glow to be.
I am getting a Compiler error with this code:
stop();
import flash.display.Sprite;
import flash.filters.GlowFilter;
var colorON="0x1E6175";
var colorOFF="0xCCCCCC";
var glowColor="0xFFFFFF";
var glowAlpha=.75;
var glowBlurX=25;
var glowBlurY=25;
var glowStrength=2;
var glowQuality=2;
var glowInner=false;
var glowKnockout=false;
mcWorldMapBottom.mcUnitedStates.filters=[new GlowFilter(glowColor,glowAlpha,glowBlurX,glowBlurY,glowStrength,glowQuality,glowInner,glo wKnockout)];
var colorTransform:ColorTransform=mcWorldMapTop.mcUnitedStates.transform.colorTransform;
colorTransform.color=colorON;
mcWorldMapTop.mcUnitedStates.transform.colorTransform=colorTransformdoes that one movieclip, mentioned in the error message, exist in the same frame as that code?
if so, there are a few ways you could cause a problem and still have the instance name match the name used in your actionscript.
one way would be if you converted a button or graphic to a movieclip. if you didn't do that, remove the current movieclip with that instance name and create a new movieclip with that instance name. retest.
if you see a different error (about a term being undefined etc), you can remove that new movieclip and drag the correct movieclip to the stage and, after copying the name from your code, paste that name into the properties panel. retest. -
Get the instance names of clips attached to a movieclip
I want to get the instance names of all the cmovieclips that
are attached to a movieclip.
Is there a simple way to do this.
I imagine this is something that can be done with AS3 but can
it be done with AS2?
regards Jyou're welcome.
FYI: a for...in loop loops through all the accesible
properties (in the broadest sense of the meaning, includes
methods/functions and variables etc). Each time it finds one it (in
this case) assigns the property name to the variable 'unknown'
the code inside the loop just checks
a) is it a property that references a movieclip instance and
b) is it the same property name as the movieclip instance's
_name property (this is to avoid listing additional references to
the same movieclip instance that may be set up as variables in your
McA's scope).
I just read that and I'm wondering if it actually will help
you understand... its quite complicated to describe,sorry...
although its simple to understand once you get used to it. To learn
you should experiment with a few for.. in loops on different
objects and see what trace outputs you get. -
How to access instance name? need help here.... :D
using actionscript..
if i have a movie clip in my Scene 1 and inside that movie clip is another symbol e.g. a button, how will i reference the instance name of that button in my Scene 1. tnx!Use the dot operator. Say for example you have a movieclip with instance name mysymbol and it has a child symbol button with name childsymbol then you use mysymbol.childsymbol on the main timeline. Try also to trace the symbols to see if they exist like trace(mysymbol) or trace(mysymbol.childsymbol)
-
How do i reference a movie clip instance name from inside child movie clips.
I have a label I am referencing form a movie clip inside the movie clip which contains the "label_2."
Here is the code I used:
MovieClip(parent.parent).gotoAndPlay("return_2");
Now I need to reference a instance name of a movie clip in side the same scene.
What would the code be?You should probably start by reading the docs and/or google:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9 b90204-7fca.html
http://www.google.com/search?hl=en&q=AS3+events
Once you got the basics down, look into creating/using your own custom events:
http://www.google.com/search?hl=en&q=AS3++custom+events
http://www.adobe.com/devnet/actionscript/articles/event_handling_as3.html
Event dispatching and event handling is one of the most important things about ActionScript. The sooner you get into them, the better. -
Accessing a movieClip inside a movieclip in as2
I am trying to get to a
movieclip nested inside a movieclip in As2:
MovieClip1.movieClip2.movieClip3.gotoAndStop(2)
MovieClip1, MovieClip2, MovieClip3 is instances Names.Your approach is correct. Based on the change in spelling between the two lines you show, if you are having a problem, that may be the cause.
-
Adressing multiple copies of Movieclips with the same instance name
Is it possible to iterate through MV copies with the same instance name? It would be very useful for my project.
you can copy movieclips with the same instance name but you'll only be able to easily control (with actionscript) the last created instance. the rest will be difficult to reference.
although, if the only movieclips attached to the parent are the ones you are interested in and you want to do that same thing to all of them (say rotate them all), you can do that without giving them distinct names. -
Reference a movieclip by a variable containing its instance name?
There are some movie clip instances on the stage (not
dynamically created at run time). Now, I want to do this:
use a variable to hold a instance name at runtime. then use
this variable to reference the movie clip it points to.
Problem: suppose this variable is named "mc_ref". it fails to
use "_root.mc_ref" to refer to the movie clip by the name that
mc_ref contains. it seems in this case flash takes "mc_ref" as
instance name and thus looks for any child by that name. since
mc_ref itself is not a name, this will not work.
is there something like MovieClipbyInstanceName function for
this? Any thoughts? Thanks!you're confused. the variable's name and the movieclip's name
should not be the same.
the following are correct ways to reference movieclips in
flash: -
Return MovieClip symbol name from an instance
I have variables that return _level0.mcContainer.mcSquare,
_level0.mcContainer.mcTriangle, etc. They are instances of the
MovieClips mcSquare, mcTriangle, etc.
Is there any way to take the variables and return the name of
the MovieClip as it appears in the Library?
Any assistance is appreciated.Thanks for the fast response. Very close to what I need, but
I think that that is returning the instance name still, and not the
symbol name. A better example for me to offer would be the below
one.
There are variables that return
_level0.mcContainer.mcSquare01, and _level0.mcContainer.mcSquare02.
These are both instances of the mcSquare MovieClip, that were given
dynamic instance names when they were created.
Using ._name returns mcSquare01 and mcSquare02. Is there a
way to get mcSquare out of it? A custom class is the only thing I
can think of, just wondering if there were a simpler
solution. -
Multiple MovieClips with same instance name
I'm following a tower defence tutorial and part of the code is set up so I can build towers on the "grass" movie clip. I wanted to add more patches of "grass" and gave them all the same instance name so I can be able to place towers on them, but I have the problem that I can only place towers on the first item I placed and has the instance name of "grass". I can't seem to place towers on the other patches of grass.
I removed the instance name of the first patch of grass and it let me build towers on the second patch, but the second patch only.
I was following this tutorial: http://www.goofballgames.com/2010/01/31/how-to-build-a-tower-defense-f lash-game-part-2-placing-towers/
Here is the code for it I believe:
onClipEvent (load)
active = 0;
onClipEvent (enterFrame)
if (active == 1)
setProperty("", _x, int((_root._xmouse - 10) / 20) * 20 + 20);
setProperty("", _y, int((_root._ymouse - 10) / 20) * 20 + 20);
hitTestOnGrassMovieClip = _root.grass.hitTest(_x, _y, 1);
if (hitTestOnGrassMovieClip) {
gotoAndStop(1);
_root.ranger.gotoAndStop(1);
else {
gotoAndStop(2);
_root.ranger.gotoAndStop(2);
_root.ranger._x = _x;
_root.ranger._y = _y;
_root.ranger._width = _root["tower_" + tower].range * 2;
_root.ranger._height = _root["tower_" + tower].range * 2;
on (press)
hitTestOnGrassMovieClip = _root.grass.hitTest(_x, _y, 1);
hitTestOnDeSelectMovieClip = _root.deselect.hitTest(_x, _y, 1);
if (hitTestOnGrassMovieClip || hitTestOnDeSelectMovieClip) {
if (hitTestOnGrassMovieClip) {
++_root.towerCount;
_root["tower_" + tower].duplicateMovieClip("t" + _root.towerCount, 500 + _root.towerCount);
a = _root["t" + _root.towerCount];
a._x = _x;
a._y = _y;
a.active = 1;
active = 0;
setProperty("", _x, 1000);
_root.selectedTower = "";
_root.ranger._x = 1000;
_root.ranger._width = 10;
_root.ranger._height = 10;
}1. You cannot use the same instance names for different objects and expect more than one to be targeted. You need to assign unique names, or you can store references to them in an array and use the array to target them.
2. You are posting AS2 code in the AS3 forum. You should repost in the AS2 forum. http://forums.adobe.com/community/flash/flash_actionscript
Maybe you are looking for
-
March's TechNet Wiki BizTalk Guru Winners announced!!
The results for March'sTechNet Guru competition have been posted! http://blogs.technet.com/b/wikininjas/archive/2014/04/17/the-microsoft-technet-guru-awards-march-2014.aspx <- results page! Congratulations to all our new Gurus for March! We will be i
-
I m trying to send a email and sms alert to people and it works fine on all systems expect on Iphone,the problem is swedish charcters doesn't show on iphones used by people in sweden but works absolutely fine on iphones in india. the code i m using i
-
Adobe Flash Player and Apple iOS 8.1.3
I have an iPhone 4S and I used it to stream FM radio through my AV system by locating the website of the station on the phone, clicking on Listen Live and using the Air Play built into the receiver to connect to the streaming audio. Apparently, I wa
-
Hey, I'm trying to find a cheap video capture device that I can use with my iBook. I'm looking for something comparable to the Diamond VC500 One Touch Video Capture Device: http://www.amazon.com/Diamond-VC500-Touch-Capture-Device/dp/B000VM60I8/ref=pd
-
If column2 is same for two different column1 data
I have a table say XYZ like this COLUMN1 COLUMN2 A B C B N X HJ X I want to print if column2 is same for two different column1 data I want to print that rowids Please help me in this