ActionScript 3.0 :: Reference To Child By "level" Not Instance Name?
May 12, 2010
The following code works fine. However, rather than refering to the child by instance name I want to use something like the as2 _level1.gotoAndStop.
The idea is that it'll work for any .swf that is added using addChildAt(1) and therefore avoid having to repeat the code for lots of different .swfs
Code:
stop();
var thisMovieClip:MovieClip;
var thisLoader:Loader = new Loader();
[Code].....
View 5 Replies
Similar Posts:
Oct 23, 2009
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.
View 10 Replies
Aug 18, 2010
I have a movieClip with one frame on the timeline containing one child whose instance name is "myContent"I am using this function to swap "myContent" with any number of possible class instances.
Code:
function setContentAsClass(c:Class)
{
[code].....
View 2 Replies
May 16, 2011
i have a small question concerning away3D. I have some cubes with the exact same dimensions that are positioned in the same place. When i click on the stack of cubes, i want to register a click on the cube i added last. Instead of doing this, the click is registered on the cube i added first.
I have found a way to alter the cubes position in the container and have tried putting the element at the end (code below) and start of the childrenArray, but nothing seems to work. I am kinda really stuck here, so if anyone knows how to get the top level element when clicking on the stack, i'd be happy to hear.
[Code]...
View 1 Replies
Jan 23, 2009
I have a child that I added during run time. I would like it to access a variable that was defined on the stage. npFurn:Number.[code]...
View 9 Replies
Jul 2, 2009
I encountered and did not make heads or tails out of this whole new concept of child, parent and setting a index level. What is an index level and this 'child and parent' thing?
View 3 Replies
Jun 24, 2009
I have a movieclip(parentMC) which consists of several other movieclips(childMCs). Each childMC can trigger an event, and each event performs a different function. I want to check from my parentMC whenever there is an event triggered by any of its child.
View 3 Replies
Apr 14, 2011
I'm creating a little game - The player controls a character that follows the mouse. Pigs run away from the player, and the player has to get them all into a pen. To make the game a little more difficult I'm trying to add an enemy - wolves, that attempt to perform a 'hunt' method every x seconds. This method sends a reference of the wolf instance to Main (my document class) and Main then loops through the pigs on stage to see if there's any nearby. Now as far as I know this works - my problem is I'm unsure how to send the pig instance reference back to the wolf that called the hunt method, so it can then 'target' the pig, and then attempt to pounce on it.
This is my Wolf class:
Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
[Code].....
View 7 Replies
Jul 21, 2009
Got this code
Code:
function onOver (event:MouseEvent):void
{
[code].....
View 9 Replies
Jul 24, 2009
I've got a set of arrays being dynamically generated with paths to nested movieclips. The paths are coming in as strings, and I can't seem to get them to work as movie clip instance variables.as example, a string would be:
siteMC.b1MC.b1f1MC.rMC
(that path works fine outside of the array)
How do I get that kind of nested path from the string to something flash wont spit out as null?
View 4 Replies
Apr 13, 2010
I thought since a Sprite is a display object container and I can add an instance of a MovieClip to it I should be able to reference the MC through the Sprite.
var bh1:Sprite = new Sprite(); beerChan = new BeerChan(); bh1.addChild(beerChan); trace("bh1 "+bh1); trace(bh1.beerChan);
1119: Access of possibly undefined property beerChan through a reference with static type flash.display:Sprite.
View 10 Replies
Oct 2, 2009
I have a movieClip and would like to run a hitTestPoint() if statement on it, but only for a particular instance within the movieClip.
Would: 'movieClipName'.'InstanceName'.hitTestPoint () { work?
View 1 Replies
Mar 16, 2010
I have 6 movieclips on the stage, each with a unique instance name. I just want to put them in order determined from an external xml file.I can get the name and order of each instance name evident from a trace, but I can't use that xml variable name to position the x on the stage.Seems simple, but it won't let me use the variable as an instance name:
//begin AS3
var loader:URLLoader = new URLLoader();
var xml:XML = new XML();
[code].....
View 2 Replies
Apr 29, 2010
I have one custom class named player, which plays video from RTMP Server. It has property named cliptime:Number and it holds the video's duration through the metadata.duration property. I have other class named controlbar which holds the control bar for the video. I use TweenMax.to to move It's video slider and I want the tween's duration value to be the player class' cliptime property. But I can't get this value. Both classes are child of ramesCont class and are added to it. framesCont and controlbar extends Canvas class, and player extends Sprite if it matters.
[Code]...
View 11 Replies
Dec 10, 2010
Quick question. I have been Googling this all morning, but it's either not there, or else written in a way that doesn't register. I am inclined to believe the latter, as this seems like it should be something completely trivial to me. I made a small Flash file using AS 3.0, and this is the first time I've really been able to stick to the OOP way of doing things and not hack together a mix of stuff from the timeline to get around not having everything work in the classes.
So I'd like to keep it that way, but one thing is eluding me: I can't call a method of an instance of another class (than the one I'm calling from) without resorting to "DocumentClass(root).instanceName.method." Intuition tells me there has to be a better way of doing this (like, without having to reference the document class every time I call another class instance's function; and CERTAINLY without having to use the word "root" - that just seems so Flash 5 to me. Does anybody have a better way of doing this that they can share?
[Code]....
View 1 Replies
Nov 15, 2009
I have a script on frame 1 that onRelease of button should tell dynamic MovieClip instances which have been added by attachMovie on frame 2 and 3 to go to a particular frame , here's the code:Frame 1:numdests is set to 2pagesAmount is set to 4
btn_submit.onPress = function(){
for (var i = 0; i<numdests; i++){
for (d = 1; d < pagesAmount + 1; d++){
[code].....
View 9 Replies
Aug 16, 2009
Lets say I have 3 Movie Clip Symbols in my Library : Movie0, Movie1 and Movie2
Each movie has a dynamic text box: "TextBox1"
I want to be able to write a function that can manipulate the alpha(or any attribute) of the TextBox1 in all three MovieClips.
In my limited experience I thought I could do something like the following:
for (var row:int = 0; row < dataArray.length; row++)
{
Movie(row).TextBox1.alpha = 1;
}
I hoped that this would loop through 3 times and set the alpha of the TextBox1 in all three movies to 1.
Is this possible? Can you reference an instance with use of a variable?
View 2 Replies
Mar 8, 2011
set to null a reference in this case?
private function initGame():void{
var game:Game = new Game()
}
[code]......
View 2 Replies
Jul 15, 2011
Is it possible to control an object/element on a instance? If so, how is it done through actionscript? There is an instance "instance140" off of the root, that has an element named img4 that i need to reference... does anyone know how I would go about that? using root.instance.object form returns undefined.
View 1 Replies
Nov 15, 2009
I have a script on frame 1 that onRelease of button should tell dynamic MovieClip instances which have been added by attachMovie on frame 2 and 3 to go to a particular frame , here's the code:
Frame 1:
numdests is set to 2
pagesAmount is set to 4
[Code].....
Currently the movies that are added using AttachMovie don't move when button on frame 1 is pressed.
View 0 Replies
Sep 6, 2010
I have movie clip Ball what has public function glow[code]...
full access to Ball is MainMenu.ImagesPanel.Ball
I want to send command from server in text like:
string="MainMenu.ImagesPanel.Ball.glow"
How to convert sting to structure?
View 0 Replies
Oct 14, 2010
i'm playing around with Senocular's brilliant transform tool. Here's the code that I'm having issues with - it targets the instance name, which is great and works perfectly.
ActionScript Code:
_transformTool.targets = [pasteBoard];
_transformTool.activeTarget = pasteBoard;
Here's the issue. When I have an MC placed on the stage with the instance name of 'pasteBoard' the above code (which tells the transform tool what to transform), works just great. However, when I place the MC on the stage with AS and name it, the transform tool can't find it . Here is the code I'm using to place the MC:
ActionScript Code:
var pasteBoard:_pasteBoard = new _pasteBoard();
addChild(pasteBoard);
pasteBoard.name = 'pasteBoard';
pasteBoard.x=128.00;
pasteBoard.y=300.00;
Now, surely this should work as I'm even giving it an instance name? But it does not, it does not work even with no instance name, or when the class object name is different than the instance name. Weird huh? Surely this should work just fine as I'm doing exactly the same thing as placing it on the main timeline, just doing it with code. But the transform tool, referenced by the code at the top of this post, can't find pasteBoard.
Do I need to alter the code at the top to find pasteBoard by class instance? how would I do that?
View 4 Replies
Jul 14, 2011
Is it possible to control an object/element on a instance? If so, how is it done through actionscript?There is an instance "instance140" off of the root, that has an element named img4 that i need to reference... does anyone know how I would go about that?
View 0 Replies
Mar 23, 2012
I created an Array of lrgIcons that contains several MovieClips, they are then positioned within a second MC and pushed to a second array of lrgIconsOnStage, they are enabled as buttons and assigned an event listener (all of this works fine). Problem is, I want to know which lrgIcon is selected and react to it with an if statement. When I trace the array of lrgIconsOnStage I get [object amazonLrgIcon],[object emailLrgIcon],[object gmailLrgIcon],[object messagesLrgIcon],[object missedCallsLrgIcon] and when I trace e.target I get [object amazonLrgIcon] (depending on which item I selected, which in my mind, should trigger the code correctly, but it does nothing, Why?
Code:
var currButton:String;
var lrgIcons:Array = new Array(amazonLrgIcon,emailLrgIcon,gmailLrgIcon,messagesLrgIcon,missedCallsLrgIcon);
var lrgIconsOnStage:Array = new Array();
var lrgIconPosY:int = 69;
var lrgIcon:MovieClip;
[Code] .....
View 7 Replies
Nov 21, 2010
1) I have a movieclip instance on stage (simple graphical element that represents platforms for a hero to run and jump along). I have placed it on the stage with an external class engine.as and in this class it is called myPlatform and is an object of Platforms.as. The movieClip is called platforms and from a trace(myPlatform.name) the instance name is instance3.
2) I am attempting to access the properties of myPlatform in an Enterframe event loop in my character control and collision class (called hero.as)Basically here is the bit of code I am trying implement within Hero.as :
if (myPlatform.hitTestPoint(x,y,true)) { // if a platform is hit
trace("hitME");
y--;
tGravity = 0; // reset
break;
}
Here's the error that I get:
1120: Access of undefined property myPlatform
This all worked when I was writing actionscipt within the FLA file, on the timeline frame 1.I simply don't know how to access myPlatform from within the external Hero.as class! Do I need to create a variable?
View 1 Replies
Nov 26, 2007
I'm creating a dynamic movieclip and the name/instance name is stored in a variable. How can I reference the instance if its stored in a variable?This is what I'm using and it doesnt seem to work (for obvious reasons). I know in php that you do this "blah blah" . $variable.
View 1 Replies
Apr 26, 2010
I am using loader to load an image "1.jpg" in the constructor.Using a timer, after 5 seconds I want to remove the child and then reload another image however removeChild doesn't work, neither does getChildIndex. In the constructor I can call getChildIndex and it outputs 1, however in the Timerevent function it seems that I cannot get access to the my_loader created in the constructor.
However from the Timerevent function I do have access to the variable test that I created in the constructor. Why is it that I can access test, but not my_loader and how can I fix this so I can get the reference to my_loader within the Timerevent function? I tried moving the loader outside of the constructor but then I get a message saying that my_loader is undefined for the line "my_loader.load(new URLRequest("1.jpg"));"[code]...
View 2 Replies
Oct 9, 2011
So I have a button on which I create an instance of a symbol, I'd like to have a listener for the new symbol but I get a reference error because it compiles the listener before I get to create the instance. What do I do?
[Code]...
View 1 Replies
Apr 25, 2011
I'm fairly experienced with Flex 4, but I still haven't needed frameworks yet (I like to do everything myself) and don't want to use them either, I know it's advantages and have learned how to use one of them, but still, no.
How can I dispatch an event in the main application and have a component inside a popupmanager to react to that event? All this dispatching the event within the main app and NOT aiming it to the popupmanager or the component instance, I want to be able to fire the event and not care about who gets it or if anyone reacts to it at all so if that is possible then I wouldn't care about keeping track of said popups.
I already dispatch an event from the component and receive it in the main application by bubbling the event and therefore being agnostic of each other, now I want it backwards.
View 3 Replies
May 23, 2011
class Foo {
public function bar():void { ... }
}[code].....
View 4 Replies