[FMX2K4]XML To Array Help
Hey everyone, I'm having a little trouble here....I'm trying to make roster[i] contain all of the childNodes in the rHolder, which is the entire xml document but the program never gets to the for loop below, so whenever the button is pressed for the search() function, it doesn't find anything because the roster array isnt containing anything in the begining and I can't seem to figure out why Any help would be appreciated please below the actionscript file is an example of my xml file
Code: myxml = new XML(); myxml.onLoad = function(success) { if (success) { rHolder = myxml.firstChild.childNodes; roster = new Array(); //the below for loop just crashes the program every time i try to debug for (i=0; i<rHolder.length; i++) { roster[i] = rHolder[i].childNodes; } } }; myxml.load("roster.xml"); this.onEnterFrame = function() { var loadedBytes = myxml.getBytesLoaded(); var totalBytes = myxml.getBytesTotal(); var bytes = Math.floor(loadedBytes/1024*1000); var percentLoaded = Math.floor(loadedBytes/totalBytes*100); _root.loading.text = percentLoaded+" %"; if (loadedBytes>=totalBytes) { percentLoaded = 101; } }; search_btn.onPress = function() { _root.search(); }; function search() { thissearch = input.text; for (i=0; i<roster.length; i++) { if (roster[i][3].firstChild.nodeValue == thissearch) { trace("loop"); for (j=0; j<4; j++) { trace(roster[i][j].firstChild); } } } }
Code: <rosterlist> <roster> <division>csim</division> <userid>94704</userid> <teamid>401</teamid> <uniqueid>0:1:2273</uniqueid> </roster> <roster> <division>csim</division> <userid>54</userid> <teamid>263</teamid> <uniqueid>0:0:3441256</uniqueid> </roster> </rosterlist>
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 03-15-2005, 04:45 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[FMX2K4]XML To Array Help
Hey everyone, I'm having a little trouble here....I'm trying to make roster[i] contain all of the childNodes in the rHolder, which is the entire xml document but the program never gets to the for loop below, so whenever the button is pressed for the search() function, it doesn't find anything because the roster array isnt containing anything in the begining and I can't seem to figure out why
Any help would be appreciated please below the actionscript file is an example of my xml file
Code:
myxml = new XML();
myxml.onLoad = function(success) {
if (success) {
rHolder = myxml.firstChild.childNodes;
roster = new Array();
//the below for loop just crashes the program every time i try to debug
for (i=0; i<rHolder.length; i++) {
roster[i] = rHolder[i].childNodes;
}
}
};
myxml.load("roster.xml");
this.onEnterFrame = function() {
var loadedBytes = myxml.getBytesLoaded();
var totalBytes = myxml.getBytesTotal();
var bytes = Math.floor(loadedBytes/1024*1000);
var percentLoaded = Math.floor(loadedBytes/totalBytes*100);
_root.loading.text = percentLoaded+" %";
if (loadedBytes>=totalBytes) {
percentLoaded = 101;
}
};
search_btn.onPress = function() {
_root.search();
};
function search() {
thissearch = input.text;
for (i=0; i<roster.length; i++) {
if (roster[i][3].firstChild.nodeValue == thissearch) {
trace("loop");
for (j=0; j<4; j++) {
trace(roster[i][j].firstChild);
}
}
}
}
Code:
<rosterlist>
<roster>
<division>csim</division>
<userid>94704</userid>
<teamid>401</teamid>
<uniqueid>0:1:2273</uniqueid>
</roster>
<roster>
<division>csim</division>
<userid>54</userid>
<teamid>263</teamid>
<uniqueid>0:0:3441256</uniqueid>
</roster>
</rosterlist>
Gawd...fmx2k4 Is Being Trixy
Ok. Now I cant even open files with it. I have old projects that I've made with the trial ... and since I am not planning to shelling out bones for this piece of trash ... Im converting everything I've made back to MX format.
Oh wait. It wont let me. Everytime I open up some of my files it just responds 'failed to open document', and thats all I can get out of it.
Cant open the files with MX either, since they're fmx2k4 format. Any help recovering my work?
[fmx2k4]CreateEmptyMovieClip Not Working
Here's the code, the problem is, it displays nothing, what am I missing?
Quote:
function createNewTabMovie(name, digit) {
tX = _root.tabControl.y;
tY = _root.tabControl.x;
tWidth = _root.tabControl.width;
tHeight = _root.tabControl.height;
newTab = _root.createEmptyMovieClip(name+digit, getNextHighestDepth());
newTab._x = tX;
newTab._y = tY;
newTab._width = tWidth;
newTab._height = tHeight;
newTab.attachMovie("Button","myButt",3242);
newTab.moveTo(tX,(tY + tHeight));
newTab.lineStyle(2,0xff00ff,100);
newTab.lineTo(tX,tY);
newTab.lineTo((tX+tWidth),tY);
newTab.lineTo((tX + tWidth),(tY + tHeight));
newTab.onRelease = newTab.onReleaseOutside = function (){
trace("hit");
}
}
tabControl = new Object();
tabControl.y = 1;
tabControl.x = 48;
tabControl.width = 238;
tabControl.height = 138;
createNewTabMovie("tab",5);
FMX2k4 Projector Issue
Alright, this isn't a very technical or convoluted problem. I'm making a simple interactive movie, and being as controlling as I am, naturally invoked the 'Stage.showmenu = false' code in the first frame of the movie. This is the first time I've really attempted to use this, and I noticed later upon exporting the projector file that there was a top and bottom margin problem. The problem being that there were approximately 10 excessive pixels on the top and bottom of the projected movie. I would assume this simply a result of the newfound lack of a menu -- being that it would presumably take up the space of roughly 20 pixels at the top.
I've attempted to combat this the only way I could think to (short of resizing the entire stage, thereby truncating the bottom and leaving the top unaffected), which is to play with all the Stage.scaleMode properties. At first it seemed that changing the scaleMode to exactFit resized the movie correctly -- as there was no more visible top and bottom breaks -- but as more experienced actionscripters have probably guessed, this just made it stretch the movie by those ~20 pixels, which is a very undesirable prospect.
This seems like it must be a common problem, and I'm admittedly inexperienced, so any managable solutions would be greatly appreciated.
[fmx2k4]CreateEmptyMovieClip Not Working
Here's the code, the problem is, it displays nothing, what am I missing?
Quote:
function createNewTabMovie(name, digit) {
tX = _root.tabControl.y;
tY = _root.tabControl.x;
tWidth = _root.tabControl.width;
tHeight = _root.tabControl.height;
newTab = _root.createEmptyMovieClip(name+digit, getNextHighestDepth());
newTab._x = tX;
newTab._y = tY;
newTab._width = tWidth;
newTab._height = tHeight;
newTab.attachMovie("Button","myButt",3242);
newTab.moveTo(tX,(tY + tHeight));
newTab.lineStyle(2,0xff00ff,100);
newTab.lineTo(tX,tY);
newTab.lineTo((tX+tWidth),tY);
newTab.lineTo((tX + tWidth),(tY + tHeight));
newTab.onRelease = newTab.onReleaseOutside = function (){
trace("hit");
}
}
tabControl = new Object();
tabControl.y = 1;
tabControl.x = 48;
tabControl.width = 238;
tabControl.height = 138;
createNewTabMovie("tab",5);
FMX2k4 Projector Issue
Alright, this isn't a very technical or convoluted problem. I'm making a simple interactive movie, and being as controlling as I am, naturally invoked the 'Stage.showmenu = false' code in the first frame of the movie. This is the first time I've really attempted to use this, and I noticed later upon exporting the projector file that there was a top and bottom margin problem. The problem being that there were approximately 10 excessive pixels on the top and bottom of the projected movie. I would assume this simply a result of the newfound lack of a menu -- being that it would presumably take up the space of roughly 20 pixels at the top.
I've attempted to combat this the only way I could think to (short of resizing the entire stage, thereby truncating the bottom and leaving the top unaffected), which is to play with all the Stage.scaleMode properties. At first it seemed that changing the scaleMode to exactFit resized the movie correctly -- as there was no more visible top and bottom breaks -- but as more experienced actionscripters have probably guessed, this just made it stretch the movie by those ~20 pixels, which is a very undesirable prospect.
This seems like it must be a common problem, and I'm admittedly inexperienced, so any managable solutions would be greatly appreciated.
[FMX2K4] Text Aligned Along Bottom Of The Box
Lets say I have a text box that is 100x100. How can I make the text start aligning along the bottom? So if I have 1 line of text its on the bottom of the text box, if I have 2 lines of text...its the bottom 2 lines of the text box, if i Have 5 lines of text...it takes up the whole box, starting from the top? Kind of a bottom justify or something? Is it possible?
Loading XML Data Then Saving It [FMX2k4]
I have a load of XML files that I am in need for reformatting and because I have been working with Flash alot recently, I'm familiar with the XML tools and decided that it would be the best choice to reformat the files.
So, right now, I'm loading the files in using XML Objects and then just using a recursive loop to cycle through all the nodes and do what I need to. Now, is there any easy way that I can save the update data back into the same XML file I loaded it from? Since this isn't going to be going into any sort of public use, it's all being run directly from the Flash interface. Any suggestions on an easy way to do this?
Just so you have an idea of what I'm doing, here's an example:
Code:
<root >
<cm1 label="Company Name" assignedUsers="user1, user2">
<bf1 label="BCS" assignedUsers="">
<bu1 label="BCS" assignedUsers="User12, User3">
<bp1 label="This is the first BP Label" assignedUsers="User4, User8"/>
<bp2 label="Another BP" assignedUsers="User 1"/>
<bp3 label="The third BP" assignedUsers="User666"/>
Continues on with more bp, bu, and bf nodes
Now, I'm not sure why the guy before me did it this way, but what I would am doing is changing it so that each nodes name isn't bp#, but just bp (or bf, or bu, etc.) and adding another attribute node called ID with the associated number. I'm also looking at doing something with the assignedUsers node to make it easier to work with (ie, easier to query with XPath). So it will hopefully look something like this:
Code:
<root >
<cm ID="1">
<bf ID="1" label="BCS" ...
<bu ID="1" label="BCS" ...
<bp ID="1" ...
<bp ID="2" ...
<bp ID="3" ...
<bp ID="4" ...
<bp ID="5" ...
[FMX2K4] Text Aligned Along Bottom Of The Box
Lets say I have a text box that is 100x100. How can I make the text start aligning along the bottom? So if I have 1 line of text its on the bottom of the text box, if I have 2 lines of text...its the bottom 2 lines of the text box, if i Have 5 lines of text...it takes up the whole box, starting from the top? Kind of a bottom justify or something? Is it possible?
FMX2k4 Help With Mouse Events In Multiple Instances Please
As a Delphi developer moving over to FlashMX2004 I am having trouble with a fundamental process. Here is what I am trying to do:
</p>
* load an xml from a specified URL. parse it within an onLoad function.
* the xml contains a random number (up to 20) of sibling nodes. Parsing each node causes a new custom object (same class every time) to be created and relevant properties (text and numeric) to be set.
* I then create a new movieclip and load it with an image loaded from a URL specified as a property in the xml.
* SO FAR SO GOOD, MOVIECLIPS CREATED AND VISIBLE.
* I then set Mouse.addListener and onMouseDown, onRollOver and onRollOut events for each instance.
My problem is that although the events fire, they either use ONLY the last created instance or cause errors because the reference is 'undefined'.
I understand that there is a known 'feature' in Actionscript which means that the functions use the current value of any variable used in the initialisation loop, rather than the value appropriate to the instance at the time of creation.
Can anyone point me to a quick example where multiple instances of an object (and child movieclip) are created in a loop and assigned mouse events?
Thanks in advance
David
[fmx2k4] Custom Context Menu Limitations
Just playing around with some of the new FMX2k4 features, specifically the ContextMenu() and ContextMenuItem() stuff.
Perhaps unsurprisingly you cannot have custom elements with the same labels as any of the built-in items ("Show All", "Zoom 100%", etc). These are case-insensitive too.
That's fair enough, but it seems that you cannot have custom menu items with the labels "cut", "copy" or "paste" (add any other characters besides a space and they work fine, eg: "cut_", "copy_").
Here's my code:
ActionScript Code:
/* DOESN'T WORK */
var my_cm = new ContextMenu();
my_cm.hideBuiltInItems();
my_cm.customItems.push( new ContextMenuItem("copy",f_one) );
my_cm.customItems.push( new ContextMenuItem("paste",f_two) );
function f_one() { trace(" f one ") }
function f_two() { trace(" f 222 ") }
this.menu = my_cm;
/* WORKS GREAT */
var my_cm = new ContextMenu();
my_cm.hideBuiltInItems();
my_cm.customItems.push( new ContextMenuItem("copy_",f_one) );
my_cm.customItems.push( new ContextMenuItem("paste_",f_two) );
function f_one() { trace(" f one ") }
function f_two() { trace(" f 222 ") }
this.menu = my_cm;
Anyone know why this might be? There are no current cut/copy/paste items but might they be getting added in at some point? Can anyone find any other disallowed menu labels?
FMX Components Vs. FMX2K4 Components
Hi,
I would like to export movie clips as components and let other developers use those to create applications.
I have very little experience with components; I did use FMX components in the past.
I would like to let users change the components features, for instance, totally redo the animation of a button's components rollover effect.
1.Can this be done with FMX2k4 components (I think not).
2.Can this be done with FMX components?
3.Can I export FMX components with FMX2k4 IDE?
4.What effect will components have on file size and performance?
Thanks in advance,
DMZ
Array, Array HELP - Importing A External File Into N ARRAY - Almost There
I am reading and external file with the following code:
ActionScript Code:
on (release, keyPress "<Enter>") {
lv = new LoadVars();
lv.onLoad = function() {
questions1 = this.filelist0.split(",");
answers1 = this.filelist1.split(",");
for(i=0;i<questions1.length;i++)
//trace(questions1[i]+" "+answers1[i]);
trace(questions1[i]);
//assumes same number of scores in each list
};
lv.load("questions.txt");
}
When I parse the file it puts it into an columar format as it should...however I need it to look like this:
questions1=new Array ("2+4=?","What is the capital of Illinois?","What color is the sky?","10x(5+2)=?");
answers1=new Array ("8","springfield","blue","70");
How do I do that?
Text file look like this:
&questions1=2+4=?,What is the Capital of Illinois?,What color is the sky?,10x(5+2)=?")&
&answers1=8,springfield,blue,70&
Pls Help: Need To Create New Array Taking 3 Random Entries From An Existing Array
Hello
I have a 2d array:
qTeeth[1] = [How many teeth do we have?, 1-10, 11-20, 21-30, 11-20]
etc.
It goes [question, option1, option2, option3, real answer]
I now just want to extract 3 or so of these entries and create a new array with them. Since I want to just use 3 or so questions randomly from a large array of questions.
Does anyone know a good tidy script to do this with??
Thanks in advance,
Ben.
Array Text Into Textfield And Creating New Line For Each Array Element
I have an array called dropTarg1 which stores dropped-in items.
I want to loop through this array and in a textfield, display each array item on a new line of this text field
I think I need to use something like Array.join("/n") but I can't get it working properly. I hope that the /n would create a new line of the text field called reviewBoxContentText.
for(var i:Number = 0; i<dropTarg.length; i++){
with(reviewBoxContent.reviewBoxContentText){
autoSize = true;
text = dropTarg1.join("/n");
}
}
All that is happening though is that the text field displays on a single line with /n in between each array element.
Calling A Function With An Array Variable As Arguments Is Resetting Array?
I'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!
Any help would be grateful.
ActionScript Code:
// processReplace Function function processReplace(transferFiles) { var processArray:Array = transferFiles.slice(); var fileName:String = new String(); var filesArray:Array = new Array(); var replaceArray:Array = new Array(); var exists:String = new String(); var error:String = new String(); var promptResult:String = new String(); // Check for (i=0; i<processArray.length; i++) { // This is where it bugs up <b>exists = processSearch(transferFiles[i][1]);</b> if (exists == "replace") { replaceArray.push(processArray[i]); } else { filesArray.push(processArray[i]); } } // Prompt if (replaceArray.length>0) { error = "Replace "+replaceArray.length+" item(s):
"; for (i=0; i<replaceArray.length; i++) { error += " - "+replaceArray[i][1]+"
"; } promptResult = mSystem.messageBox(error, "Replace Existing Files?", 4); } // Action if (promptResult == "NO") { transferFiles = filesArray; } else if (promptResult == "YES") { transferFiles = filesArray.concat(replaceArray); } processTransfer(transferFiles); }
The processSearch
ActionScript Code:
// == processSearch Function function processSearch(sentInfo) { for (i=0; i<_global.boxFiles.length; i++) { if (_global.boxFiles[i] == sentInfo[1]) { return "replace"; break; } } }
Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".
It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.
I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.
Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code
ANY Solution ideas are welcome, even if you think it's dumb
Thanks!
Array.splice Works But Array.slice Doesnt?
This should be simple enough. I have an array of objects, and I want to SLICE a piece of the array and assign it to a new array. All of my attempts have failed. SPLICE works, and I could duplicate my original array into a temp array and splice out what I want, but surely slice is supposed to save me this trouble, right?
I'm a bit baffled, but here's the code:
Code:
private function createGlist() {
var glistObj:Glist = this;
xml_object = new XML();
xml_object.ignoreWhite = true;
xml_object.onLoad = function(success:Boolean):Void {
if(success) {
var i:Number = 0;
for (var this_node = this.firstChild.firstChild; this_node != null; this_node = this_node.nextSibling) {
glistObj.thumb_array.push(new Gthumb(glistObj, glistObj.thumb_array_mc.getNextHighestDepth(), this.firstChild.childNodes[i]));
i++;
}
var load_start:Number = 2;
var load_count:Number = 2;
glistObj.thumb_load_array = glistObj.thumb_array.slice(load_start,load_count);
trace(glistObj.thumb_load_array); //no result, no error
trace(glistObj.thumb_array.slice(load_start,load_count)); //no result, no error
trace(glistObj.thumb_array.splice(load_start,load_count)); //outputs [object Object],[object Object]
} else {
//error
}
}
xml_object.load(xml_url);
}
Array Copy Points To Original Array Instead Of Duplicating
Hey all.
Spent a long time trying to figure out what was wrong with my code. Then I remembered about arrays being objects instead of primitive variables. My question is, how can I make a duplicate copy of an Array?
Details:
So this code
PHP Code:
package{
import flash.display.*
public class tester extends MovieClip{
var a:Array = [1,2]
public function tester () {
var b = a
trace (a)
b.splice(1,1)
trace (a)
}
}
}
results in this output:
PHP Code:
1,2
1
How can i make b an actual duplicate of a, instead of a pointer?
PHP Code:
b = new Array
b = a
doesn't work either.
Thanks!
DHP
Creating Multi-dimentional Array From Single Array
I have an array
myArray=[hello,bye,fred,1,2,3,4,5,6];
I need to convert it to a multi-dimentional array that would look something like below
array1=[hello,bye,fred];
array2=[1,2,3];
array3=[4,5,6];
newArray=[array1, array2,array3];
I am not sure how to split the array can anyone help? myArray.length/3 would give me the number in each of the new arrays but I am puzzled after this?
Associating Array Elements With Another Array Keeping The Order.
hi, i have already posted this problem yesterday but i haven't solved it yet.
i have two arrays:
array_1[a,b,c,d]
array_2[01,02,03,04]
the first array represents mcs in my stage - the buttons of the menu.
the second represents other mcs, containing some text.
when i rollOver each element of array_1 i would like to show each element of array_2 in the same order and hide it when i rollOver another menu button to show a new one.
I mean, it always has to be showing a with 01, b with 02, c with 03...
any suggestions?
Array Of Movie Loaders/array Of Image Files
Alright. I'm fairly new to Actionscripting, so if we can somewhat lame out the tech talk to mild to medium I'd appreciate it. what I am trying to do is create an swf movie that will interact with a PHP script. first lets start with saying the PHP script reads the directory that it is currently in and filters out any file that is not a GIF,PNG, or JPG and then it suffes all of this into a URL encoded string and the directory path ,such as :
?pictures=image1+image2+image3+image4&path=http://servername/directoryPath
now i have flash load the variables "pictures" and split the images and stuff those into an array and the directory path of course stays in its own seperate variable. ive gotten this far with no problems.
so what im trying to do now with this info is create a bit of a slide show. I want to take the array of pictures and load those into an empty movie clip displaying each picture consecutively. Ive made several attempts but no such luck. Ive tried to use a for() loop to cycle through the array of pictures loading them into the empty clip. im still very new and rather lost with these objects and class use i. Im sure im probably not using a listener of somesort that i need and what not. I am sorry i am probably not giving enough info for all this. the whole idea of this clip is to be able to display an indefinite amount pictures , so the flash player will not know ahead of time how many pictures till the php script has sent all the names of what is in the directory. this movie needs to be able to dynamically load any images that are in that directory.so any suggestions on what i can do with an array an an empty clip? thank you to anyone who can make suggesions.
How Do I Lope Through Array, Delete Clip And Remove From Array
I have a function that creates an instance of a movieClip and adds it to an array.
In my gameloop I loop through the array and change some values. Now I want a cleanup function that loops through the array, and if the y value exceeds a certain value, I want to delete the clip instance and remove the record in the Array.
Could someone please help me with the syntax for that? I will lay the code out below.
Thankyou
Attach Code
var myClipArray = new Array();
public function createClipInstance() {
var myClipInstance:myClip = new myClip();
myClipInstance.y = 0;
addChild( myClipInstance );
myClipArray.push(myClipInstance);
}
// loop through array and check y value
// if y > 400: Delete clip and remove from array
public function cleanClips() {
for (var n:int = 0; n<myClipArray.length; n++){
if (myClipArray[n].y > 400) {
// DELETE CLIP AND REMOVE FROM ARRAY
trace("this is where I need help");
}
}
}
Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...
ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.
the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...
is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?
any suggestions would be grand.
this is what i have on my controller clip:
onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}
Load Xml Images-->Array-->Duplicate Array: AHAA
Hello Kirupians!
[Summary]
I want to load images from an XML, then store the images inside an array, then duplicate that array into other clone arrays so that I can addChild() copies of the images into stage whenever i want (and be able to change their properties).
Basicly i have to create two duplicates; big_img and icon_image
[SYMPTOMS]
Everything is loaded fine;the big_imgloads and positions correctly, but, when i try to load icon_image the first big_img disappears! as if the new array has hasn't duplicated the original array (as if it's only a shortcut, not a real copy).
The cody thing:
ActionScript Code:
// total images read from XMLvar axiLength=Accessoir.length();// main image container arrayvar axxARR:Array = new Array();// add images to arrayfor (var k=0; k<axiLength; k++) { var axxLoader:Loader = new Loader(); axxLoader.load(new URLRequest(Accessoir.PHOTO.text()[k])); axxARR.push(axxLoader); axxLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, axxLoaded);}function axxLoaded(e:Event):void { // show big image if (axiLength==axxARR.length) { axxShow(0); }}function axxShow(ID_AXX:Number) { // duplicate images array var axxImage:Array=axxARR.concat(axxARR); // reposition it axxImage[ID_AXX].x = product_details_swf.axx.x+(axxImage[ID_AXX].width/2)-5.5; // Add init image to accessoires axxImage[ID_AXX].name="axxImage"; product_details_swf.axx.addChild(axxImage[ID_AXX]);}// here i got an event listner to a button, once rolle over is triged it // should make small copies of the whole array images and put them on stage//....function rollover_button(ID_AXX:Number) { for (var i=0; i<axiLength; i++) { axxCreate(i); } function axxCreate(ID_AXX:Number) { var axxPic:Array=axxARR.concat(); imageResizer(axxPic[ID_AXX], 50, 50); axxPic[ID_AXX].name="axxPic_"+ID_AXX; axxPic[ID_AXX].x=product_details_swf.axx.getChildByName("axxBG_"+ID_AXX).x+axxPicSpacingX; axxPic[ID_AXX].y=product_details_swf.axx.getChildByName("axxBG_"+ID_AXX).y+axxPicSpacingY; product_details_swf.axx.addChild(axxPic[ID_AXX]); }}
[MORE INFORMATION]
I tried array duplication using; concat and slice but not work, it doesn't creat copies of the orriginal array, but just a shortcut to it!
thanx for any tips!
Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...
ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.
the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...
is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?
any suggestions would be grand.
this is what i have on my controller clip:
onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}
Copying Loaded Array Into A Local Array
I'm loading an array through loadVariablesNum (into level 0). The script properly returns array values... I've checked by using text boxes on my stage. But, when I try to store the loaded array within a local Actionscript array for manipulation, it doesn't seem to be able to read the loaded values. It's as if the stage and the frame Actionscript were independent of each other. Can anyone help?
Thanks
Inserting An Array Into An Array To Make It Multidemensional
hi there,
Using an ASP script I've managed to get strings into flash
at the moment the strings come in like this:
array1=data1,data2,data3,data4,data5
array2=celeb1,celeb2,celeb3,celeb4,celeb5
currently I'm doing this:
webfoldercontents = new Array();
webfoldercontens = websubfolders.split(",");
which creats a 2d array. what I need is this:
multidemesionalarray = [array1[array2]]
any help v.appreciated!
Danny
Saving An Array Then Importing Saved Array?
I am creating a kids activity. At the moment I am working on the stamp tool that allws them to stamp a shape in different colours over the canvas... this is working fine, however I need to track the position and colour (and maybe more later) so that the child can save the activity and go back to it later.
So far I have managed to create an array for each propery (_x position, _y position and colour) in seperate arrays as a new stamp is attached it is given a number (1,2,3,4...) and in each array entry of that number are the position or colour properties. When I save these arrays (using FSCommand in Flash5) I think thay form a string in the text document.
When I loads the array from the text document, that looks like this:
&colourArray=255,255,255,16711680,16711680,1671168 0,16711680,16711680,16711680,16711680&XposArray=23 3,420.95,389,262,556.95,674.95,619.95,481.95,458.9 5,280&YposArray=109,167,313,211,301,158,80,105,174 ,451.95
I cannot pull out the data from the arrays (colourArray[2] traces as undefined) What I want to do is a loop based on the lenght of one the arrays that attaches the stamp MC in the correct position and colour.
Hope someone can shed light on this for me... I think I need to find a way to convert the text file data from a string to an array?!?
Cheers
Oll
Copying Array Inside Array Of Arrays
Hi,
I've got an array made up of other arrays, and I need to copy one of the arrays to a tempory array (so i can copy it)
I've tried using...
TempArray = ArrayList[0].splice();
but TempArray just shows (in debugger) as undefined, any idea's??
thanks
phil.
Tracing An Array :: Sending Array Through JS Proxy
Correct me if I'm wrong, but I thought when you traced an Array, the output was [object]. For example:
code:
var x = new Array();
x.push("one");
x.push("two");
x.push("three");
x.push("four");
trace(x);
Would output: [object Object], not the array as a comma delimited string, correct?
Having a problem where I'm passing an Array to a JS function throuh the JS proxy (flash-javascript kit) and JS picks it up as a string.
How To Duplicate Array?Array.slice() Can Not Work
I test it, and Array.slice() can not work.
var arNew:Array = new Array();
var arOld:Array = [
{checked:0},
{checked:0},
{checked:0}
];
arNew = arOld.slice();
for(var i = 0; i < arNew.length; ++ i)
{
arNew[i].checked = 1;
}
for(var i = 0; i < arOld.length; ++ i)
{
trace(arOld[i].checked);
}
It seems that "arOld" had been changed and "arNew" is not a copy of "arOld", but a reference of "arOld".
How should I copy a array?
thanks for any help
Given An Array Return An Array With Only Unique Elements
if i have an array of elements like 1,2,2,1,3,3,1,2,...
I want to return only
1,2,3
so to strip out duplicates, I thought this would be easy but its proving harder than I thought.
thanks
Filling Array - Passing Array In Function
hello
I'm trying to fill an array then pass it to a function i'm tying to do it that way
but it giving me strange results when I trace things (try it and you'll see):
Code:
////////////////// fiiling the array /////////////////
for (i=1; i<=numberof_player;i++){
pos_array = new Array(numberof_player)
pos_array [i]= i
trace("in array"+pos_array [i])
}
////////////////// pasing array in function //////////////////////
function rolldice( pos_array:Array){
trace(pos_array) /// gives 4,undefined,undefined,undefined,4
}
///////////////////////////////////////////////////////////////////
maybe i'm stupid
Thanks
T
Random Array, Array Name Selected Randomly
Random Array, Array Name selected Randomly
Here is the code:
var RDNumber2x:Array = [2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36, 38,40];
var RDNumber3x:Array = [3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54 ,57,60];
var RDNumber4x:Array = [4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,7 2,76,80];
var RDNumber5x:Array = [5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85, 90,95,100];
var RDNumber6x:Array = [6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102 ,108,114,120];
var RDNumber7x:Array = [7,14,21,28,35,42,49,56,63,70,77,84,91,98,105,112,1 19,126,133,140];
var RDNumber8x:Array = [8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128 ,136,144,152,160];
var RDNumber9x:Array = [9,18,27,36,45,54,63,72,81,90,99,108,117,126,135,14 4,153,162,171,180];
var RDNumber10x:Array = [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150 ,160,170,180,190,200];
var RArray:Array = ["RDNumber2x","RDNumber3x","RDNumber4x","RDNumber5x ","RDNumber6x","RDNumber7x","RDNumber8x","RDNumber 9x","RDNumber10x"];
var RArrayBox:String;
var RArrayBoxS = 0;
RArrayBox = RArray[Math.floor(Math.random() * RArray.length)];
RArrayBoxS = RArrayBox[Math.floor(Math.random() * RArrayBox.length)];
trace(RArrayBoxS);
Heres The error:
ReferenceError: Error #1069: Property 6 not found on String and there is no default value.
at randomarray_fla::MainTimeline/randomarray_fla::frame1()
What I am trying to atchieve is randomly selecting the array name and then randomly selecting something from that array.
So I am randomly selecting from a randomly selected array
Can anyone help with my problem?
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 !
Sorting A New Array From An Existing Array (emergency)
Hi
i got an existing array, main[y], which after an equation, will come out with another array.
Code:
if (main[y] === topicList.getValue()){
subTopic = [];
subTopic = fTitle[y]
trace(subTopic)
}
However, i could not sort the subTopic, as it gkeep giving me undefined. Is there any way to sort this subTopic, such that they are in alphabetical orders?
Appreciate any help.
Referencing Array Items With An Id Pulled From The Array
I have been modifying one of the Kirupa tutorials about loading external xml data and arrays. I have it successfully working, but i would like to figure out how to take it one step further. I want to be able to designate a each item in the arrays with an id rather than an iterative variable number and cannot figure out how to do it.
This is a snippet from the xml file:
<projects>
<item>
<id>13</id>
<projectname>First Project</projectname>
<location>Anytown, USA</location>
<units>60</units>
</item>
<item>
<id>33</id>
<projectname>Second Project</projectname>
<location>Sometown, USA</location>
<units>132</units>
</item>
</projects>
I am currently populating an array this way:
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
id[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
projectname[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
plocation[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
units[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
}
but that just gives me references to: projectname1, projectname2 etc.
I would like to figure out how to get the <id> value from the loaded xml file connected to the variable name of each item in the array so that i can refer to the variables this way: projectname13, projectname33, etc.
Does this make sense? Can anyone help?
Setting Array Values To Variables In Another Array
I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated.
A way I've tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an "apply" button is pressed which will set the values found in array2 to the variables in array1.
So...
Code:
PHP Code:
//variables on the main or root timelinevar1 = 1; var2 = 2; //... //within options mc timelinearray1 = [var1, var2]; array2 = [var1Display, var2Display]; apply.onRelease = function() { //set values in array2 to variables in array1 and update the main timeline's variables//... }
How would you do this so that var1, var2... are updated properly according to the values found in array2?
And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?
hope this all makes sense to everyone
PHP Array -> Flash Array In Function
I'm retrieving an array from PHP, bringing it into Flash, converting it to a Flash array, then passing the array values to functions in order to control playback of multiple timelines.
The PHP array consists of time values in milliseconds, and mouth positions for a character's lip-synch. For example, &time1=0.015962&mouth1=eat&time2=etc...
I want my first function to extract the first array value for time and the first array value for mouth position, and pass it to another function that reads the time, does a calculation to determine how long to pause before executing the original function again, thus leaving the mouth position passed to it and moving along to the next array value.
My problem is this: how can I write the array references into the function so that it knows each time which successive array value to extract? Do I need to pass a total number of array values initially, then trade a "current value" between the two functions (time and mouth position) to make sure the array value being retrieved is correct?
Any help is appreciated,
Mike
Simple? Array To Array Problem
I am trying to pass the value from one array element to an element in another array. I believe the value is getting there, but it won't display when the 2nd array element is used as the variable in a dynamic text block. Here's the simplistic code I'm trying to learn the concept with:
one = new Array(5);
one[0]=1;
one[1]=2;
one[2]=3;
one[3]=4;
one[4]=5;
two = new Array(5);
two[0]=one[4];
two[1]=one[3];
two[2]=one[2];
two[3]=one[1];
two[4]=one[0];
I then set up individual dynamic text boxes for two[0] through two[4], but no value will show.
Link Array 2 To Randomized Array 1
Hi,
I am trying to do the following:
I have a textfile that contains 2 variable sets:
&songs=bluestravelertest.swf|aridtest.swf|dmbtest. swf|joewalshtest.swf&eof=1
&info=<br><b>Blues Traveler</b><br>Onslaught|<br><b>Arid</b><br>Little Things of Venom|<br><b>Dave Matthews Band</b><br>Mother, Father|<br><b>Joe Walsh</b><br>Funk #49&eof=2
The 'songs' var I use to load a new swf in an empty MC, the 'info' var I use to load into a dynamic textfield. Both vars are properly parsed via a function (no problems here).
I created a button that should shuffle the 'songs' var.
Code:
var o=_root.myArray.slice(myArray[0], myArray(total))
var newlength=o.length
var shuffledArray=new Array()
for(var i=0;i<newlength;++i){
var r=random(o.length)
shuffledArray[shuffledArray.length]=o[r]
//o[r]=o[o.length-1]
o[r]=o[o.length-1]
o.pop()
}
This all works fine, but how can I link the 'info' var to the 'songs' var after it has been shuffled? (in other words, how can I get the 'info' var 2 to load when 'songs' var 2 is loaded)?
It's kinda late, so let me know if it is not clear.
I really hope you can help me here, because I have been working on this for ages, but I simply can't get it to work.
Thx in advance.
With kind regards,
RF
Question: PHP Array To Flash Array?
I've searched many topics about this and they have helped me a little bit, but I can't quite get my PHP array to go into Flash as an array. I think the method I want to do is echo my PHP array as a string separated by commas and then bring that into flash and split it.
1. I'm not quite sure how I could format my PHP array as a string separated by commas.
2. I'm not sure how to bring it into Flash via LoadVars.
Heres what I have so far:
PHP Code:
<? // test.php
include('db.php');
dbConnect("slayer");
$result=mysql_query("select*from portfolio");
$num=mysql_num_rows($result);
echo "&num_results=" . $num;
$myArray=$row["name"];
for($i=0;$i<=$num;$i++){
$row=mysql_fetch_array($result, MYSQL_BOTH);
echo "&name$i=" . $myArray[$i];
}
?>
code: on (release) {
myData = new loadVars();
myData.load("test.php");
myData.onLoad = function(success) {
if (success) {
var i = 0;
while (this["myArray" + i] != undefined) {
_root.myVar = this["myArray" + i];
i++;
}
}
};
}
Thanks for any help or tips. I would really appreciate it greatly.
ARRAY Element Value - Not Array Index Value
Hi all -
Have a small problem converting the below variables from PHP into a useful Ascript Array. I keep getting the value of the array index, rather than the value of the variable in question.
So I know I have 3 rows in my database (totalRows var),
and I have a incremental values for the "recordId"'s (which correspond to the record ID in the db).
totalRows = 3
recordId0 = 1
recordId1 = 5
recordId2 = 6
this is the code I am using:
Code:
function extractMenu() {
//returned vars (FYI): totalRows=3&recordId2=6&recordId1=5&recordId0=1&result=okay&
this.menuArray = new Array();
with (menuLoad) { //menuLoad is the LoadVars object holding PHP vars.
for (i=0; i<=totalRows-1; i++) {
menuArray[i] = recordId + i;
trace(menuArray[i]);
//the trace returns:
//0
//1
//2
//I was expecting the values:
//1
//5
//6
}
}
any takers?
Array Data Is Set Then Lost... But Just One Array
Hi,
I have 3 arrays, 2 hold different information which will be combined into the third one.
The creation/population of each array is done with in each own function as results are sent back to the flash from remoting.
I have attached a mock up of the code below.
Code:
array1 = new Array();
array2 = new Array();
array3 = new Array();
combineArrays = function () {
for (j=0; j< array2.length; j++) {
array3.push({something:array1[j].something, something:array2[j].something, ....});
}
this.myGrid.setDataProvider(array3);
};
query2_Result = function (result) {
array2.push({something:result[0].something, ....});
};
query1_Result = function (result) {
aMatrix = result;
for (i=0; i<aMatrix.length; i++) {
array1.push({something:aMatrix[i].something, ....});
remoting.query2(int(aMatrix[i].something), "");
}
combineArrays();
};
array1 and array3 keep the data that was populated into it. But by the time we reach the combine function array2 has no data.
I'm not sure why its losing the information, if you trace with in query2_Result() you get all the information that was populated into the array2.
Any help would be greatly appreciated.
Ty,
alex
Reading Array, Not Setting Array
Sorry everyone, I think I'm making a simple mistake but I just can't see it.
I'm using an array to store the order of something, I also make a backup of that array as a reference to remember what that first array looked like.
The problem comes when I'm using the values of that backed up array to populate the first array. What happens is that the backed up array gets it values overwritten, when all I wanted to do was read its values, not set its values.
Heres what I'm up to :
Code:
// Sets initial array
var ButtonOrder = new Array("One", "Two", "Three", "Four");
// Makes a backup of the initial array
ButtonOrderBackup = ButtonOrder;
// Changes the initial array with values from the backup
// (This is where I think the problems at)
ButtonOrder[0] = ButtonOrderBackup[3];
ButtonOrder[1] = ButtonOrderBackup[2];
ButtonOrder[2] = ButtonOrderBackup[1];
ButtonOrder[3] = ButtonOrderBackup[0];
// Trace Backup array
for (i = 0; i < ButtonOrderBackup.length; i++)
{
trace("Backup " + i + " " + ButtonOrderBackup[i]);
}
trace("");
// Trace initial array
for (i = 0; i < ButtonOrder.length; i++)
{
trace(i + " " + ButtonOrder[i]);
}
trace("");
Heres what the debugger feeds back to me :
Code:
Backup 0 Four
Backup 1 Three
Backup 2 Three
Backup 3 Four
0 Four
1 Three
2 Three
3 Four
I was wanting the initial array to have the values: Four, Three, Two, One. And the backup array to be how it was originally : One, Two, Three, Four.
What have I done wrong, thank you.
Populate An Array Values From An Array
ok i have this xml file
Code:
<artworkinfo>
<movieinfo>
<artLocation>cover1.jpg</artLocation>
<movie>Live Free or Die Hard</movie>
<plot>John McClane takes on </plot>
</movieinfo>
<movieinfo>
<artLocation>cover2.jpg</artLocation>
<movie>Meet the Robinsons</movie>
<plot>Lewis is a brilliant inventor </plot>
</movieinfo>
</artworkinfo>
the xml will tell where the cover art is the movie title and plot.
i want to populate my movie with this info what is the best approach to create empty movieclips using actionscript or create individuals MC , i try the second one and create 4 movieclips (cause the xml have 4 elements just post 2) and make an array of mc but i can find how to match the xml array to the mc array , this is the code for better explaining,
Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
movie = [];
plot = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
movie[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
plot[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
}
placeholder=new Array(loader1,loader2,loader3,loader4);
placeholder_total = placeholder.length;
for (e=0; e<placeholder_total; e++){
placeholder[e].contentPath=this.image[i];
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("movieinfo.xml");
the stage have 4 movieclips name loader1,loader2,ect... each mc have 2 dynamic text field one for title and one for the plot.
|