Access Array Of Objects
I need to fill an array with objects, access the information stored in the array and use it to duplicate a movie clip. I am an avid programmer new to actionscript so any tips and pointers are welcome.
Here I am attempting to fill the array array_Calendar (initialized as: var array_Calendar:Array;) with DateCell objects.
code: for (var dateNum = 0; dateNum < 42; dateNum++) { array_Calendar[dateNum] = new DateCell(dateNum); }
This is the DateCell class:
code: class DateCell { var dateCell; var dayNumber; var eventText; var eventList;
function DateCell(dateNum) { dateCell = (typeof dateNum == "number") ? "calendarDate" + dateNum + "_mc" : ""; dayNumber = (typeof dateNum == "number") ? "_root.calendarDate" + dateNum + "_mc.dayNum.text" : ""; eventText = (typeof dateNum == "number") ? new Array("_root.calendarDate" + dateNum + "_mc.eventText0_mc.eventText_dt.text", "_root.calendarDate" + dateNum + "_mc.eventText1_mc.eventText_dt.text", "_root.calendarDate" + dateNum + "_mc.eventText2_mc.eventText_dt.text") : ""; eventList = new Array(); } }
This is the line I'm trying to use to duplicate the movie clip:
code: duplicateMovieClip("calendarDate_mc", array_Calendar[day].dateCell, day);
After the loop that is supposed to fill the array with DateCell objects I used the trace function to see if the array was indeed filled with objects. Trace returns "undefined", so either I'm not using the trace function correctly (I used it like so: trace (array_Calendar[day].dateCell);) or the array isn't getting filled correctly. I'm guessing it's the latter of the two.
I need to fill an array with objects, access the information stored in the array and use it to duplicate a movie clip.
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-27-2004, 05:49 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[f8] Array Access Notation To Access A MC Within A MC?
Hi,
can one access the contents of a movieclip - that contains another mc - using Array Access notation??
I am loading a bunch of similar (ie, based on the same template) external swfs individually on level0 on the main timeline. because there are many swfs, i want to control the button/mcs in those external swfs from the main timeline. i have a different number of buttons in each swf, and each button goes to a different label. so i am trying to figure how to dettermine the name of the loaded swf, in order to get to the buttons inside that swf...
I was thinking to name each label the same name as the corresponding button object name. and each button/label name be derived from the name of the containing swf... I could put the name of the swf in a variable, and use it as a gotoAndStop() argument...,
i can provide code, but i'm lost and it's gotten messy...
Any ideas GReatly appreciated.
Store And Retrieve Array Of Custom Class Objects From Shared Objects.
Hi,
I am stuck up with a problem in ActionScript 2. I am using Flash MX 2004 on windows XP.
I have created 3 custom classes say Parent, Child, and GrandChild. Parent class contains in it an array of its Child objects. Similarly each Child object contains in it an array of GrandChild objects. Also I do have one global array of all the Parent objects.
I want to store this array to the shared objects on specific events(say exiting the session) and then reload them from the shared object(on next session startup). I am able to store the global array to the shared object but when I try to retrieve the same array from shared object, I could not do it. The retrieved array is not of my custom class type [Parent].
Help needed to solve this problem urgently. Does anybody have idea how to do it??
Thanks in advance.
Cheers,
Naishadh Sevalia
Access Objects?
this is an object created in main timeline, the problem I have is that this info is stored in memory and read only once it seems. How do I access it from a movieclip and change x and y positions???
Anyone got any ideas
brk1 = {};
brk1.clip = this.brick1;
brk1.x = brick1x;//brk1.clip._x;
brk1.y = brk1.clip._y;
brk1.radius = brk1.clip._width/2;
brk1.mass = 100000000;
brk1.bounce = 10;
brk1.xmov = 0;
brk1.ymov = 0;
trace(brick1x)
How To Access Objects Via A String?
For example, in the Flash IDE I have a bunch of textFields (dynamic text) named txt_01, txt_02, txt_03, ....
how to change all the textFields' certain attributes to a same value?
I remember in AS2 I can do something like this:
PHP Code:
for (var i:int = 1;i<=10;i++)
{
var s:String;
if (i<10)
s = "0" + String(i);
else
s = String(i);
var combined:String = "txt" + "_" + s; // "txt_02"
//trace(combined);
root[combined].setTextFormat(format); // <--- won't work in AS3 anymore
}
but this doensn't seem to work in AS3 anymore. Any hints?
Access Class Objects
If i have a parent item that initializes the custom class ObjectTimer. and within ObjectTimer i define an object in the class body with:
ActionScript Code:
public var CloseAPrimary:Object={scaleX:.5,scaleY:.5,time:1,transition:"easeOutElastic", _blur_blurX:100, _blur_blurY:100};
how dould i access a CloseAPrimary in the parent item? I'd like to pass that object to a custom function similar to.
so like foo(CloseAPrimary);
Access Objects From A External .swf
Hey i loaded a flash mx movie into a flash 8 movie, and now i need to detect if a button of the loaded movie is pressed but i simply dont know how.
i used:
var news_mcl:MovieClipLoader = new MovieClipLoader();
news_mcl.loadClip("source.swf", newscontainer_mc);
to load the movie, and i have a movieclip inside it with the instance name "read", and i need the code to put in the parent movie (the flash 8 one) to detect a onRelease on that "read" movieclip.
Access Objects From A External .swf
Access Objects from a external .swf
Hey i loaded a flash mx movie into a flash 8 movie, and now i need to detect if a button of the loaded movie is pressed but i simply dont know how.
i used:
Code:
var news_mcl:MovieClipLoader = new MovieClipLoader();
news_mcl.loadClip("source.swf", newscontainer_mc);
to load the movie, and i have a movieclip inside it with the instance name "read", and i need the code to put in the parent movie (the flash 8 one) to detect a onRelease on that "read" movieclip.
Access All Objects In Scene.
Hi Everyone,
I've got some textfields in my Flash document. Some created at authoring time, while a few others created dynamically at runtime.
What I'd like to do is to go through all the items on the stage. Check if it's a textfield. If so then modify a property (such as colour or text).
This is my algorithm...
for all objects in the scene {
check if it's an instance of the textfield class {
change property
}
}
I was wandering if it's possible to write a for loop which can access all the objects in a scene?
Thanks in advance.
How Do You Access Shared Objects From Other Swfs
Hi -although this is about the 4th time i have posted a query on here and no doubt will also get no replies, i thought i may as well try
i have made an swf that sets up a shared object on the user's computer. How can I read/change this data from another swf?
thanks if anyone bothers to answer me i would appreciate it
How To Access Objects Dynamically Created With AttachMovie?
hello,
i have written some code that create multiple objects from a loop(they're called "Groupe" in my library).
PHP Code:
for(i = 0 ; i < TGroups.length ; i++ ) {
_root.attachMovie("Groupe","Groupe"+i,0);
}
}
how can i access them in my code in order to set their properties?
in this case these objects would have the names Groupe1, Groupe2, etc... is there a way to do it dynamically?
thanx in advance
PeeWeeK
Access Objects Nested In Main Object?
I haven't programmed in a couple of years (AS1) and getting rather rusty! I can read AS2 but never tried coding it.
The following problem occurred when I was cleaning up my OOP code a bit in a working application before eventually learning AS3. Getting access to the properties of objects that are nested in a main object is the issue.
I parsed an XML file and created the following object "folderObj" with the second levels of the XML file as objects appended to it as such:
Variable _level0.folder = "Iris106-images"
Variable _level0.i = 6
Variable _level0.Iris106-images = [object #184, class 'Object'] {
label:"Iris106-images",
subdir:"images/tableSettings/Iris106/",
numChildNodes:6,
Iris106-0:[object #185, class 'Object'] {
secondLevelLabel:"Iris106-0",
thumbName:"Iris106-kit01_tmb.jpg",
imageName:"Iris106-kit01.jpg",
story:,
thumbW:"200",
imageW:"600"
},
Iris106-1:[object #186, class 'Object'] {
secondLevelLabel:"Iris106-1",
thumbName:"Iris106-kit02_tmb.jpg",
imageName:"Iris106-kit02.jpg",
story:,
thumbW:"200",
imageW:"600"
}, ... and so forth for six nested objects.
So I create some clips to load thumb images into but I'm including only the first part of the function where the problem is:
createClips = function (folderObj) {
numChildNodes = this[folderObj].numChildNodes
for (var i=0; i < numChildNodes; i++) {
// Create the name of the secondLevel for sorting the folderObj.
Here's the problem -- var nameSecondLevel = this[folderObj].????.secondLevelLabel
Any idea how I can access properties inside that nested object?? I tried to append the objects to a property of the main object but that didn't seem to work.
I've been working on this for a few days and did lots of searches but found no help. I would deeply appreciate a jump start on this. I've found that I'm remembering more than I expected, but not everything of course.
- jim
How To Access Thru Actionscript To Objects That Belong To Other Frames?
Hi,
I'm trying to do something very simple without sucess.
i'm declaring a movieclip named resultsArea in the second frame of the movie and i want to access it via code from the first frame.
How can i do that? I can do this if the code and the object are the two in the same frame, but not in differrent frames...
Whats the problem?
Thx,
Nuno
Access Properties Of Objects In A DisplayObject Container
Hi all,
i was wondering :
lets say we have a displayObject container which holds several children movieClips. How would one access the properties of one of its children IF the children are dynamically created using a for loop ? Ive been looking for this for a while, and im quite sure there's a simple solution for it, but i cannot find it. Ive tried setting the .name property of the children but to no good. Anyone who can point me into the right direction ?
ActionScript Code:
var container:Sprite = new Sprite();
var testmc:MovieClip = new MovieClip();
container.addChild(testmc);
addChild(container);
trace(container);
trace(container.testmc);
trace(container.testmc);
when i test this out quickly, the trace of the container returns the correct object, but the testmc, which is a child of container returns undefined ?
i think i have a totally wrong idea about the displayObject concept so if anyone could "enlighten" me that would be fantastic !
thanks a lot
Juan
Access Display Objects From Within Scrollpane Instance?
Hi all,
I've seen several posting on various sites with this question but never found an answer that actually works.
Very simply, I create an instance of a scrollpane on my stage and I load in a mc from my library that has another mc nested within. I want to access that nested mc and I don't seem to be able to:
Code:
import flash.display.MovieClip;
import fl.containers.ScrollPane;
//MyBox is the class name of the mc in my library
var myMovieClip:MyBox = new MyBox();
//
var myScrollPane:ScrollPane = new ScrollPane();
myScrollPane.name = "myScrollPane";
myScrollPane.source = myMovieClip;
addChild(myScrollPane);
trace(myScrollPane.content.nested_mc.alpha)
When I run this I get the following error:
1119: Access of possibly undefined property nested_mc through a reference with static type flash.displayisplayObject.
I've tried to access the nested_mc by using the content property as I've seen noted in one post on actionscript.org like this:
Code:
trace(MovieClip(myScrollPane.content.nested_mc).alpha)
but I get the same error...
What gives? What is the best way to access content within the scrollpane component?
Any advice is greatly appreciated!
Read/Access Objects From External SWF Files
I have for weeks been trying to access/read objects from external SWF files without any success.
I load SWF file into my Flex application, but how do I go further to access all objects of that MovieClip?
Is there any way to parse all objects of loaded MovieClip(SWF) in order to read the text?
I basically want to search SWF files as if it was PDF files. FlashPaper2 has this function and its only 1 SWF files so some how it must be possible. I just have no idea where to look or where to start.
I can get the text out of SWF using swfstring or swfdump - but that is almost useless as it cant be used to mark words with "live" search...
SWF example
http://dev.rb.no/pdf2swf.swf
Thank you
Shared Objects, Local And Online Access
All,
Is it possible to create a local shared object from an online swf, then read from that shared object with a local projector file?
I'm building an "occassionally-connected" application; the user should be able to save information they produce while they're online, and then retrieve that information later when they're not connected. Seems like a common thing to do. How does one accomplish this?
Many thanks again for any advice or insight!
Cheers,
Matt Stuehler
Assigning Array Objects To Variables In An Array
how do i take an array with objects [orange, red, yellow, green, blue] and assign them to another array 5 random variables named [Slot1, Slot2, Slot3, Slot4, Slot5]
so i can get results such as
Slot1 = color*
Slot2 = color*
Slot3 = color*
Slot4 = color*
Slot5 = color*
thanks !
How To Use Local Shred Objects To Restrict Access To Frames In Swf
Hi,
I've got a swf containing several frames. However, I dont want the user to be able to access certain pages until they have viewed a selection of other certain pages? Any ideas how I can incoporate this facility using LSO's/Flash cookies?
I was think of creating a variable for each page stored as a LSO somehow, then whenever the user wants to access the frame that can only be accessed once other frames have been viewed, on the buttons that goes to that frame have some code saying that if all those other LSO's are equal to something, only then can this page open.
Any ideas??
Thanks
Access Objects Inside A Loaded Movie From The _root Timeline
I used loadMovie to load head.swf.
ActionScript Code:
loadMovie("head.swf","_root.head_mc");
head.swf has three objects, head0, head1, head2.
I want to change color on all three objects. I tried the following but it did not work.
ActionScript Code:
for(var i = 0; i < 3; i++)
{
objColor = new Color(_level0.head_mc["head"+[i]]);
objColor.setRGB("0xFF0000");
}
I tried to trace and it gave me undefined. I can trace _root.head_mc.
ActionScript Code:
trace(_root.head_mc["head0"]);
Also, In the head.swf, I have a function. If I want to get an object through the function what kind of targeting will I use. I found out I cannot use _root because it goes to the loader.swf. I also tried this._parent but I am getting undefined.
ActionScript Code:
this._parent["head0"]
Thanks in advance for the help,
Shrini
Array How To Access
after initializing an Array we need to add values to them
then access them back. my array[0] but it's difficult on the
real world is it ? we need a little bit description for
can some one do that ? plz some one do as bulid a students and their marks how to intili and Declare and access them if some can ?
Array Access
I've created an array and everytime you click a button it inserts a value at the end. but how can I use the last entry of the array?
I thought I could do something like this:
varTest = mainArray.length
mainArray[varTest]
and this would access the last entry? but it doesnt seem to work
Access Array By Name
Hi,
I need to access array by name. Could anyone suggest how to do it. Accessing Object by name works fine with eval:
Code:
myObject = new Object();
myObject.myVariable = "this is variable";
trace(eval("myObject.myVariable"));
But this is not working:
Code:
myArray = new Array();
myArray[0] = new Object();
myArray[0].myVariable = "this is variable";
trace(eval("myArray[0].myVariable"));
Thanks
Can't Access Array
I have a MovieClip "tableCell_mc" that is added to the stage via AS3. This MovieClip has a few variables that I have declared within it. These variables are as follows:
var tableCellHomeX:int;
var tableCellHomeY:int;
var myChildren:Array = new Array();
stop();
I use these to store unique data to each instance of tableCell_mc.
I can access the tableCellHomeX and tableCellHomeY vars no problem. It's the myChildren:Array that I'm having trouble with. It's an empty array but as I go through my for loop I try to add values to that array like so.
ActionScript Code:
function makeTable(theXMLList:XMLList) {
var theXMLListAttribs:XMLList = theXMLList[0].attributes();
for (var i:int = 0; i < theXMLListAttribs.length(); i++) {
tableHeader = new tableCell_mc();
tableHeader.width = stage.stageWidth / theXMLListAttribs.length();
tableHeader.x = 0;
tableHeader.y = 100;
tableHeader.tableCellHomeX = tableHeader.width * i;
tableHeader.tableCellHomeY = 100;
tableHeader.cellValue_text.text = theXMLListAttribs[i].name();
tableHeader.addEventListener(Event.ADDED_TO_STAGE,slideToRight);
tableHeader.addEventListener(TweenEvent.MOTION_FINISH, dummyFunction);
addChild(tableHeader);
for (var j:int = 0; j < theXMLList.length(); j++) {
var myAttribs:XMLList = theXMLList[j].attributes();
tableHeader.myChildren[j] = String(myAttribs[i]);
}
}
}
I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SpreadSheet_fla::MainTimeline/makeTable()
at SpreadSheet_fla::MainTimeline/frame2()
Help anyone?
Thanks,
Rich
Access To Array
I have duplicated 10 movies and give them different instance names. I also create an array called myArray which hold 10 elements. Now I want it to be like this... when I place the mouse over a movie, says "box1", I want it to show myArray[0]; "box2" shows myArray[1]; and so on.. how can I do that?
i tried..
on(rollOver){
_root.x = 1;
if (this._name == "box1"){
_root.popUp1.popText = explanation[0];
} else {
_root.popUp1.popText = explanation[1];
}
}
but it didn't work. please help.
thank you.
Can't Access Value In Array - Please Help
I have written the following code, and the function called by mcListener.onLoadComplete is returning the current value in the array as "undefined." I want the current image that has finished loading to fade in, but "i" seems to have no meaning within the function. If i replace the [i] with a number, it works fine. I think this is a scope issue but I can't figure it out. Any help is much appreciated.
HTML Code:
var thumbArray:Array = new Array;
var mcListener:Object = new Object;
var photoHolderLoader:MovieClipLoader = new MovieClipLoader;
photoHolderLoader.addListener(mcListener);
function creMenu(){
for (i=0; i<total; i++) {
var smallIm:MovieClip = smallPic.attachMovie("thumb","thumbNail"+i,i);
thumbArray[i] = smallIm;
thumbArray[i]._x = xPos[i];
thumbArray[i]._y = 0;
thumbArray[i]._alpha = 0;
photoHolderLoader.loadClip(image[i], thumbArray[i].inner_mc);
mcListener.onLoadProgress = function(){
trace("LOADING");
};
mcListener.onLoadComplete = function(){
trace(thumbArray[i]);
};
smallIm.picVal = i;
//THUMBS ROLLOVER/RELEASE
thumbArray[i].onRollOver = function(){
this.alphaTo(50,1,"easeOutExpo");
};
thumbArray[i].onRollOut = function(){
this.alphaTo(100,1,"easeOutExpo");
};
thumbArray[i].onRelease = function(){
largePic.workPicMask.scaleTo(100,.5,"easeOutExpo");
smallPic.alphaTo(0,.5,"easeOutExpo");
p = this.picVal;
largePic.picture.loadMovie(large[p], 1);
largePic.desc_txt.text = caption[p];
picture_num();
};
};
}
Access Array By Name
Hi,
I need to access array by name. Could anyone suggest how to do it. Accessing Object by name works fine with eval:
ActionScript Code:
myObject = new Object();
myObject.myVariable = "this is variable";
trace(eval("myObject.myVariable"));
But this is not working:
ActionScript Code:
myArray = new Array();
myArray[0] = new Object();
myArray[0].myVariable = "this is variable";
trace(eval("myArray[0].myVariable"));
Thanks
Dynamic Array Access
Hi,
I'm trying to take a sentence and break it into an array of words (done) then take the words and break them into arrays of letters. I was able to do a sloppy bit of code and make a buch of variable but I'd kinda prefer to do it with arrays cuz it's a whole lot cooler.
anyway here is the mucked up code for the variable generation just so you can see what I was trying to do
on (release) {
words = v_1.split(" ");
for (i=0; i<words.length; i++) {
for (l=0; l<words[i].length; l++) {
set ("word"+i+"["+l+"]", words[i].charAt(l)
);
}
}
}
and here is the array generation code as it stands now
on (release) {
words = v_1.split(" ");
for (i=0; i<words.length; i++) {
set ("word"+i, []
);
for (l=0; l<words[i].length; l++) {
set ("word0"+[l], words[i].charAt(l));
}
}
}
I can create the arrays OK but it's the last line of code where I try to populate them that's not working - where it says "word0"... I had tried "word" + i + [l] and it disregards the [] so it I know there is something I'm doing wrong with the syntax
Thanks to all who give this some thought
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How To Access Array Elements?
hi, i'm currently trying to use arrays for the first time, and i've made a simple array myArray with 50 elements 1, 2, 3... 50. but i encounter a problem that makes me suspect that i don't understand the array concept at all: how can i access the value of an element in the middle of the array?
failed attempt #1: why is trace(myArray[x]) undefined and not simply x?
failed attempt #2: i tried to make a new array with the slicing method (referred to in flash help), like myArray.slice(x,x+1). then i reckoned i could access the element from this new array by the pop or shift method. but where on earth IS this new array, and what's the name of it??
failed attempt #3: an expression like
secondArray=myArray.slice(x);
myVariable=secondArray.shift();
didn't work either.
EXTRA QUESTION (OPTOINAL...) what i'm planning to make is an application that jumps between 50 frames, just one visit in each, in a random order. i will use the array to accomplish this, by deleting one element after each frame is visited, in order to avoid a condition for testing whether a frame has been visited (don't know if this was understandable). am i on the right track by using arrays or is there another/simpler way?
Urgent - Array Access
I can load the variables I need into an array with the following, BUT...outside of the success function, how can I access the array variables?
code: var navVars = new LoadVars();
navVars.load("variables1.txt");
navVars.onLoad = function(success) {
if (success) {
//trace that the variables have loaded
//trace("success")
//trace the type of object you are dealing with
//trace(typeof (this.level1));// string
//split the varibles into their respective arrays
this.navArray1=this.level1.split(":");
this.navArray2=this.level2.split(":");
trace(typeof (this.navArray1));
trace(this.navArray1.length);// 4
trace(this.navArray1[0])
array_length = this.navArray1.length;
for (i=0; i<array_length; i++) {
trace(this.navArray1[i]);
}
}
};
Urgent - Array Access
I can load the variables I need into an array with the following, BUT...outside of the success function, how can I access the array variables?
code: var navVars = new LoadVars();
navVars.load("variables1.txt");
navVars.onLoad = function(success) {
if (success) {
//split the varibles into their respective arrays
this.navArray1=this.level1.split(":");
this.navArray2=this.level2.split(":");
trace(typeof (this.navArray1));
trace(this.navArray1.length);// 4
array_length = this.navArray1.length;
for (i=0; i<array_length; i++) {
trace(this.navArray1[i]);
}
}
};
Strange [] (array Access)
Hi,
Im using Flash MX
i put this line in my script, but it doesn't work:
ii=1;
_parent.imageList.imageMC[ii].gotoAndPlay("down");
The next line does work:
_parent.imageList.imageMC1.gotoAndPlay("down");
The difference is "[ii]" and "1".
Ofcourse i want to use "[ii]", what im i doing wrong?
(I didn't include the rest of the actionscript, because i thinks the problem comes down to what i just told)
XML And Array Access Issues
I'm learning to work with XML files in Flash, and making some headway. But here's an issue I've come up against hard.
I'm dynamically creating buttons on stage based on the number of certain childNodes; then placing text into these button instances. This works fine. However, I have childNode data related to these buttons. When the user clicks a particular button, text fields will be populated with data related to that button.
I've got all the XML data stored in an array, and naturally my buttons are created using an array. I'm sure there's a way to correlate the info from one array to the other, but I just can't seem to puzzle it out.
Can anyone point in the right direction?
Array Access Notation
Im trying to be dynamic here in creating movie clips on the fly with
Code:
var source[inc]:MovieClip = this.createEmptyMovieClip("source"+curX, this.getNextHighestDepth());
inc is incrementing each time to make source0, source1 etc
syntax error though??
How To Access Dynamic Mc In An Array?
Hi,
I'm creating instances of a movieclip in the library dynamically, then i want to animate them (make them drop from the top to bottom). But I can't figure out how to access them in my array.
They are in there, they come up in a trace, but using a loop through them (on enter frame) and trying to change y value doesn't work? I have my array registered at the top of the class, and get no errors..
Code:
// randomly create treasures with timer (WILL MOVE TREASURES WITH TIMER ASWELL)
public function createTreasures(){
var rand:Number = (Math.ceil(Math.random()*2000))
var timer:Timer = new Timer(rand);
timer.addEventListener(TimerEvent.TIMER,timerF);
timer.start();
treasures = new Array();
function timerF(event:TimerEvent):void{
var treasure:MovieClip = new Treasure();
treasure.x = (Math.ceil(Math.random()*800));
treasure.y = 0;
//random treasure type
treasure.type = Math.ceil(Math.random()*5);
treasure.gotoAndStop(treasure.type);
treasure.speedY = Math.random() * 5 + 2;
treasure.inAir = true;
treasure.width = 20.0;
treasure.height = 40.0;
//keep treasures with min/max boudary
if (treasure.x<100){
treasure.x = treasure.x + 100;
}
else if(treasure.x>700){
treasure.x = treasure.x -100;
}
//add to stage
addChild(treasure);
//push into array
treasures.push(treasure);
}
}
//loop through treasures
public function moveTreasures(timeDiff){
for(var i:int=0;i<treasures.length;i++){
// add to treasures y value
treasures[i].y = treasures.y + 100;
}
}
http://www.actionscript.org/forums/i...s/rolleyes.gif
Array Access In An Object
I've encountered another problem.
The following code does not mention that I have a MovieClip in the Library set up with its class as my_class. I drag it onto the stage and name it my_object. When I try to use the my_array property it does not work.
The class includes a boolean property that works fine, so I concluded that my arrays must be discombobulated. I also tested a string property and it works.
Plz help?
Attach Code
/////---------
class my_class extends MovieClip
var my_array:Array;
}
/////---------
//my_object <- is instance of my_class
my_object.my_array[0] = "rasin";
trace(my_object.my_array[0]) // returns undefined. why?
Using An XML /FlashMXPro2k4 To Access An Array
Could someone please explain how to use an XML file and an image array and FlashMXPro2004 to run a slideshow/presentation that uses no buttons but simply starts playing when the user accesses the page? There are 14 images and they just loop.
Thanks for your help
dwilder
How To Access This Array Element
Here's the function :
Code:
var curItem;
function disableAll(){
for (var i=0;i<buttonArray.length;i++){
trace(buttonArray[i])
}
}
Here's the problem/question :
- I want to assign the var curItem into the onRelease function throughout the buttonArray. How?
Array Access Notation In AS3
how to make something like this work
Code:
var i:uint;
for(i=0;i>3;i++){
var test[i]:Sprite = new Sprite();
test[i].graphics.beginFill (0xff000000);
test[i].graphics.drawRoundRect (0, 0, 50, 50, 0, 0);
test[i].graphics.endFill ();
addChild(test[i]);
test[i].y = 55 * i;
};
Code:
1086: Syntax error: expecting semicolon before leftbracket.
var test[i]:Sprite = new Sprite();
Variables With Array Access ?
hello
pretty new to actionscript 3.0 and was wondering why this doesnt work
Code:
var bonkers:Array = new Array(i);
bonkers[0] = new oldie();
bonkers[1] = new chtv();
bonkers[2] = new every();
bonkers[3] = new jerkwtv();
bonkers[4] = new hawtv();
var i:int;
var myTimer:Timer = new Timer(delay, repeat);
var delay:uint = 30000;
var repeat:uint = 6;
//-- MovieClips & Sprites --\
for (i = 0; i < 5; i++);{
addChild(bonkers).name = "bonkers" + i;
bonkers.x = 320;
bonkers.y = 214.5;
}
and i have tried this many different ways with the addChild()
Code:
for (i = 0; i < 5; i++);{
bonkers[i].addChild();
bonkers.x = 320;
bonkers.y = 214.5;
}
Code:
for (i = 0; i < 5; i++);{
addChild(bonkers[i]);
bonkers.x = 320;
bonkers.y = 214.5;
}
I get different ranging errors 2007, 1010 and others. Any help would be great.
How To Access Data In An Array?
I need to move my targets in the "onBubblaKlick"-function to the x and y positions defined in the bubblaData-Array (marked in red). But I can't figure out how to access them? Any solutions out there?
Code:
var bubblaArray:Array = [];
var bubblaData:Array = [[56, 432, .5, "picknick", "Text", 1, 34],
[ 182, 408, .6, "restaurang", "Text", 70, 789],
[ 322, 245, .7, "vindkraft", "Text", 63, 300],
[ 334, 427, .8, "varutransport", "Text", 70, 150],
[ 522, 636, .9, "dagvatten", "Text", 70, 542],
[ 605, 489, 1, "cyklist", "Text", 20, 300],
[ 735, 185, 1.1, "lagenhet", "Text", 70, 150],
[ 880, 159, 1.2, "solceller", "Text", 70, 150],
[ 935, 422, 1.3, "kollektivtrafik", "Text", 200, 300]];
// Animera in bubblorna
for (var i:Number = 0; i < 9; i++)
{
var a:Bubbla = new Bubbla();
var placeBubbla:Object = { _scale:1, time:2, transition:"easeoutelastic", delay:bubblaData[i][2] }
var bubblaX = bubblaData[i][0];// x-position
var bubblaY = bubblaData[i][1];// y-position
var bubblaName = bubblaData[i][3];// vilket scenario
var infoText = bubblaData[i][4];// scenario-rubrik
var moveX = bubblaData[i][5];
var moveY = bubblaData[i][6];
a.scaleX = a.scaleY = 0;
a.filters = [shadow];
a.x = bubblaX;
a.y = bubblaY;
a.name = bubblaName;
a.bubblaText_txt.text = infoText;
a.bubblaText_txt.alpha = 0;
Tweener.addTween( a, placeBubbla );
addChildAt ( a, 1 );
bubblaArray.push(a);
a.addEventListener( MouseEvent.CLICK, onBubblaKlick );
a.addEventListener( MouseEvent.ROLL_OVER, bubblaStor );
a.addEventListener( MouseEvent.ROLL_OUT, bubblaLiten );
}
// Klick på bubblorna
function onBubblaKlick( evt:Event ):void {
var target = evt.currentTarget;
Tweener.addTween( target, { _scale:2.5, x:moveX, y:moveY, time:1, transition:"easeoutlinear" } );
for ( var p in bubblaArray ) {
if ( bubblaArray[p] != target ) {
Tweener.addTween( bubblaArray[p], fadeBubbla );
}
}
target.removeEventListener( MouseEvent.CLICK, onBubblaKlick );
target.removeEventListener( MouseEvent.ROLL_OVER, bubblaStor );
target.removeEventListener( MouseEvent.ROLL_OUT, bubblaLiten );
var myRequest:URLRequest = new URLRequest ( "scenario/"+target.name+".swf" );
myLoader.load ( myRequest );
}
How To Access Dynamic Mc In An Array?
Hi,
I'm creating instances of a movieclip in the library dynamically, then i want to animate them (make them drop from the top to bottom). But I can't figure out how to access them in my array.
They are in there, they come up in a trace, but using a loop through them (on enter frame) and trying to change y value doesn't work? I have my array registered at the top of the class, and get no errors..
Code:
// randomly create treasures with timer (WILL MOVE TREASURES WITH TIMER ASWELL)
public function createTreasures(){
var rand:Number = (Math.ceil(Math.random()*2000))
var timer:Timer = new Timer(rand);
timer.addEventListener(TimerEvent.TIMER,timerF);
timer.start();
treasures = new Array();
function timerF(event:TimerEvent):void{
var treasure:MovieClip = new Treasure();
treasure.x = (Math.ceil(Math.random()*800));
treasure.y = 0;
//random treasure type
treasure.type = Math.ceil(Math.random()*5);
treasure.gotoAndStop(treasure.type);
treasure.speedY = Math.random() * 5 + 2;
treasure.inAir = true;
treasure.width = 20.0;
treasure.height = 40.0;
//keep treasures with min/max boudary
if (treasure.x<100){
treasure.x = treasure.x + 100;
}
else if(treasure.x>700){
treasure.x = treasure.x -100;
}
//add to stage
addChild(treasure);
//push into array
treasures.push(treasure);
}
}
//loop through treasures
public function moveTreasures(timeDiff){
for(var i:int=0;i<treasures.length;i++){
// add to treasures y value
treasures[i].y = treasures.y + 100;
}
}
http://www.kirupa.com/forum/images/smilies/sonic.gif
spank you
Using An XML /FlashMXPro2k4 To Access An Array
Could someone please explain how to use an XML file and an image array and FlashMXPro2004 to run a slideshow/presentation that uses no buttons but simply starts playing when the user accesses the page? There are 14 images and they just loop.
Thanks for your help
dwilder
Access Random Array
Hi,
I have some arrays as below:
Code:
var Q1 = new Array("What Colour is the sky",1, "blue", "green", "black");
var Q2 = new Array("What Colour is the grass",2, "pink", "green", "yellow");
var Q3 = new Array("What Colour is the road",2, "blue", "green", "black","yellow");
I know how to access a certain array and element i.e. Q1[0]
But how can I access an array at random e.g Qi[0];
I have generated a random number, just need to know how to use it in accessing the array, ive tried this "Q"+num[0] where num is the random number.
Any help will be great thanx
Array Access Difficulties - Tell Me What I'm Doing Wrong...
Hi,
I'm drawing a line chart that takes its data from a .txt file, converts that data into arrays, and is supposed to draw a line chart from duplicated movie clips....but doesn't.
OK, converting the data from the .txt file into arrays and duplicating movie clips works dandy - Flash Player can see the arrays and the duplicated movie clips show up exactly as I want them - but the chart doesn't draw out.
I want the script to take a cloned movie clip and to send it to frame X, where X is a value in an array, thus:
for (n=0; n<NavDot.length; n++) {
bnav = "NavDot" add n;
duplicateMovieClip ("NavDot", bnav, n+250);
if (Number(n) == 0) {
// Positions the clip on stage
setProperty (bnav, _x, NavDot._x);
bnav.gotoAndStop(NavPlot[n]);
} else {
//Positions the clip on stage
setProperty (bnav, _x, Number(getProperty(bnav, _x)+Number((n-1)*(getProperty(bnav, _width))));
bnav.gotoAndStop(NavPlot[n]);
}
}
...I also tried
for (j=0; j<NavPlot.length; j++) {
tellTarget ("NavDot" add j) {
gotoAndStop (NavPlot[j]);
}
}
But they don't work. The script has no syntax errors, all the movie clip instances are named correctly on stage, so I can't tell what I'm doing wrong...but it sure don't wanna go to frame (NavPlot[n]). The movie clip is simply a little square, motion tweened over 1000 frames(I've used this before so I know it works), and the value in the array should tell that movie clip where to go, but they all remain in frame 1.
Any clues?
Thanks
Lassi
Help With Syntax (array Access Operator)
Hi,
I am trying to address a ""clipC" + n " without "dot" operator and identifyier. The problem is, it lives in a clip whose name I can't write out either.
I tried this
--------------------------------------------------------
clipA["clipB"+n][clipC" + n].doSomething
--------------------------------------------------------
but to no avail. Can anyone help me with the syntax?
How To Access Multi Elements Array
Hi all I think the quezz so simple
but I don't know how ??
to display the 2 elements in an array at the same time
something like this
m = ['a','b'];
trace(m[0][1]);// display undefined
Access Nested Clip From Array
aMCs = ["movieClipA","movieClipB","movieClipC"];
a = aMCs[0];
b = aMCs[0] +"."+ aMCs[1];
trace(typeof b + " B " + b); // movieClipA.movieClipB
goto(a); // i work
goto(b); // i fail
goto(movieClipA.movieClipB.movieClipC); // i fail
function goto(clips){
trace(typeof clips +" IN "+clips);
_root[clips].gotoAndStop(2)
};
//movieClipA.movieClipB.gotoAndStop(2); //ok
how can i access the timeline of a nested clip
using the array of movie clip instance names ??
tia
a_void();
|