ActionScript 3.0 :: Referring To Nested Sprites
Jun 3, 2011
What I am basically trying to do is Like,the yellow boxes are dynamically made,with Actionscript Code: new Sprite(); inside that red and blue are also made with new sprite(); with instance names yellow1(red1,blue10),yellow2(red2,blue2) etc... How can I refer to yellow1.red1?Like,these are dynamically made,and i dont know the limit,like say it adds on with each click,It will make Actionscript Code: 'yellow'+i and red+i etc... How can I refer to the ith sprite when the user clicks?Suppose the user clicks yellow5,I want a reusable code that will refer to yellow5.red5
View 1 Replies
Similar Posts:
Mar 15, 2009
I must be doing something very stupid here. I have a tab-based menu that has different states for different purposes. I store these states in an Array and have a function I can call when I need the menu to change, which works fine.
But what I cannot at all understand right now is how to access the elements inside the newly create tabs (to add EventListeners for example).
[Code]...
View 4 Replies
Apr 30, 2010
I'm having two problems. First off I'm trying to remove container0 on roll out, but I can't remove it from the outView function because it doesn't recognize it.
Second these functions load another image on top of the thumb0 and it disappears right away. I don't know why and I'm trying to stop it from loading 2 instances
var container0:Sprite;
var loader0:Loader;
var boolean0:Boolean = false;
[code].....
View 2 Replies
Apr 12, 2011
I have a nested movieclip, which I shall refer to as Menu.a.b This is passed to a MouseEvent function using e.currentTarget
I now need to run a command (indexOf) on Menu.a, however only have Menu.a.b saved. How can I refer to Menu.a as a function of Menu.a.b
I've tried Menu.a.b.parent, and that hasn't seemed to work, nor has a few other attempts involving the MC function.
View 2 Replies
Dec 21, 2006
This is my problem: I've got a couple of movieclips, when I click on them I want them to open the URL that I've typed in my XML-file.(The photos are thumbnails stored inside of the movieclips)Here's my XML:
Code:
<?xml version="1.0"?>
<select name="photos">
<option photo="film14" url =">[code]....
How do I refer to the url-code in the actionsscript?
View 4 Replies
Feb 20, 2010
Now that I've set labels, I'm trying to create actionscript code to go to the labels. Here's an example of my code:
btn_me.addEventListener(MouseEvent.CLICK, gotome);
function gotome(event:MouseEvent):void{ gotoAndPlay(me);}
This code has been borrowed from the online video - Getting Started 18: Building an Application. Of course, in that video explicit frame numbers are used so the code looks like gotoAndPlay(15). I'd prefer to use labels for obvious reasons. My question - how do I tell Flash that 'me' is a label? I expect I need to use a special character and I've already tried gotoAndPlay(#me) but that gives me a Syntax error.
View 3 Replies
Nov 23, 2009
i need to refere to a whole bunch of mc named a1, a2, a3, a4, a5 and var who:MovieClip="a"+3 dosnt work...
ActionScript Code:
import gs.TweenLite;
stop()[code].............
View 1 Replies
Apr 12, 2010
I have a small Flash file where I control a ball.In ActionScript 2.0, I have it to where this ball moves around based on input from the Arrows on the keyboard. It also bounces off the edges.I added a new separate ball (not the same symbol) and I want to refer to the NEW ball's X and Y coordinates to see if I am running into the new ball. How do I refer to the other ball's (or any other object for that matter's) properties from within the ActionScript of the first object?
View 2 Replies
Apr 17, 2003
say i have this code: blah = "123 + i" so blah is a variable right? so how would i refer to this variable? i want to be able to do: _root.blah.onPress = function () but this won't work beause you need an instance name instead, so how would you do this? thx, i hope you understood what i was saying
View 9 Replies
Feb 7, 2006
Code:
var l = 2;
duplicateMovieClip(button, "button"+l, this.getNextHighestDepth());
[code].....
View 4 Replies
Mar 31, 2006
im trying to, to make my MC have a rollover effect but my movie clip had been added by Action Script so this doesnt work
[Code]...
View 5 Replies
Jan 29, 2008
How do you refer to the level one below the current level . I know _root refers to the bottom level, parent refers to one level above but I don't know what to use for one level below. Otherwise, is there a way to refer to a level by its name?
For my needs, I have a clip portfolio.swf that is loaded into a Base flash file. Within portfolio, is a loaded movie called Gallery.swf. Gallery contains a movieclip called Thumbnails which has buttons to load various image.swf files. Also within Gallery is an empty movieclip called "ContainerMC" which is where image.swf are loaded into when called upon by the thumbnail buttons. From within Thumbnails, I want to be able to refer to that movieclip "ContainerMC" which those selected image.swf files are loaded into. I can't use _root as that will refer to the base flash file. I can't use "this" as that refers to the Gallery file.
View 2 Replies
Mar 15, 2009
I have created a loop to add my clips by class and give them a name
tempClip = new clientsThumbs[i]();
tempClip.x = xPos;
tempClip.y = yPos;
[Code]....
How do I reference my instances by name
View 1 Replies
Jul 23, 2009
I'm trying to access an instance by using a variable but when I try to manipulate a property to the instance (by referring to it with a variable) it only recognizes it as a string... for instance... (pun intended??)
public var prevbutton:String = "btn1";
trace(["page"+prevbutton]);
// which traces - pagebtn1
trace(pagebtn1);
// which traces the instance class - [object btn1pageclass]
I want to call the instance by using a variable... how do I do this?
View 11 Replies
Mar 4, 2010
I have an object that I add movieclips into when a user does something.
I'm trying to loop through the items in this object later and perform something when object.objectName = something, however I'm finding it hard to get the right code to use in place of the something.
code within a function that adds movieclip to object:
Code:
if (thisHImage==1) {
healthArray[healthIndex] = new mcCake();
}
[Code]...
when i trace(healthO.objectName) i get [object mcCake], but it won't enter the if statement,
View 2 Replies
Jul 8, 2009
I have a button located in a movieclip which I want in its overstate to gotoAndStop a particular labeled frame located in a different movieclip. How do I go to a frame of "movieclip A" by interacting with an element of "movieclip B"? Must I sever the relationship between the button and the movieclip its in which I wouldn't want to do...?
View 3 Replies
Oct 12, 2010
I have a button nested in a moveiclip within a larger flash file. I'm trying to have the button launch another swf file in a UILoader that is nested in the parent of this movieclipI thought that the following code would work to refer to a UILoader in a parent movieclip, but it didn't
archGallery.addEventListener(MouseEvent.CLICK, goArch)
function goArch(e:MouseEvent):void {
loadWindow.(this.parent).source = "archGlider.swf"
[code].....
View 5 Replies
Oct 6, 2009
still cant get my head around this..iv created balls inside a function is there a way to reference them out side of the function? with addChild() do they get instance names?
ActionScript Code:
makeBalls();
function makeBalls() {
for (var i:int=0; i<10; i++) {[code]...........
View 1 Replies
Jan 21, 2010
've been trying to figure out how to refer to the stage from a Sprite before it is added to the stage.
I'm working on a small program in which I plan to use external classes for each "window" that comes up. I've made the window classes extensions of Sprite. I'd like to make this window add itself to the stage when its constructor is called, and then just remove it from the window class when I'm finished with it. Is this a good idea? I'll post some of my code to show you what I mean.
This code doesn't work. I get the error "type was not found or was not a compile-time constant: Stage"
From my window class:
ActionScript Code:
public class PlayerSelectionWindow extends Sprite{
var stg:Stage;
[Code]....
View 2 Replies
Dec 6, 2010
The constructor class has the following code:
Code:
//Phase 2: Parse XML Data
internal var xmlParse:ParseXMLData;
[Code]....
View 7 Replies
Jan 26, 2006
I'm using a little flashmovie as a button on a website, and I'm trying to link it to not only a certain page but also a specific place on that page. Right now I'm using the following code:
getURL("SS-nieuws-flash.htm#opendagen", "_self");
This only gets me to the right page, but not the right place on that page. Can this be done in Flash. I haven't been able to find any examples of it in the manual or on the web.
View 1 Replies
Oct 27, 2006
altering values of movie clips (couldnt think of another way to put it)say i need to change the _x of movie clip ##_mc
# being variables
i would normally use:
tellTarget ("_root."+A+B+"_mc")
{
_x++;
}
since the i cant just say _root.G5_mc._x++; cuz i dont know if its G5_mc or G4_mc (follow? im horrible at explaining things!)is there any other way of doing this? or do i have to use tellTarget?
i tried:
"_root."+A+B+"_mc._x" += 1;
but it didnt like that too much
View 5 Replies
Feb 5, 2009
I have found a tutorial which shows me how to create a class. It also shows me how to construct an object in the main code. What I want to do is to access a variable from the object that I made. Heres the code...This is the link to the tutorial:http:[url]....
Code:
package
{
public class Car [code]....
Then I use this code to construct the object, which in this case is a car (the code is in my main flash file):
Code:
var mycar:Car = new Car("Porche", 3.2, 4, "Normal doors");
I understand all of the code, but how do I reference a variable like the engine? I have tried lots of things like "trace(this[mycar] .engine)", "trace(mycar.engine) but nothing seems so work. I just get error messages of property undefined.
View 4 Replies
Jan 14, 2009
I have a movieclip on the stage in which I have some 90 movieclips also on the stage.
I created an array to hold the movieclips. But when I try to add eventlisteners to these movieclips by cycling through the array, I get a 1009 error ("Could not parse the XML. Error #1009: Cannot access a property or method of a null object reference.") Oddly, however, the application seems to work correctly, handling my listener events.
On the other hand, if I add eventlisteners for each movieclip individually, all works fine--no errors are thrown.
View 4 Replies
Mar 2, 2010
I just started "coding" in AS3. By "coding", I actually mean trying around with features and generally trying to grasp the vast amount stuff you can do with this software of. I have some coding experience, however the way Flash likes to hide code snippets all over my project does tend to confuse me. Not knowing where I tried putting the code and/or rewrote some other stuff keeps me sorta busy.
Anyway, my issue is this:
Messing around with movieclips inside movieclips, I've keep encountering the error "1120: Access of undefined property onTimerComplete." I do realize that this error generally is caused by not having defined an instance correctly or not having it defined at all - an error beginners tend to make. Nonetheless, I'm not trying to refer to an instance/symbol, I am trying to call a function defined on the stage from within a movieclip that also is placed on the stage.
I've been reading huge amounts of text/articles and how-to 's, but they all seem to only touch the subject lightly or simply going in head-first - becoming far too complicated for me (a beginner) to grasp.
So, trying to sum my questions up into something that looks like a tl;dr:
- What's up with levels, "_root" and referring to functions like in the older versions of flash?
Flash tells me to use some display-package instead of _root, when I use that... (I do realize the article is from Flash 5.0)
- How do you refer to a function defined on the stage, from inside a movieclip? (The function is a timer, that is supposed to make the mother-movieclip continue to the next child-movieclip.)
View 7 Replies
Nov 1, 2010
I'm using Flash Develop. Creating a new project creates a Main.as class. How do I refer to the instance of that class from a different file?
View 2 Replies
May 31, 2011
I have four buttons named button1, button2, button3 and button4. I want the code to trace the name of the button when the button is clicked. This is just an eample of what I'm doing in my project. The project itself is too convoluted to put up and explain. My problem that needs to be solved is, how do I refer to the button in the Function?
var c:int;
var buttonName:String;
for (c = 1;c < 5;c++) {
buttonNum = "button"+c;
[Code]....
When I say "trace(this)", the code doesn't know what "this" is because I've taken this[buttonNum] out of the loop by having to put it in a Function. How do I call to the object that is in the listener that called the Function?
View 8 Replies
Sep 7, 2009
I'm developing a flex application and I want to access a component by using it's id.
I know I must use .property of the component. The problem is I have the component Id in a String var and now I don't know how to access to it's properties.
View 2 Replies
Feb 20, 2009
I'm fairly new to AS3 and CS4, and I'm trying to figure out how to write code that isn't needlessly repetitive. I'm not sure exactly how to streamline it, or if that's possible in my case. My issue in particular is with buttons. I have 40 buttons that perform the same function with a single variable, so I'd like to figure out if I can accomplish that without writing 40 separate functions.This is the current version: http:[url]......Here's the full code, with the relevant part in the last commented section:
Code: Select all// Library button opens library
libraryButton.buttonMode = true;
libraryButton.addEventListener([code].......
It seems that something like that might work, but I don't know how to go about setting my variables up in an array or otherwise putting them in a state where an incremental statement could refer to them.The bigger issue, though, is whether I need to make a separate function for each button.Each button will do the same thing, just with one variable.When the user clicks a button, I want it to perform a function that will update text fields with text pulled from XMLList variables.Each button is given a unique identifier that corresponds to an index in the XMLList.So clicking the button just needs to establish that identifier as a variable n, so that the function can, for example, update the titleText text field with the text contained at titleList[n].
For the purposes of this example, let's just say that I want the mgInteraction function to trace the identifier (name, array index, or whatever) of the clip that's being interacted with (mg0/mg1/mg2/mg3). Is there a way to set this up to work with a single function, or do I need to create 40 unique functions, one for each button?The flash, if need be, is here:
http:[url].......
View 1 Replies
Jun 8, 2009
I have a simple question regarding the objects that are on stage. If you make a symbol in the Flash editor, export it for actionscript and put it on the stage, how can you refer to it in an external .as file which contains the document class? I tried using getChildAt() but that returns a displayobject, and I want to modify properties of that instance of the class of that symbol.
I need this because I am trying to make a scrollpane that adapts it's size to the screen resolution, and it's source is a MovieClip that isn't on stage but in the library. I also want the source to adapt it's width and height to the screen resolution. Is this possible? For this to work I need to refer to that source MovieClip in my as3 file, and I can't figure out how to do that...(in this situation it isn't even on stage but I guess I could make it invisible and put it on the stage if nessecary)
View 1 Replies