Trouble With Web Service That Returns An Array Of Arrays
Hello,
I have a project thats dealing with making SOAP calls to various web services. One in particular returns an array of arrays for the logged in user. When I do a trace() on the return, it traces out as [object Object]. So I assume that this is the Main Array. Everything I do to try and access the contents traces out as undefined. Hope this makes sense. I am unable to post the exact code due to my clients security concerns.
Thanks for any help you can offer.
~squirt
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 06-16-2008, 08:00 PM
View Complete Forum Thread with Replies
Sponsored Links:
Flash Service Returns Undefined
hi
I’m having troubles with the use of flash remoting
I have a class called daoZoek. this class is the data accessor for searching members in a database using flash remoting. Everything worked before but yesterday I decided to place my classes in folder (be.wellconsidered.dao instead of be.wellconsidered.*) so the project has a better structure.
But since then, this class doesn’t work anymore. The strange thing is that I have a similar class to register, edit and login members and that class still works as it should be
so, the problem with daoZoek is the service. when I try to trace “zoekService” it returns “undefined” which is strange because daoLid (for registering, login and edit) is just the same.
also, the gateway path and the service path are correct as well as the methodname.
this is the code
ActionScript Code:
import be.wellconsidered.*;
import be.wellconsidered.dao.*;
import mx.remoting.*;
import mx.services.*;
import mx.rpc.*;
import mx.remoting.debug.*;
//
class be.wellconsidered.dao.daoZoek extends MovieClip {
// VARS
private static var instantie:daoZoek = new daoZoek();
private static var zoekService;
// CONSTRUCTOR
private function daoZoek() {
// SERVICE INIT
zoekService = new Service("http://localhost/__flashservices/gateway.php", null, "WT.Zoeken", null, null);
trace(zoekService);
}
// GETDAOLID
public static function getInstance():daoZoek {
if (instantie == null) {
instantie = new daoZoek();
}
return instantie;
}
/* --ZOEK ALL LEDEN-------------------------------------------------------------------------------- */
public function zoekLid(o:Object, onResult:String, onFault:String, search_term:String):Void {
var pc:PendingCall = zoekService.zoekLeden(search_term);
pc.responder = new RelayResponder(o, onResult, onFault);
}
}
View Replies !
View Related
AMFPHP - Call Returns 'nothing' In Service Browser
Hi everybody
I have been using amfphp for a while now and deployed it in quite a few projects with no major complications.
However, now I face an issue I have never come across before and was hoping that someone could help me out.
when i test the functionality of amfphp in the service browser, I can make any call but always get the same return, which is
"amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.Note: ... bla bla"
This is very odd, and I have no idea why it returns this string. Everything works fine locally of course.
Does anyone have a clue of whats going on here
Really appreciate it
Thanks
Juergen
View Replies !
View Related
Web Service Syntax ? And Arrays...
I'm calling a web service that returns an array. I have a function that just displays the result returned. I'm getting [object, object] when I trace the result. How do I pull a variable returned from the array like city? I've tried;
details.onResult=function(result){
trace(result.city); // equals undefined
trace(result); // equals [object, object]
}
please help;
what am i missing
View Replies !
View Related
Trouble Communicating With Document-Style Web Service
I have a flash app that currently communicates with a RPC-style web service. I changed the web service to be document-style, and the flash app no longer sends valid requests. I was under the impression that one could simple swtich styles, and flash would play along. Apparently, this is not the case. Does anyone have an insight in this area?
View Replies !
View Related
Trouble Connecting To Flash Streaming Service
does anyone happen to use Playstream and have some advice? I'm trying to connect with the attached code and I'm getting the following error message:
Error opening URL 'rtmpe://fvss.playstream.com/fvssod/escstream/Irish_Dancing/Two-HandJig_56k'
Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound
at testPlayer_fla::MainTimeline/frame1()
View Replies !
View Related
Web Service Array Deserialization
Hello everyone,
A web service has been developped with gSoap. I import the WSDL and the calls and arguments are exactly as expected. Nonetheless I have problem getting arrays from this server. For info I use the WS API.
Here is the response that I get (using trace(myWScall.response) ) :
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="
View Replies !
View Related
Array Returns Undefined Outside For Each
I'm working in Flash CS3 and i want to read data from XML which works fine. I want to add this data to an array (N-rows with 4 columns). Problems occur when i want to access the saved data in another "for" stage.
ActionScript Code:
var Content:Array = new Array(); // this is the container for the rows,if i'm not mistaken
var answerA:String = "";
var answerB:String = "";
function handlerTest(event:Event):void {
var loader:URLLoader=URLLoader(event.target);
var myXML:XML=new XML(loader.data);
myXML.ignoreWhite=false;
for each (var child:XML in myXML.*) {
var i:int = 0;
Content[i] = new Array (child, child.@answer, answerA, answerB);
trace(Content[i]); // this trace outputs everything as it should
i++;
}
// next i want to add contents into textfields
for (var j:int = 0; j < 10; j++) {
var rb:TextField = new TextField();
rb.text = Content[j][0]; // this produces error since there is no data
trace(Content[j]); // this returns undefined for each loop
trace(Content[j][0]); // this also doesn't return the values that i stored into the array above
addChild(rb);
}
}
am i doing something wrong?
View Replies !
View Related
Array Size Returns 0
I'm having some issues with the following code:
Code:
gallery_category = "Category Number 1";
gallery_conf_file = "gallery.txt";
gallery_titles = new Array();
gallery_sizes = new Array();
gallery_descriptions = new Array();
gallery_thumbnails = new Array();
gallery_images = new Array();
gallery_popups = new Array();
var l = new LoadVars();
l.onLoad=function(done) {
if(done) {
gallery_titles = this.gallery_titles.split(", ");
gallery_sizes = this.gallery_sizes.split(", ");
gallery_descriptions = this.gallery_descriptions.split(", ");
gallery_thumbnails = this.gallery_thumbnails.split(", ");
gallery_images = this.gallery_images.split(", ");
gallery_popups = this.gallery_popups.split(", ");
}
};
l.load(gallery_conf_file);
trace("Images ->");
trace(gallery_titles.length);
The length of the array gallery_titles always returns 0. The array is populated though showing the correct data from the text file when I run the debug movie thingy. The arrays seem to be on _level0 - is this OK? though even when I use trace(_level0.gallery_titles.length); It still returns 0.
Any help would be fantastic - cause I cant really get any further with this project until I can get to the array size :-(
View Replies !
View Related
Web Service Array Result Undefined
Hi all, this seems to be some problem with the web service or flash web service connector, I tried to call methods from the web service, if the method returns a single result then flash WS Connector process it correctly, but if the method returns an array the results always undefined! So could anyone show me what the problem is?
Code:
import mx.data.components.WebServiceConnector;
import mx.services.*;
/*--------------------------Get Params from html page ----------------------------*/
_level0.wsUrl = _level0.Id;
if (_level0.wsUrl == undefined || _level0.wsUrl == undefined ) {
_level0.wsUrl = "http://xxxx/yyyy?wsdl";
}
var ws:WebServiceConnector = new WebServiceConnector();
ws.WSDLURL = _level0.wsUrl;
ws.operation = "getNumber";
ws.suppressInvalidCalls = false;
ws.params = [param_txt.text];
new Binding({component:ws, property:"results", event:["result"]}, {component:dg, property:"dataProvider"});
var wsListener:Object = new Object();
wsListener.result = function(evt:Object) {
trace(" wsListener " + evt.target.results); /*always undefined here*/
text_a.text += " wsListener " + evt.target.results;
trace("datagrid " +dg.dataProvider.length + " " + dg.dataProvider[0]);
text_a.text += "
datagrid length" +dg.dataProvider.length + " " + dg.dataProvider[0]
trace("datagrid " + dg.getItemAt(0));
text_a.text += "
datagrid.getItemAt(0) " + dg.getItemAt(0);
}
ws.addEventListener("result",wsListener);
My web service in Jboss
Code:
@WebMethod
@WebResult(name = "numbers")
public int[] getNumber(@WebParam(name = "userName") String sth) {
int[] number = new int[3];
number[0] = 7;
number[1] = 2;
number[2] = 3;
System.out.println("Get Number call");
log.info("ARRAY METHOD CALLED " + number.length);
return number;
}
Thanks in advance
View Replies !
View Related
Passing Array Of Objects Through Web Service To CFC
I am actually doing this in Flex but I think my issue lies in my AS.
I am trying to build an array of objects to pass to a CFC method using web services. Currently I am receiving a SOAP error stating ...nested exception is: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType]
My array of objects (currently with onyl 1 object) looks like this:
Parameter 1:
name : aAssignments
type : anyType
value[array] :
length[Number] : 1
[0][object] :
NUMASSIGNMENTID[Number] : 2932
NUMLEVELOFEFFORT[Number] : 50
NUMPERSONNELID[Number] : 121
NUMPROJECTID[Number] : 3
TXTPROJECTNAME[String] : Done Deals
YNLEAD[Boolean] : true
My suspicion is that I am not building my array of objets correctly. Here is what I am doing:
var sourceProvider:Object = event.dragSource._data.source.dataProvider;
aProjects = new Array();//clear out the array each time
//loop through the items in the data provider and and add each item to the array
for(var i = 0; i <sourceProvider.length; i++){
aAssignments.push(sourceProvider[i])
}
I think my problem might lie in sourceProvider[i]. I know that if I trace sourceProvider[i].numProjectID, It will successfully trace that value. And after this loop is run I can trace aAssignments.numProjectID.
Does this look correct?
View Replies !
View Related
Deserialize An Array Of Objects From A Web Service
Hi, I'm calling a webservice method which returns an array of objects (let's
say classes called MyClass).
I now want to define a class in actionscript called MyClass which matches
the properties of the class defined in the web service (written in .NET),
call the webservice method, and then deserialize the result in actionscript
into an array of type MyClass.
The code I have so far is:
import mx.services.WebService;
import mx.services.Log;
var mylog:Log = new Log(Log.DEBUG);
myLog.onLog = function(txt) {
trace(txt);
};
var ws:WebService = new WebService(wsc.WSDLURL);
ws.onLoad = function(wsdl) {
MyPendingCallObject =
ws.CallTheWebServiceMethodWhichReturnsAnArrayOfMyClasses();
MyPendingCallObject.onResult = function(result)
{
trace(result);
// HOW CAN I DESERIALIZE the result parameter into an Array of
MyClass ???
}
MyPendingCallObject.onFault = function(fault)
{
trace('FAULT! ' + fault.faultCode + "," + fault.faultstring);
}
};
// If the WSDL fails to load the onFault event is fired.
ws.onFault = function(fault) {
trace(fault.faultstring);
};
TIA
View Replies !
View Related
Submitting An Array To A Web Service Through Flash
Hey Guys,
I'm having a small issue with submitting an object through an array to a web service in flash. I've submitted objects to a different web service before with no problems, and I've submitted the params that aren't part of the object with no problems before, but I can't seem to get the format right for submitting the object as part of an array (Important because eventually there will be multiple objects in that array).
My code is thus:
ActionScript Code:
triggerWebService = function () { trace("triggerWebService()"); var RMAItems:Array = new Array(); for (var i:Number = 0; i<=currPlus; i++) { var RMAItem:Object = new Object(); //RMAItem.SoldItem = eval("mainContent.specs.product"+i).text; //RMAItem.SerialNumber = eval("mainContent.specs.serial"+i).text; RMAItem.SoldItem="Sold Item" RMAItem.SerialNumber=123456 RMAItem.WarrantyNumber = 22222; RMAItems.push([RMAItem]); if (i == currPlus) { this._parent.rmaSubmit_ws.params = [mainContent.specs.firstName.text, mainContent.specs.lastName.text, mainContent.specs.address1.text, mainContent.specs.address2.text, mainContent.specs.city.text, mainContent.specs.stateName.text, mainContent.specs.zip.text, mainContent.specs.country.text, mainContent.specs.phone.text, mainContent.specs.email.text, "BACK", "TEST guiID", mainContent.specs.summary.summary.text, RMAItems]; //trace(this._parent.rmaSubmit_ws.params) this._parent.rmaSubmit_ws.trigger(); } }};
The web service is:
http://wsnew.sp.cm3consulting.com/smartparts.asmx?WSDL
and the method that is being called is:
AddRMAFromForm()
Be aware that there are a few methods with very similar names
And if you do any testing with submitting on the actual web service please populate the fields with definite "test" names as it goes to the actual database. If anyone can give me any help on the proper format or what I'm doing wrong, it would be greatly appreciated.
Here is the function that is called when results are received in the web service. The resulting RMA number should be a unique integer... Not "0".
ActionScript Code:
rmaResult = function (ev:Object):Void { trace("Results received"); var rmaNum = ev.target.results.RMANumber; trace(ev.target.results.ErrorDescription); trace(ev.target.results.StackTrace); trace(ev.code); trace(rmaNum); trace(ev.target.results.RMANumber);}
thanks very much,
-iLan
View Replies !
View Related
Accessing Array Returns Undefined
Hi Guys,
Having a bit of a problem accessing an array and looking for some help
Basically I'm trying to create a Media Player, and one of the functionalities is to select chapters etc.
I'm using seperate ActionScript files, one of which is completely for chapters.
I've bolded the lines of code causing me issues, basically I am calling a function to get all of the chapters for a selected movie. This returns an array of chapters, but when I try and loop through it using the good old i++, it returns undefined.
If I manually type the number, i.e ( chapters[1] ) it returns the value of that particular item.
Very strange and frustrating, any ideas?
The code is below.
Code:
// Define Chapters
class Actions.chapters {
// Constructor function that is called from external swf file
public function chapters() {
}
// Method for loading chapters
public function selectMovie(movieName:String) {
switch (movieName) {
case "movie01_ReasonsToRegister":
return "movie01_ReasonsToRegister";
break;
default :
return "movie01_ReasonsToRegister";
}
}
// Method for loading chapters
public function selectChapters(movieName) {
switch (movieName) {
case "movie01_ReasonsToRegister":
var chapterArray:Array = new Array();
chapterArray[0] = "chapter01";
chapterArray[1] = "chapter02";
return chapterArray;
break;
default :
var chapterArray:Array = new Array();
chapterArray[0] = "chapter01";
chapterArray[1] = "chapter02";
return chapterArray;
}
}
// Method for getting next chapter
public function getNextChapter() {
var outputText:Number;
var movieName:String = selectMovie("movie01_ReasonsToRegister");
var chapters:Array = selectChapters(movieName);
trace(chapters); // output: chapter01,chapter02
var i:Number = 0;
var len:Number = chapters.length;
while (i++ < len) {
trace(chapters[i]); // output: undefined
trace(chapters[0]); // output: chapter01
trace(chapters[1]); // output: chapter02
}
}
}
View Replies !
View Related
Variable That Returns All Values Of An Array
This is a simple question I know, I have searched threads and google for answer with no luck.
Within my tween function I want to declare a variable that returns all values of an array (my array holds several mc instance names). Currently I can successfully return a single value from my array like this:
ActionScript Code:
function tweenArrayValues() {
easeType = mx.transitions.easing.Regular.easeIn;
var begin = 0;
var end = 100;
var time = 4;
var mc = myArray[2];
ballTween = new mx.transitions.Tween(mc, "_alpha", easeType, begin, end, time, true);
}
this.onEnterFrame = tweenArrayValues();
I just want all values in array returned. I have tried myArray() and myArray(index) with no luck. Any ideas?
View Replies !
View Related
Accessing Array Returns Undefined
Hi Guys,
Having a bit of a problem accessing an array and looking for some help
Basically I'm trying to create a Media Player, and one of the functionalities is to select chapters etc.
I'm using seperate ActionScript files, one of which is completely for chapters.
I've bolded the lines of code causing me issues, basically I am calling a function to get all of the chapters for a selected movie. This returns an array of chapters, but when I try and loop through it using the good old i++, it returns undefined.
If I manually type the number, i.e ( chapters[1] ) it returns the value of that particular item.
Very strange and frustrating, any ideas?
The code is below.
Code:
// Define Chapters
class Actions.chapters {
// Constructor function that is called from external swf file
public function chapters() {
}
// Method for loading chapters
public function selectMovie(movieName:String) {
switch (movieName) {
case "movie01_ReasonsToRegister":
return "movie01_ReasonsToRegister";
break;
default :
return "movie01_ReasonsToRegister";
}
}
// Method for loading chapters
public function selectChapters(movieName) {
switch (movieName) {
case "movie01_ReasonsToRegister":
var chapterArray:Array = new Array();
chapterArray[0] = "chapter01";
chapterArray[1] = "chapter02";
return chapterArray;
break;
default :
var chapterArray:Array = new Array();
chapterArray[0] = "chapter01";
chapterArray[1] = "chapter02";
return chapterArray;
}
}
// Method for getting next chapter
public function getNextChapter() {
var outputText:Number;
var movieName:String = selectMovie("movie01_ReasonsToRegister");
var chapters:Array = selectChapters(movieName);
trace(chapters); // output: chapter01,chapter02
var i:Number = 0;
var len:Number = chapters.length;
while (i++ < len) {
trace(chapters[i]); // output: undefined
trace(chapters[0]); // output: chapter01
trace(chapters[1]); // output: chapter02
}
}
}
View Replies !
View Related
Accessing Array Returns Undefined
Hi Guys,
Having a bit of a problem accessing an array and looking for some help
Basically I'm trying to create a Media Player, and one of the functionalities is to select chapters etc.
I'm using seperate ActionScript files, one of which is completely for chapters.
I've bolded the lines of code causing me issues, basically I am calling a function to get all of the chapters for a selected movie. This returns an array of chapters, but when I try and loop through it using the good old i++, it returns undefined.
If I manually type the number, i.e ( chapters[1] ) it returns the value of that particular item.
Very strange and frustrating, any ideas?
The code is below.
Code:
// Define Chapters
class Actions.chapters {
// Constructor function that is called from external swf file
public function chapters() {
}
// Method for loading chapters
public function selectMovie(movieName:String) {
switch (movieName) {
case "movie01_ReasonsToRegister":
return "movie01_ReasonsToRegister";
break;
default :
return "movie01_ReasonsToRegister";
}
}
// Method for loading chapters
public function selectChapters(movieName) {
switch (movieName) {
case "movie01_ReasonsToRegister":
var chapterArray:Array = new Array();
chapterArray[0] = "chapter01";
chapterArray[1] = "chapter02";
return chapterArray;
break;
default :
var chapterArray:Array = new Array();
chapterArray[0] = "chapter01";
chapterArray[1] = "chapter02";
return chapterArray;
}
}
// Method for getting next chapter
public function getNextChapter() {
var outputText:Number;
var movieName:String = selectMovie("movie01_ReasonsToRegister");
var chapters:Array = selectChapters(movieName);
trace(chapters); // output: chapter01,chapter02
var i:Number = 0;
var len:Number = chapters.length;
while (i++ < len) {
trace(chapters[i]); // output: undefined
trace(chapters[0]); // output: chapter01
trace(chapters[1]); // output: chapter02
}
}
}
View Replies !
View Related
Targeting An Array In A Movie Clip Returns NAn
ActionScript Code:
//in function, function executes itself
_root.universal.propertyinfo["Art Museum"]["buypay"] = 400
//in onRelease for an mc, then in a function() in an array which is in the parameter of another function
calc((_root.universal.propertyinfo["Art Museum"]["buypay"]), -1, "*")
/*
calc calculates numbers without Number()
trace(calc(1, 1, "+")) //traces 2
trace(calc(2, 4, "*")) //traces 8
*/
What is my problem? It seems like it should work, but the calc() returns nAn!
View Replies !
View Related
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.
View Replies !
View Related
Arrays In Arrays Trouble
does AS3 have capability to do multidimensional arrays? My computer won't let me download it because I have edu version. 2D arrays would make this a lot easier. Here's the class:
Code:
class com.samainsworth.math.matrix {
var arr:Array;
var r:Number;
var c:Number;
public function matrix(r:Number, c:Number) {
this.arr = new Array(c);
for(var i in this.arr) {
this.arr[i] = new Array(r);
}
this.r = r;
this.c = c;
}
public function getPos(r:Number, c:Number) {
return this.arr[c][r];
}
public function fillPos(val, r:Number, c:Number):Boolean {
if(r <= this.r && c <= this.c) {
this.arr[c][r] = val;
return true;
}
else {
return false;
}
}
}
here's the code in the movie:
Code:
import com.samainsworth.math.matrix;
var m:matrix = new matrix(2, 2);
trace(m.fillPos(1, 0, 0));
m.arr[0][0] = 1;
trace(m.getPos(0, 0));
and last but not least here's error:
Code:
true
undefined
I'm trying to work on 3D which requires a lot of matrices work even though flash doesn't support 3D you can fake it with a lot of math - http://www.kirupa.com/developer/actions ... onCube.swf
View Replies !
View Related
Trouble With Arrays
Okay, here's the deal...I'm developing a dynamic event calendar in Flash. You can view the results of what I've done so far at http://www.pacosvillage.com/home.html
You'll see there that each event has a date/title, a description and has a link attached. There are 20 events in all...
The way this works is that I have variables named date1,date2,date3,event1,event2,event3,url1,url2,u rl3, etc...They are loaded from a text file.
I am working on the admin interface and I am trying to load those variables into arrays like this:
date = new Array();
event = new Array();
url = new Array();
date[0] = "";
date[1] = date1;
date[2] = date2;
date[3] = date3;
date[4] = date4;
date[5] = date5;
date[6] = date6;
date[7] = date7;
date[8] = date8;
date[9] = date9;
date[10] = date10;
date[11] = date11;
date[12] = date12;
date[13] = date13;
date[14] = date14;
date[15] = date15;
date[16] = date16;
date[17] = date17;
date[18] = date18;
date[19] = date19;
date[20] = date20;
event[0] = "";
event[1] = event1;
event[2] = event2;
event[3] = event3;
event[4] = event4;
event[5] = event5;
event[6] = event6;
event[7] = event7;
event[8] = event8;
event[9] = event9;
event[10] = event10;
event[11] = event11;
event[12] = event12;
event[13] = event13;
event[14] = event14;
event[15] = event15;
event[16] = event16;
event[17] = event17;
event[18] = event18;
event[19] = event19;
event[20] = event20;
url[0] = url1;
url[1] = url1;
url[2] = url2;
url[3] = url3;
url[4] = url4;
url[5] = url5;
url[6] = url6;
url[7] = url7;
url[8] = url8;
url[9] = url9;
url[10] = url10;
url[11] = url11;
url[12] = url12;
url[13] = url13;
url[14] = url14;
url[15] = url15;
url[16] = url16;
url[17] = url17;
url[18] = url18;
url[19] = url19;
url[20] = url20;
Please tell me what is wrong with that code!!! It loads the variables from the text file fine, but it won't seem to put the info into the arrays.
Check http://www.pacosvillage.com/test.htm and use the passord 'test' to enter the test admin I'm working on. You will see that I have it stop and show what some of the variables are showing. This is already after I've run the code above. Once you hit 'Next' you will see how I'm building the admin.
What am I doing wrong?
View Replies !
View Related
Trouble W/ Pop() And Arrays
just for reference, ill post the whole script:
function createDeck(){
function card(value, suite){
this.value=value
this.suite=suite
}
deck=new Array()
for(a=0; a<4; a++){
for(b=0; b<9; b++){
deck[deck.length]=new card(b, a)
}
}
}
function shuffle(deck){
shuffleDeck=new Array()
for(c=0; c<deck.length; c=0){
rand=int(random(deck.length))
deck.splice(rand, 1)
}
}
function deal(){
handOne=new Array()
for(i=0; i<6; i++){
handOne[i]=shuffleDeck.pop()
}
}
createDeck()
shuffle(deck)
deal()
the most important part is the deal() function. as u know by now, all teh arrays are filled with card objects. ive been able to read their values in the deck array and in the shuffle deck array. however, once it reaches handOne, i can no longer read them. i can see that handOne has a length of 6, but what is it being filled with?
i can no longer set a variable to say handOne[i].value. what has pop() done?
View Replies !
View Related
Trouble With Arrays
I have 10 dynamic text boxes, named with the variables number1 thru 10.
I am loading an xml file that contains the text I would like to put in the boxes, I can hardcode it fine, but I am trying to do it dynamically (eventually build and populate the text boxes to the length of the xml.
code: var computerNum = new Array();
var computerName = new Array();
for (var x = 0; x < myDocument.childNodes[0].childNodes[0].childNodes.length; x++) {
var number = ["number" + (x+1)];
computerNum.push(number);
var cName = numberComp[x].attributes.NUMBER;
computerName.push(cName);
};
computerNum is the variables: number1 thru 10
computerName is the information from the xml EC1 tru EC10
it seems the arrays are containing the information, but how do I get computerNum to = ComputerName without setting computerNum to EC1.
technically something like
var number1 = numberComp[0].attributes.NUMBER;
var number2 = numberComp[1].attributes.NUMBER;
var number3 = numberComp[2].attributes.NUMBER;
but without having to type them all out
hope this makes sense
thanks
IMS
View Replies !
View Related
[F8] Trouble With Arrays
Hello fine folks.
I'm having a problem with putting some buttons in an array, so I can avoid writing the same script for 10 buttons (and also just so I become a better actionscripter).
Basically instead of writing
PHP Code:
button1.onRelease = function() {
trace("do something amazing!")
}
button2.onRelease = function() {
trace("do something amazing!")
}
button3.onRelease = function() {
trace("do something amazing!")
}
//etc, etc, etc
What I'd LIKE to do is:
PHP Code:
allButtons.onRelease = function() {
trace("do something amazing! The whole lot of you!")
}
I've looked up some tutorials online, and I have a great book, but it always seems to want to do deal with text in Arrays, not objects. But here's what I've gleaned/tried:
PHP Code:
allButtons = new Array(button1, button2, button3);
for allButtons = function() {
trace("do something amazing! The whole lot of you!")
}
I also tried:
PHP Code:
allButtons = new Array(button1, button2, button3);
allButtons.onRelease = function() {
trace("do something amazing! The whole lot of you!")
}
Neither work, so obviously, I'm doing it wrong. Any help? Many thanks!
View Replies !
View Related
Trouble With Arrays
$county_name = "Albany";
$county_votes = array( "$county_name" => array("0" => array( "votes" => 2, "topic" => "Jobs")));
Aright, I'm praying to find an ActionScript variant of this. I don't expect you guys to know anything about PHP... BUT, I've heard arrays in PHP and arrays in ActionScript are very similar and the example is pretty self-explanatory.
While I have some experience with ActionScript arrays, I'm not aware of it's limitations compared to PHP. I'm having a severe amount of trouble converting this PHP into it's similar ActionScript form.
What my trouble has lead me to believe is that ActionScript arrays can't be labeled by a variable holding a string. I'm outputting all the data from that PHP array into Flash(which I can do fine with loadVars), but I can't seem to get anything working right. I'm pretty sure I'm just doing something stupid.
Could anyone please help me out?
View Replies !
View Related
Trouble With Arrays
I need a piece of code that lets me go from an array with a whole name (for example "rodrigo") to another array that only contains the letters without including the repeated letters. So in this case, from "rodrigo" the new array would show "rodig" (because the R and O are repeated).
i got this, that u may find useful:
word = "rodrigo";
// to separate each letter of "rodrigo".
letters = new Array();
// the array that will be used to store "rodig"
separate = new Array();
// to separate each letter of the word and store it in the array.
for(i=0;i<word.length;i++){
letters[i]=word.charAt(i)
}
if you trace letters now u'll see that u get: r,o,d,r,i,g,o
Well, now i need the other part of the code that will allow me to trace "separate" and get in the output: r,o,d,i,g.
I think that it can be done with nested for loops, i've been trying but I can't get it!
-.-.-.-
Thanks, I hope I've been clear (as English is not my first language).
Any doubts? mail me, or send private message.
View Replies !
View Related
Trouble With Arrays
function EnemyStats (EnNum) {
Enemies[EnNum][0] = Trooper[0];
trace (EnNum);
}
Enemies[EnNum][0] keeps coming up as undefined. I've tried adding a return statement but that didn't change anything.
Do I need to make Enemies[EnNum] into an array first? EDIT: Ok I tried declaring Enemies[EnNum] as an empty array but that didn't work
View Replies !
View Related
Trouble With Arrays And Strings
I made a hang man game with only one word.
I then made an array of the rightLetters: rightLetter[0] = "d";
and one of the textFields: textFields[0] = rightGuess1_txt;
I wrote a function for a mouse click and in that function :
when I enter a "d" into the guest_textField it appears in the appropriate text field but that is the only one that works.
What's going wrong?
the code is as follows:
stop();
var rightLetter:Array = new Array()
rightLetter[0] = "d";
rightLetter[1] = "e";
rightLetter[2] = "s";
rightLetter[3] = "s";
rightLetter[4] = "e";
rightLetter[5] = "r";
rightLetter[6] = "t";
trace(rightLetter);
var textFields:Array = new Array()
textFields[0] = rightGuess1_txt;
textFields[1] = rightGuess2_txt;
textFields[2] = rightGuess3_txt;
textFields[3] = rightGuess4_txt;
textFields[4] = rightGuess5_txt;
textFields[5] = rightGuess6_txt;
textFields[6] = rightGuess7_txt;
submitButton_mc.buttonMode = true;
//listens for a mouse click and names its function
submitButton_mc.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
{
// reads the input that the user entered
var guess:String = guess_txt.text;
// checks to see whether it is correct by looping through all correct letters
for (var i:int = 0; i < rightLetter.length; i++)
{
// if it is correct
if (guess == rightLetter[i])
{
// puts the letter in the appropriate answer fields
textFields[i].text = guess;
}
}
View Replies !
View Related
Trouble With XML And Arrays (I Am Stumped...)
I am working on a site where a gallery is shown in a flash file that loads external jpgs and uses an array in order to create the thumbs of the images and then show each of them when clicked.
The file works fine if I define the array content internally, but I want it to be loaded from an external XML file so it can be easily updated without touching the Flash file every time.
I came up with this for the XML part so far:
import mx.utils.Delegate;
var photoxml:XML = new XML();
var picnames:Array = new Array();
function onXmlLoaded(success:Boolean) {
if (success) {
for (var j:Number = 0; photoxml.childNodes [j] != null; j++) {
picnames[j] = photoxml.childNodes[j].attributes.nome;
NPICS = j;
var XPICS:Number = picnames.length;
}
}
}
function init2() {
photoxml.ignoreWhite = true;
photoxml.onLoad = Delegate.create(this, onXmlLoaded);
photoxml.load("pics.xml");
}
init2();
which was modeled on other examples I found (I am not an expert at all under this respect.)
What happens now is that the Flash doesn't work (obviously, or I wouldn't be here...); running the debugger and asking for a listing of the variables I find that:
Variable _level0.photoxml = [object #14] {
<?xml version="1.0" encoding="utf-8"?>
<photo nome="sfl01" />
<photo nome="sfl02" />
<photo nome="sfl03" />
<photo nome="sfl04" />
<photo nome="sfl05" />
<photo nome="sfl06" />
<photo nome="sfl07" />
<photo nome="sfl08" />
<photo nome="sfl09" />
<photo nome="sfl10" />
}
Variable _level0.picnames = [object #15, class 'Array'] [
0:"sfl01",
1:"sfl02",
2:"sfl03",
3:"sfl04",
4:"sfl05",
5:"sfl06",
6:"sfl07",
7:"sfl08",
8:"sfl09",
9:"sfl10"
]
which seems to be the result I am looking for (when testing with an internal array my code was:
var picnames:Array = [
"sfl01",
"sfl02",
"sfl03",
"sfl04",
"sfl05",
"sfl06",
"sfl07",
"sfl08",
"sfl09",
"sfl10"
];
which looks pretty much the same to me), but for some reason, if I ask to
trace (_level0.picnames.length);
it returns 0 as a result, as if the array was completely empty.
At this point I am completely stumped: is there anyone here who can tell me what am I doing wrong? I would greatly appreciate any input, thanks.
View Replies !
View Related
Trouble With Arrays And Dynamic Textfields
In my first frame I have this code:
myarray = new Array();
myarray[0] = "_";
myarray[1] = "_";
myarray[2] = "_";
myarray[3] = "_";
myarray[4] = "_";
myarray[5] = "_";
nummer = myarray[0]
+ myarray[1]
+ myarray[2]
+ myarray[3]
+ myarray[4]
+ myarray[5];
stop();
nummer is a dynamic textfield. Then I have a button. The button's code is like this:
on (release) {
myarray[5] = 1;
gotoAndStop(2);
}
But when the player reaches the second frame, the dynamic textfield still looks like ______ and not like the desired _____1. What is wrong?
View Replies !
View Related
For Loop - Trouble Accessing Arrays
Okay, bare with me,
I have two arrays, xArray holding x coordinates and yArray holding y coordinates.
A new coordinate is added to each array upon a button on (release).
Upon another button on (release) the variable 'clicked' is set to true and the speed variable is set to 10.
The idea being that when clicked = true, my movie clip 'scitter' rotates and moves to the first set of coordinates and then the next etc.
It doesn't, can anybody help?
I'm using the code below, the for loop should access the same position in
both arrays as they are the same length.
if (clicked) {
for (n=0; n<_root.scitter.xArray.length; n++) {
{// calculate angle to next target
gotoSpotX = _root.scitter.xArray[n] ;
gotoSpotY = _root.scitter.yArray[n] ;
delta_x = _x-gotoSpotX;
delta_y = _y-gotoSpotY;
targetRotation = -Math.atan2(delta_x, delta_y)/(Math.PI/180);
_rotation = targetRotation;
}// move to clicked spot
if (Math.sqrt((delta_x*delta_x)+(delta_y*delta_y))>sp eed) {
_y -= speed*Math.cos(_rotation*(Math.PI/180));
_x += speed*Math.sin(_rotation*(Math.PI/180));
}
}
}
I originally had this obtain it's initial x,y coordinates from a mouse click as per the MX example and it worked fine. So I should be able to substitute these coordinates with my coordinates from the array, I assume that there is something wrong with the way I have written the loop.
Any help would be most appreciated, (pulling my hair out).
View Replies !
View Related
Trouble With Loops And Reading From Arrays
I've got the following code that I want to (eventually) expand so that it creates a load of combo box menus. As I will be updating the list a bit I figure it's better to store the data in an array and have it dynamically generate the combo boxes.
Here's my code so far:
Code:
menu1 = new Array("Europe","Albania","England","Georgia","Italy","Romania","Russia","Spain","Ukraine");
menu2 = new Array("Middle East","Iran","Jordan","Kuwait","Lebanon","Saudi Arabia","Syria","Turkey","U.A.E.","Yemen");
var i=0;//setup counter for menus
while (i++ < 3) {//loop through menus
trace ("len="+['menu'+i].length);
var h=0;//set up counter var
while (h++ < ['menu'+i].length) {//go through each item in array
trace ("h="+h);
}
}
The problem I have at the moment is with the ['menu'+i] I'm pretty sure I screwed up somehow, what I am after is that by combining the string 'menu' with the var i I can address each array - menu1, menu2, etc. But the trace on this shows that flash thinks that the length of the array is 1 and not what it actually is. Obviously I need to sort this to get my second loop (which goes through each item) working.
Another problem I'm having is getting flash to dynamically work out how many arrays named menuxx there are. I've seen this done as:
Code:
while(this['menu'+i])
But that seems not to work for me - any reasons why this would be?
Thanks for any help
Alex
View Replies !
View Related
Web Service Param Is An Object Inside And Array Which Is An Object
Howdy. This is my first time on this forum, and I hope I get more help here than some of the other forums. I'll try to explain my dillema as simply as possible.
I have a webservice. I am calling a method 'InsertSlide'. That method requires and object as the paramater.
the object shcema looks like this:
Object
-SlideID (integer)
-Name (integer)
-SlideTypeID (integer)
-Hits (integer)
-LocationID (integer)
-SwfFileName (integer)
-SlideDataCollection (Array)
- -N (Object)
- - -Label
- - -Value
I hope that makes sense, all I'm trying to get at, is there is an object with an array as a property, that array is populated with an object and it has properties.
I recieve that same ojbect from the webservice fine, but when I send that object like that to the Webservice it does not fully populate my databases, unfortunatly I did not write the webservice.
Is it possible that the problem is the webservice? or flash?
Thanks for any help!
- Kiwi
View Replies !
View Related
Array Returns "undefined" In Output?
On the timeline, I set up an array with 'section' names. When the mouse is clicked, a listener traces the section name to output.
Code:
var pageName:Array = new Array();
pageName [0] = "newsHolder";
pageName [1] = "aboutHolder";
pageName [2] = "reelHolder";
pageName [3] = "printHolder";
pageName [4] = "radioHolder";
pageName [5] = "miscHolder";
pageName [6] = "contactHolder";
(...)
trace ("New page selected "+pageName[selPageNum]);
trace ("Instance name is "+pageName[selPageNum]);
trace ("Current name is "+pageName[curPageNum]);
That works fine. But I also have a button on the stage:
Code:
on (release) {
trace ("testing "+pageName [0]);
}
But this returns "testing undefined".
Where am I screwing up?
View Replies !
View Related
[F8] An Array Of Arrays
I'm loading a number of arrays from a text file. I want each of those arrays to be loaded into another array. The number of arrays may change depending on the info in the text file. How can I dyamically create the array of arrays?
Example:
My textfile
&thisTitle=Clothing - La ropa&
&arr_p1=boots|las botas|las botas|las botas|las botas|Quiero comprar|las botas|negras.|sound1&
&arr_p2=socks|los calcetines|los calcetines|los calcetines|los calcetines|Quiero comprar|los calcetines|blancos.|sound2&
&arr_p3=dress|el vestido|el vestido|el vestido|el vestido|Quiero comprar|el vestido|azul.|sound3&
&arr_p4=swimming suit|el traje de baño|el traje de baño|el traje de baño|el traje de baño|Quiero comprar|el traje de baño|azul.|sound4&
My LV code
lv = new LoadVars();
lv.load("sounds/first.txt");
lv.onLoad = function(success) {
if (success) {
myTitle = this.thisTitle;
p1 = this.arr_p1.split("|");
trace(p1);
p2 = this.arr_p2.split("|");
p3 = this.arr_p3.split("|");
p4 = this.arr_p4.split("|");
}
};
I want to end up with ...
myArray [p1, p2, p3, p4];
...but this array may change based on the number of arrays put into the text file.
Thanks for your help.
View Replies !
View Related
An Array Of Arrays?
(Using flash CS3/AS2/3)
The code I have now, (see attached zip link) picks colors randomly from the myColors class.
I want to modify this code so the Class has sets of "myColors" (EG "myColors2", "myColors3") and the fla will pick a random "myColors" array and only use the colors within that array to display in the swf each time it is run. does that make sence?
Ive got this far but cant workout the next bit, which im sure isnt a big step and your help would be most helpful.
Thanks
Chris
View Replies !
View Related
Array Of Arrays
Can someone please help me with this. I am trying to make an array of arrays.
ActionScript Code:
var bodytype:Array = new Array;
var gender:Array = new Array;
var allArrays:Array = new Array;
bodytype = [fbody_small, fbody_medium, fbody_large];
gender = ["boy", "girl"];
allArrays = [bodytype, gender];
function hideAll (ev:Event):void{
for (var i:Number = 0; i < allArrays.length; i++) {
allArrays[i].visible = false;
trace ("gooooooood");
}
Thanks
View Replies !
View Related
Arrays Within An Array
Hi,
how can I read a 2dimensional array.
I have a main_array:
var main_array:Array = Array();
the main_array looks like: [x,x,x,x,x,x,x,x,x,x]
I have a itemA_array, looks like: [A,AA,AAA]
I have a itemB_array, looks like: [B,BB,BBB]
I put the 2 arrays into the main_array:
main_array.splice(2,1,itemA_array);
main_array.splice(3,1,itemB_array);
So far no problem. I load the main_array up with LV to the Database.
It arrives correctly.
The main_array is 10 elements,
itemA is on [2]
itemB is on [3]
The problem:
when I read the data in with LV like:
var main_array:Array = Array();
main_array = this.main_array;
Flash cannot read, that the elements on [2] and [3] are arrays.
Now my main_array has a length of 14 elements, it reads the As + Bs as single elements.
How can I read the 2 item arrays??
Thank you in advance.
Luciewong
View Replies !
View Related
Sorting Arrays Within An Array
hi there,
I have several values stored in multiple arrays (let's call these 'secondary arrays'). Each 'secondary array' is stored in one cell of another array ('main array'). The structure would look something like this:
Code:
mainArray(secondaryArray(number, textField, textField,...), secondaryArray(number, textField, textField,...), ...)
I was wondering if there was a way to sort the secondary arrays according to one of the values in them (namely the 'number')
Is that possible at all? Any help would be appreciated
Ta
View Replies !
View Related
Array Of Arrays, Multidimensionals Maybe?
Hi All,
First time posting, after spending the last week trying to get into actionscript. My question has to do with arrays, specifically, I want to record all mouseup and mousedown actions on the stage, then eventually use the drawing API to draw lines between each down and the following up point. But the current problem is probably more simple:
Code:
var this.ptArray:Array = new Array();
//array will contain [indexnumber:number, connected_to_previous:boolean, _x, _y]
this.onMouseDown = function(){
this.myX = _xmouse;
this.myY= _ymouse;
this.myTempArray = new Array();
this.indexnum = this.ptArray.length+1;
this.myTempArray.push(indexnum, 0, myX, myY);
trace(" myTempArray : "+myTempArray);
this.ptArray.push(myTempArray)
trace(" ptArray : "+this.ptArray);
}
The problem - I can't get my temp array to populate the ptArray. I've also tried changing all of the this.ptArrays to _root.ptArrays, but it still appears empty upon trace?
Thanks,
dialectric
View Replies !
View Related
Arrays In One Single Array?
Hi!
is there a way to place arrays in one arrays?
like i got three arrays here, and i want to place them in one array.
ActionScript Code:
var aVisible1:Array = new Array(mcMPR1, mcMPR2, mcMPR3, mcMPR4, mcMPR5);
var aVisible2:Array = new Array(mcMPR6, mcMPR7, mcMPR8, mcMPR9, mcMPR10);
var aVisible3:Array = new Array(mcMPR11, mcMPR12, mcMPR13, mcMPR14, mcMPR15);
//now I want to place all arrays in one array something like
var aAllarraysInOne:Array = new Array(aVisible1, aVisible2, aVisible3);
//but that's not the right way.
anyone who can help?
thanks in advance*
View Replies !
View Related
Create Arrays From Array
Hey guys,
tryign to use something liek this:
ActionScript Code:
var section:Array = new Array();section = ["a","b","c"];for(item in section){ _root[item]= new Array{} }
to create array objects from each item in the 'section' array, basiically giving me
a= new Array;
b= new Array
c = new Array
What am i doing wrong here?!
View Replies !
View Related
Combining Arrays To Form New Array
Hi,
I need to create an array by combining 4 others. If I just create the array naming the variable name of the other arrays as the elements, it leaves me with a 4 element array. I need all of the elements of all 4 arrays in the combination array. What is the best way to do this?
TIA,
aaroneousmonk
View Replies !
View Related
Can I Make An Array Of Pointers To Other Arrays?
Hi again, I'm building a really cool system to parse through properties of a sports team.
I've gotten quite far, but I have a little peice of code I'd like to optimize.
Basically I have a number of arrays called: "KeyTeam[]", "KeyPlayer[]" etc.
And with each array I need to perform a language logic match based on some entered data.
My question is this: I'd like to make a loop so i can call all the arrays via one function, I thought I'd be "smart" and use a reference array named "lookUpKey" so i can replace the array object name with a pointer to the array. But AS thinks I am inserting a string, and not a pointer to the array... is there anyway to have an array with pointers to another array (object)?
Here is a striped snip of the code I am using:
Thanks!!!
Code:
KeyTeamStr = [];
KeyTeam = [];
KeyPlayer =[];
KeyPlayerStr =[];
KeyWhere = [];
KeyWhereStr =[];
KeyWhen = [];
KeyWhenStr =[];
KeyWhat = [];
KeyWhatStr =[];
KeyVs = [];
KeyVsStr =[];
lookUpKey = new Array ("KeyTeam", "KeyPlayer", "KeyWhere", "KeyWhen", "KeyWhat", "KeyVs");//pointer to actual arrays with these names
lookUpKeyStr = new Array ("KeyTeamStr", "KeyPlayerStr", "KeyWhereStr", "KeyWhenStr", "KeyWhatStr", "KeyVsStr");//pointer to actual arrays with these names
//main logic loop:
for (u= 0; u < lookUpKey.length; u++) {
trace("LOOP:"+u);
trace("lookUpKey[u]:"+lookUpKey[u]);
//the problem is this next line, it thinks these are strings and not my arrays:
stepIntoMatches (KeyString, lookUpKey[u], lookUpKeyStr[u]);
}
View Replies !
View Related
Arrays || Dynamic Array Name & Set Index
Hi, I have been searching through the forums and could not find anything regarding my dilemma.
I created a three stage break down of a mass string into arrays the second array
set("display_info_"+x, info_split[x].split("*"));
breaks information incrementally into
display_info_0
display_info_1
display_info_x
This works and the "display_info_x" is populated with the correct data.
Now here is the problem I am facing. I need to populate a new array lets say it is:
batch_list = new array()
with
display_info_{x}[2]
I have written this to display what I am trying to achieve, this is a non-working setup but should give you an idea of what I am talking about.
batch_list[x] = eval("display_info_"+x+"[2]");
This is looped through and stops according to x amount of "display_info_x", this is not that important (the looping) mainly I need to know if there is a way to an array name called dynamically.
Thank for your help...
RD
View Replies !
View Related
Arrays To Nested-array Problem
A kind forum-member (Xeef) helped me find a solution to an array problem, but now I'm flummoxed as to how to convert my two simple arrays into the nested style: [{v:12, w:6}, etc.]
I tried several ways to construct the nested array style, and I feel I am close with the following, but no cigar:
ActionScript Code:
v = (12,21,-13,48,33);
w = (6,-99,7,-2,-2);
VW = [{}];
for (a=0; a<v.length; a++) {
VW[a].v.push(v[a]);
VW[a].w.push(w[a]);
}
for (a=0; a<VW.length; a++) {
trace(VW[a].v+" "+VW[a].w);
}
//no output
//I need the output: VW = [{v:12, w:6}, {v:21, w:-99}, {v:-13, w:7}, {v:48, w:-2}, {v:33, w:-2}]
View Replies !
View Related
Array.shuffle() & Non-repeat Arrays
First, let me say that I love Rothrock's Array.shuffle() and I think it an awesome method, give up the props. But I've heard it said several times that by using the shuffle, it will produce non-repeating choices from the array.
I could be mis-understanding (probably) or not using it correctly (likely), but I've never been able to understand how 'shuffling' the contents of the array would eliminate any of the possible choices, regardless of the index being chosen at random or statically. although the method does a fabulous, perfectly conceived, stupendous, superbly executed (that was butter for Rothrock :) job of shuffling it, I don't see how it's still not possible for items to occationally repeat, through natural random chaos. Granted the more elements in the array, the less likely this occurs, but I believe it will occur.
I did a little experiment to see what happens, and it seems to validate this, but I'm probably doing something wrong anyway. So I though I'd open a disscussion, because I'd like to know more, and get some of the thoughts on this from everyone, maybe work out a solution, or tell me what the heck I'm doing wrong.
Once again though, no shot a Rothrock here, this method truely 'rocks'. Just quest for knowledge.
Here's the code I used, very simple, try it out and pick it apart:
Attach Code
stop();
Array.prototype.shuffle = function() {
for (var ivar = this.length-1; ivar>=0; ivar--) {
var p = random(ivar+1);
var t = this[ivar];
this[ivar] = this[p];
this[p] = t;
}
};
var Ar = [1,2,3,4,5];
var prev=null;
var it=1;
var index = false; //set: true=0[static index], false=rndNum
onEnterFrame = function() {
Ar.shuffle();
(index) ? i=0 : index=Math.round(Math.random()*4);
if(prev==Ar[i]) {trace('repeat after iterations: '+it); it=1;}else{it++; prev=Ar[i];}
}
View Replies !
View Related
[F8] Array Help (matching Actions For 2 Arrays)
Hey all...
I'm working on a mockup for a solution...
Got an array of button movie clips and an array of clips these buttons control. Got the button stuff worked out, but I need the buttons to control the corresponding movie clips....
I'm close, but on click the buttons all move the same clip, not the one they're supposed to. I've attached the fla (explains it better)...
Here's the codeActionScript Code:
ActionScript Code:
ActionScript Code:
import mx.transitions.Tween;import mx.transitions.easing.*;//------------------------------------function setArray() { for (var mc in squares) { squares[mc]._y = -100; }}//------------------------------------var squares:Array = new Array(_root.squares.v1, _root.squares.v2, _root.squares.v3, _root.squares.v4, _root.squares.v5, _root.squares.v6, _root.squares.v7, _root.squares.v8, _root.squares.v9);var buttons:Array = new Array(b1, b2, b3, b4, b5, b6, b7, b8, b9);var tweenMethod = Back.easeInOut;//------------------------------------for (var a = 0; a<buttons.length; a++) { btn = buttons[a]; btn.id = Number(a)+1; sqs = squares[a]; sqs.id = Number(a)+1; btn.onRollOver = function() { new Tween(this.stinky, "_xscale", tweenMethod, 100, 150, .5, true); new Tween(this.stinky, "_yscale", tweenMethod, 100, 150, .5, true); }; btn.onRollOut = function() { new Tween(this.stinky, "_xscale", tweenMethod, 150, 100, .5, true); new Tween(this.stinky, "_yscale", tweenMethod, 150, 100, .5, true); }; btn.onRelease = function() { setArray(); new Tween(sqs, "_y", tweenMethod, 0, 50, .5, true); };}//------------------------------------stop();
View Replies !
View Related
Associative Arrays: Array Or Object?
Dear all,
I am having a confusing night with Associative Arrays in Flash CS3. For example I wrote these lines:
HTML Code:
var listMC: Array = new Array ();
listMC["0"] = "instance0";
listMC["1"] = "instance1";
listMC["2"] = "instance2";
listMC["3"] = "instance6";
listMC["6"] = "instance8";
listMC["7"] = "instance5";
trace(listMC.length);
Result/ 8
Why 8? It seems flash assumes that it has to take into account those missing numbers (4,5). If I use a loop to see the content of the array I got:
HTML Code:
instance0,instance1,instance2,instance6,,,instance8,instance5
This confirms the assumption. And if I use:
HTML Code:
listMC["id0"] = "instance0";
listMC["id1"] = "instance1";
listMC["id2"] = "instance2";
listMC["id3"] = "instance6";
listMC["id6"] = "instance8";
listMC["id7"] = "instance5";
trace(listMC.length);
Result/ 0
No idea why!!!
So, I tried using objects and I got
HTML Code:
var listMC: Object = new Object ();
listMC["0"] = "instance0";
listMC["1"] = "instance1";
listMC["2"] = "instance2";
listMC["3"] = "instance6";
listMC["6"] = "instance8";
listMC["7"] = "instance5";
trace(listMC.length);
Result/ undefined
Not lucky again
A light in this world of darkness?
Thanks in advance
View Replies !
View Related
|