ActionScript 2.0 :: Referencing Dynamically Created Variables?
Dec 9, 2006
I have a number of 'TweenField' instances created in a for loop. The problem is that each time the loop increments, the 'myTweenField' variable has the same name, so I don't know how they can be referenced individually from elsewhere in the script. How can I rewrite it so that each instance has a unique name, and how would I then reference it from outside the loop?
Code:
package
{
[code].....
View 11 Replies
Similar Posts:
Jan 10, 2010
here is a snippet of code in first frame of the movie I have trouble with:
----------------
for (var i = 0; i < 5; i++) {
var container:MovieClip = new MovieClip();
this.addChild(container);
[Code]....
I am getting an error message: A term is undefined and has no properties. I checked list of objects and container0.one and it's there but I can not get to container0.one.usecase
View 6 Replies
Jul 17, 2010
I'm using Flash 8.
I've made 18 movies in a for loop. I'm trying to modify a text field in those movies. I am unable to do so in the for loop. Something with my referencing is wrong.
The dynamic text field in each movie is named "eventText".
ActionScript Code:
_root.attachMovie(myData["loadHandler"+x]+"Movie", myData["event"+x], x, {_x:100, _y:100});
_root.myData["event"+x].eventText.text = "test";
If I hardcode the event name for testing purposes, it puts the data in correctly:
ActionScript Code:
_root.houseSale2.eventText.text = "test";
View 4 Replies
May 23, 2008
I am trying to load an image in to a dynamically created movieclip, which is:
_root.mySlider."+stripX2(band[i][0])+i
but I can't seem to reference it. I can load the movie into _root.mySlider, but if I add the dynamic element (stripX2(band[i][0])+i) without quotes it it doesn't load. If I load with quotes i.e.
"_root.mySlider."+stripX2(band[i][0])+i
flash doesn't allow strings in movieClip variables.The code I'm using is belowm, it's the second to last line thats causing the problem:
var loadListener:Object = new Object();
loadListener.onLoadComplete = function(target_mc:MovieClip):Void {
trace(">> target_mc._width: "+target_mc._width);[code]......
View 2 Replies
Feb 16, 2011
I have a contact form in my flash file with name/email/message fields which a user can fill out and then click send, which passes these to a php script which then emails the information that they entered. This works fine when the text inputs are manually placed on the stage and all the information is passed to the php script and emailed to me. I am just updating it so the textinputs are created via AS2 so that I can style them more easily etc. This is fine however when created via script they no longer get passed to my php file. I am creating the textinput using the following code (which works fine):
var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = false;
my_fmt.font = "Arial";
[Code]....
This works fine however does not pick up the value of the dynamically created text input (however does pick up all the text inputs that are manually added to the stage).
View 5 Replies
Feb 16, 2011
I have a contact form in my flash file with name/email/message fields which a user can fill out and then click send, which passes these to a php script which then emails the information that they entered. This works fine when the text inputs are manually placed on the stage and all the information is passed to the php script and emailed to me. I am just updating it so the textinputs are created via AS2 so that I can style them more easily etc. This is fine however when created via script they no longer get passed to my php file. I am creating the textinput using the following code (which works fine):
[Code]...
This works fine however does not pick up the value of the dynamically created text input (however does pick up all the text inputs that are manually added to the stage). I am rather confused as to why it's not picking this up and am not sure how I set it to do so, i would be immensely grateful if someone could point me in the right direction?
View 1 Replies
Apr 27, 2010
I'm having a problem while assigning variables into dynamically-created MovieClips. Here's a pseudo-code of what I'm trying to achieve.
[Code]....
I need the movie clips to contain their index values as a variable within them. I've tried several approaches, including declaring the variable names within the MC itself, but that doesn't work either.
View 2 Replies
Feb 17, 2010
I'm dynamically creating movieclips with dynamically created movieclips inside them and am having trouble with targeting them.Below is a simplified example of what I'm trying to achieve, in the real file there are a lot more movieclips and I'm creating and naming them with a for loop.
This one is just one Sprite created inside another sprite. I can target the top level sprite named "testname". However when i try target the nested MC it throws an error.The bottom couple of traces are just test MCs I've made to make sure i got the syntax right, on targeting nested movieclips.
PHP Code:
var holder:Sprite = new test1();holder.name = "testname";this.addChild(holder);var holder2:Sprite = new test2();holder2.name = "testname2";holder.addChild(holder2);trace(getChildByName("testname").x); //this one traces finetrace(getChildByName("testname").getChildByName("testname2").x);//this throws up an errortrace(testclip1.x);trace(testclip1.testclip2.x);
View 1 Replies
Nov 11, 2010
I am creating a loop which loadsimages to newly created loaders.After each loader completes, I'd like to pass it through another function.[code]It seems like if the above function was my complete_handler but in the place of loader_names[k] would be the completed loader.
View 5 Replies
Nov 11, 2010
I am creating a loop which loadsimages to newly created loaders. After each loader completes, I'd like to pass it through another function Here's my loop of loaders where loader_names is an array of my loader names and overlay_files is an array of my file URLs
for (var j:int = 0; j < loader_names.length; j++) {
loader_names[j] = new Loader();
loader_names[j].contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader_names[j].load(new URLRequest(overlay_files[j]));
}
Once each image loads I want to overlay the image on a map here's a loop which does just that, only I do not know how to pass loaders into this function as they finish
function create_overlays(e:Event):void {
for (var k:int = 0; k < loader_names.length; k++) {
overlay_names[k] = new GroundOverlay(loader_names[k],
new LatLngBounds(new LatLng(46.669, -115.035), new LatLng(48.995,-112.079)));
}
}
View 1 Replies
Jun 8, 2007
I have a situation where I create many instances of an MC, one for each node in an XML file (using a for loop), using attachMovie.
Code:
var photo_mc = _root.center_mc.photosLevel1_mc.attachMovie("photoFrame_mc", photoName, itemCount);
[code].....
View 7 Replies
Oct 14, 2009
wrote a couple of small games using AS 2.0. One of the things I found easiest about AS 2.0 is that a MovieClip created using _root. attachMovieClip() inside of one function was accessible to every other function. For instance:
Code:
function AddClip() {
TheClip = _root.attachMovie("Object", "TheClip"+ClipCount, _root.getNextHighestDepth(), {_x:30, _y:30})
}[code]....
This causes an error, because the MovieClip variable was declared inside of a function and when the function ended, the MovieClip variable was erased. Is there any way of doing this without declaring the MovieClip variable outside of the function? I want to be able to create an unknown amount of these movieclips on the fly, so I can't just declare them outside of the function.
View 9 Replies
Jun 16, 2011
I am completely new to actionscript although I do come from a OOP background. I have been asked to trial Flash and Actionscript 3 in particular - so I do come with a few preconceptions on how I expect actionscript to behave. I have a problem I donot understand. I have created a new class and to test it I use a simple test harness in the form of a .fla file.
The issue I have is when I create a new instance of the class and assign it to a variable, subsequent background changes to that instance of the class are not 'picked-up' when referenced through the variable. I would expect that given instance of class could be assigned to many different variables and any updates using one variable would accessible using any of the other variables.
[code]...
View 1 Replies
Dec 7, 2010
I am adding a bunch of MC's(linkage ID:buttonHolder) dynamically using a for loop and attachMovie. If I want to dynamically add an onRelease function to each of those MCs,so that each of them links to different links how would I accomplish that? here's where i've reached so far..
var depth:Number=0;
var nextY:Number=77;
for (i=0; i<5; i++)
[Code].....
View 1 Replies
May 18, 2009
Essentially, I've got a MC container that's created dynamically based off an XML file (basically for every <title></title> I've got, it makes a new "card"). Now within the context of each <title></title> grouping I've got <imgs></imgs> in which I specify the path to images that are related.All of that works perfectly, save for the external jpg files actually appearing on the stage. The MC I add them to does, but the external image doesn't.My problem is- I can't add the external images until they're completely loaded (or so it appears). The thumbnail BG I use is blank. So I know for a fact that the thumbnail BG isn't occluding the loaded thumbnails.
View 2 Replies
Aug 3, 2009
I am having trouble dynamically changing the reference to root in my movies. Here's what I'm trying to do: I have a main movie(_level0.mainMovie) that I am loading external .swfs into. However, I want to be able to test the child movie clips without having to load them into the mainMovie(for testing purposes). In such a case, the child clip would be at _level0 or _root. I would like to add some code to the child clips to test whether they are the _level0 clip, if not, then I want to change their reference to _root. Here's what I've come up with, which doesn't seem to work:
Code:
function testLevel(){
//This code goes into each child clip to see if it has been loaded into another clip
trace(this);
if(this == _level0){ //If this is the _level0 clip
[code]....
View 4 Replies
May 3, 2011
I have a bunch of variables in a class. There are situations when I want to set then to null/ "temp" etc as per a well defined logic. The challenge is to list out the variables at multiple places- tedious and error-prone.
classname.speed=NaN
classname.speedtype="not_set"
classname.distance=NaN
classname.distancetype="not_set"
would prefer a way to refer to these variables programatically and set something like "for all class variables- if variable ends in type, set as "not_set"; for other variables set as NaN How can I achieve this?
View 2 Replies
Nov 28, 2011
I'd like to know how I can achieve this in AS3. The code would work fine in AS2, but as I am very new to AS3 I am not sure what the equivalent would be in AS3.
code:
humanNum = 1;
MC = ["Human"+humanNum];
[code].....
View 1 Replies
Jun 12, 2009
I want to reference clip with some variable name because i want to change dynamicaly target clip. Example:
myMC="testClip";
myMC.my_txt="some text";//this doesn't work
//but this works
eval(myMC).my_txt="some text";
I guess eval() is not right thing to do.
View 4 Replies
Mar 15, 2012
I am having trouble referencing a MovieClip based on certain variables in my code. I am using Flash Player 9 as the player setting and ActionScript 3.
I have a symbol with a name "Check1" set as a MovieClip, exported for ActionScript, I have ten of these on the stage with an Instance Name of ch0, ch1, ch2...ch9.
Each ch? has 21 frames on the timeline, each with a label name (named with a Number reference "00", "32", etc...) and a different image in each keyframe.
What I would like to do based on these variables:
Code:
iTurn = 1;
iLeft = 3;
iRight = 2;
This is how I would like to use it:
Code:
Check1.ch[iTurn].gotoAndStop(iLeft+iRight);
//iLeft & iRight as a frame label and not a frame number, so in the case I would like to access framelabel "32" which is frame 10 on the timeline.
I have tried many way to try and make this work with no luck, the only way I have been able to make it work is by using:
Code:
ch1.gotoAndStop("32");
Doing this, I would have 10 clips, each with 21 possibilities. I can do this with many lines of code but I have been unable to tighten it into smaller code.
View 5 Replies
Sep 22, 2003
I'm having trouble referencing variables in a loaded movie. I read in other posts that you simply refer to the variable as if it belongs to the clip you load it into, however this doesn't seem to be working for me
View 2 Replies
Dec 5, 2011
Hey guys. It's been a while since I've used Flash and I am still trying to wrap my head around Actionscript 3.0 and the way it works; I am so used to the way AS2 works.I have provided the code below, it's very simple, so you might be able to skip this explanation and just take a look at the error and the code:
- I have made a movieclip called HeroMC in my FLA.
- The HeroMC movieclip has the AS Class linkage of exactly the same name, "HeroMC".
- I have made an actionscript class file, HeroMC.as, to house specific variables for my hero; such as Name, Age, xPos and yPos.
- I have also made an actionscript class file, Main.as, the document class for this FLA.
- In Main.as I instantiate HeroMC using the variable hero, and then run the function addHero() from my constructor.
- addHero() is a simple stage.addChild(hero);
This all works perfectly fine and it adds my hero to the stage. However, the problem arises whenever I try to reference one of the variables from HeroMC.as. I am met with this error - I will use the variable xPos as an example.
Here is the error:
1119: Access of possibly undefined property xPos through a reference with static type HeroMC.
Here is the code for Main.as:
Code:
package {
import flash.display.*;
import flash.events.*;
[code]....
It is obvious this is a very simple problem, but I have searched Google, Kirupa and Flashkit for an answer, but none of the threads I find discuss my specific circumstances and I am unable to find the specific information I need to.
View 3 Replies
Jan 20, 2011
Just wondering, is there any way to dynamically reference movieclips on the stage, as in through a for loop like so:
for (var i = 0; i < 10; i++) {
["mc" + i].x = 10;
}
[code]........
View 3 Replies
Dec 1, 2010
I am trying to display in 'Reciever.swf' the value a shared object updated in 'TextSO.swf'. The following is my code for the Reciever
Reciever.as-----------------
package {
import flash.events.SyncEvent; import flash.events.NetStatusEvent; import flash.events.MouseEvent; import flash.net.SharedObject; import
[Code]....
I am getting an error that says that 'text_so' is an undefined property and that I can't access it. Yes, I have not declared 'text_so' in 'Reciever.as'. However it is the shared object instance from the 'Text_SO.as' file. How do I reference it from the 'Reciever.as' so that I won't get this error anymore?
View 1 Replies
Oct 27, 2009
Got some external classes, say MyClass.as MyClass.as has a static variable called foo
So, ordinarily in other AS files I can call this with MyClass.foo = bar;
However, this seems to be different in timeline scripts. Every time I try this I get the reference with a static type error 1119: Access of possibly undefined property foo through a reference with static type flash.display:DisplayObjectContainer.
I've tried doing an import MyClass, etc... nothing seems to be firing.
View 1 Replies
Dec 1, 2010
I am trying to display in 'Reciever.swf' the value a shared object updated in 'TextSO.swf' . The following is my code for the Reciever[code].,...
I am getting an error that says that 'text_so' is an undefined property and that I can't access it. Yes, I have not declared 'text_so' in 'Reciever.as'. However it is the shared object instance from the 'Text_SO.as' file. How do I reference it from the 'Reciever.as' so that I won't get this error anymore?
View 4 Replies
Aug 16, 2010
I'd like to add a couple of different MC's to the particle stream. I'd like to do that by referencing different items in the library.So I have 12 different particles in the library exported with classes named from Bubble0 to Bubble10 now as I run through my for loop I'd like it to use a different particle each time. first time I tried:
ActionScript Code:
var bubbleArray:Array = new Array();
bubbleArray.push(Bubble0,Bubble1,Bubble2,Bubble3,Bubble4,Bubble5,Bubble6,Bubble7,Bubble8,Bubble9,Bubble10,Bubble11)
for (var j:uint = 0; j < NUMBER_OF_BUBBLES; j++) {
[code]...
Scene 1, Layer 'actions', Frame 1, Line 871086: Syntax error: expecting semicolon before leftbracket.Is what I'm trying to do possible without some clunky switch statement?
P.S. I tried searching the forum for an answer but the terms are so common I couldn't find what I'm looking for.
View 6 Replies
Jul 12, 2009
The problem is referencing object names dynamically in AS3, in a loop. Example. I have an array called c4 which i would like to reference like this:
I have a number
var x:Number = 4
How can I do something like
trace(["c"+x].length);
(I know this is wrong!)
Same with other objects
E.g. Movieclip called mc4
["mc"+x].x = 100;
View 3 Replies
Jan 13, 2005
I am trying to select an object and use its path as a varible in flash.[code]The 1st trace command yields the full path, but the second trace command yields an "undefined". This problem seems to exist all over, if I use the variable from selected_objcet = this for any thing it does not work unless I but "" around it - this of course, does not solve the problem.Another way to point out the problem, if I do a comparison check in flash with the variable created from "this" I get:[code]
View 10 Replies
Feb 9, 2009
The following creates movieclips from XML. Everything worksgreat.One problem however. I need each MC to have it's own mouse event listener anddon't know how to achieve this because I don't have specificinstance names to refer with. I want to update textfields etc, with specific data when a
View 3 Replies