Array Comparison ( Flash 8 )
Hello,
I am trying to write a function that will "highlight" days
in a month--for a calendar I'm making.
The dates I have come in from PHP/MySQL look like this:
YYYY-MM-DD.
I split up the date by "year", "month" and "day" then put
them into an array like so:
////CODE////
function editDateResults( d:Array ){ // d = an array full of
dates formated YYYY-MM-DD
for( var i:Number=0 ; i < d.length ; i++){
year.push( parseInt( d
.substring( 0 , 4 ) ) );
month.push( parseInt( d.substring(5 , 7 ) ) );
day.push( parseInt( d
.substring(8 , 10 ) ) );
}//end for
}//end function
////END CODE////
How do I take those arrays and line them up with my Calendar
days.
I tried something like this. DON'T LAUGH! It worked kind of!
LOL
////CODE////
var l:Number = 0;
var d:Number = 0;
var count:Number = 0;
function highlightDay( ){
count = 0; //reset;
while( true ){
count++;
l++;
l %= month.length;
d++;
d %= 31;
if( monthsByNumber[n]+1 == month[l] and d == day[l] ){ // n
= a number changed by pressing "next" or "prev" button
var DayColor = new Color( Calendar["daycube"+ d] );
//Calendar = main clip. "daybube" is just a little cube with a
number representing the day ( inside Calendar ).
var colorTransform:Object = { ra:50 , ga:50 , ba:50 };
DayColor.setTransform( colorTransform );
Calendar["daycube"+d].hasEvent = true;
Calendar["daycube"+d].eventNumber = l;
}else{
var DayColor = new Color( Calendar["daycube"+d] );
var colorTransform:Object = { ra:100 , ga:100 , ba:100 };
DayColor.setTransform( colorTransform );
Calendar["daycube"+d].hasEvent = false;
}//end if
if( count >= ( month.length * 31) ){ break }; //how many
times to check
}//end while
}//end function
////END CODE////
Thanks for any help you can give!
Never mind. I figured it out!
Similar Messages
-
Passing flash array to flash sprite
Hi,
I am trying to pass a flash array like [{x:1,y:2},{x:1,y:2},{x:3,y:5}] from a flash sprite to Director lingo and back to another flash sprite. In director all looks fine when passing it back to the second sprite but the flash trace command just gives me undefined values. Can't I do this in lingo?
in lingo:
put " flashAry.length " & flashAry.length
flashObject.DrawAry(flashAry,"testxy")
Output window:
-- " flashAry.length 23.0000"
in ActionScript
function DrawAry(points:Array,test){
trace(">DrawAry " + points + " " + points.length + " >" + test + "<")
Output window:
-- >DrawAry undefined undefined >testxy<Had a very similar problem and found a solution...
Hope this helps....
-- This GETS an array from Flash to Director
-- 'myFlashArray' is the name of the array in your Flash file
-- 'flaArray' is the new list created in Director
-- And obviously, the flash file is on sprite 1
flaArray = convert(#list, sprite(1).myFlashArray)
put flaArray
-- This SENDS a Director list to flash (as an array)
-- 'zz' is just a temporary variable so the script is easier to read
-- 'dirList' is your Director List
-- 'myNewFlashArray' is the name of the newly created array in your flash file
-- again, the flash file is on sprite 1 in this case
dirList = ["item 1","item 2","item 3"]
zz = convert(#flashObjectArray, dirList).toString()
sprite(1).createVariable(#myNewFlashArray, zz )
NOTE: I'm using an undocumented 'convert' function that is only available in Director 10.1.1 onwards... -
Director Array to Flash Array?
I'd like to be able to create an array in Director, and then
pass that array object into Flash and use it there. I can use
Director to manipulate a Flash array, but I haven't been successful
in passing an array object.
Any help?If you have the new (at least more recent) Director 10.1
update with the
new Flash Asset Xtra, you can use the brand spankin new
convert() method
to do just that.
Here is a technote (pdf) about how to use it:
http://www.adobe.com/support/director/flash_8_asset_xtra.pdf -
Associative array comparison and INSERT upon IF condition
Hi Guys,
I have written this pl sql code to identify non existing sellers and insert their sales channel information into the dimension table (dimensional table update).
Somehow,......nothing is inserted and this script runs for 12 hours+ without any result. the sql autotrace shows no result and the explain plan (button on sql developer throws upon clicking "missing keyword". I have no
information what is going on/wrong. Does anyone spot an error?
UNDEFINE DimSales;
UNDEFINE FactTable;
DEFINE DimSales = 'testsales';
DEFINE FactTable = 'testfact';
DECLARE
v_SellerNo VarChar(9);
v_error_code T_ERRORS.v_error_code%TYPE;
v_error_message T_ERRORS.v_error_message%TYPE;
TYPE assoc_array_str_type1 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
v1 assoc_array_str_type1;
TYPE assoc_array_str_type2 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
v2 assoc_array_str_type2;
BEGIN
--Collect all distinct SellerNo into associative array (hash table)
select distinct SellerNo bulk collect into v1 from &FactTable;
select distinct seller_id bulk collect into v2 from &DimSales;
v_SellerNo := v1.first;
loop
exit when v1 is null;
--1 Check if v_SellerNo already exists in DIM_Sales (if NOT/FALSE, its a new seller and we can insert all records for that seller
if (v2.exists(v_SellerNo)=false) THEN
INSERT INTO &DimSales (K_Sales,REG,BVL,DS, VS,RS,GS,VK)
(SELECT DISTINCT trim(leading '0' from RS||GS) ,REG BVL,DS,VS,RS,GS,VK from &FactTable where SellerNo =v_SellerNo);
--ELSE
end if;
v_SellerNo := v1.next(v_SellerNo);
end loop;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
--v_error_code := SQLCODE
--v_error_message := SQLERRM
--INSERT INTO t_errors VALUES ( v_error_code, v_error_message);
END;
---------------------------------------------------------------Distinct clause requires a sort. Sorts can be very expensive.
Bulk collects that are not constrained in fetch size, can potentially fetch millions of rows - requiring that data to be wholly read into server memory. I have seen how this can degrade performance so badly that the kernel reboots the server.
Using PL/SQL loops to process and insert/update/delete data is often problematic due to its row-by-row approach - also called slow-by-slow approach. It is far more scalable letting SQL do the "loop" processing, by using joins, sub-selects and so on.
Where the conditional processing is too complex for SQL to handle, then PL/SQL is obviously an alternative to use. Ideally one should process data sets as oppose to rows in PL//SQL. Reduce context switching by using bulk fetches and bulk binds.
But PL/SQL cannot execute in parallel as the SQL it fires off can. If after all the optimisation, the PL/SQL process still needs to hit a million rows to process, it will be slow irrespective of how optimal that PL/SQL approach and design - simply because of the number of rows and the processing overheads per row.
In that case, the PL/SQL code itself need to be parallelised. There are a number of ways to approach this problem - the typical one is to create unique and distinct ranges of rows to process, spawn multiple P/SQL processes, and provide each with a unique range of rows to process. In parallel.
So you need to look close at what you are trying to achieve, what the workloads are, and how to effectively decrease the workloads and increase the processing time of a workload.
For example - finding distinct column values. You can pay for that workload when wanting that distinct list. And each time afterward repeat that workload when wanting that distinct list. Or you can pay for that workload up-front with the DML that creates/updates those values - and use (for example) a materialised view to maintain a ready to use distinct list of values.
Same workload in essence - but paying once for it and up-front as oppose to each time you execute your code that needs to dynamically build that distinct list.
Kent Crotty did tests and showed stunning performance improvements with bulk collect and forall, up to 30x faster:Bulk processing is not a magical silver bullet. It is a tool. And when correctly use, the tool does exactly what it was designed to do.
The problem is using a hammer to drive in screws - instead of a screwdriver. There's nothing "stunning" about using a screwdriver. It is all about using the correct tool.
If the goal of the swap daemon is to free up "idle" chunks of memory, and try to use that memory for things like file cache instead, what does that have to do with bulk processing?The swap daemon reads virtual memory pages from swap space into memory, and writes virtual pages from memory to swap space.
What does it have to do with bulk processing? A bulk fetch reads data from the SGA (buffer cache) into the PGA (private process memory space). The larget the fetch, the more memory is required. If for example 50% of server memory is required for a bulk collection that is 2GB in size, then that will force in-use pages from memory to swap space.. only to be swapped back again as it is needed, thereby forcing other in-use pages to swap. The swap daemon will consume almost all the CPU time swapping hot pages continually in and out of memory. -
Simple array comparison not working. Please HELP!
I have been struggling to solve this problem for a few days now, and I'm slowly losing my mind.
I am in Adobe Acrobat 10.
I have a group of button fields called: btn0, btn1, btn2, etc.
I have a group of text fields called: txt0, txt1, txt2, etc.
I have a script that takes the value of txt0 and makes it the caption for btn0, and so on.
I have a script that sets the MouseUp action of btn0 to setFocus to txt0, and so on.
These scripts work fine.
I have a script that takes the values of all the txt fields and puts them in an array, and sorts it.
I have a script that takes the array[0] item and makes it the caption for btn0, and so on (alphabetizing my list of buttons).
Those scripts work fine.
I am trying to compare the value of the array[0] item to each of the txt fields to find the match, and then set the MouseUp action of btn0 to setFocus to the matching txt field, and so on (so my alphabetized list points to the correct locations).
This is where I'm at a loss.
Here is what I have:
//specified the txt fields
var txt0 = this.getField("Z name");
var txt1 = this.getField("A name");
//etc.
//put their values into an array called rxArray
var rxArray = [txt0.value, txt1.value]; //etc.
//sorted the array
rxArray.sort();
//set the captions equal to the sorted array items
for (var i = 0; i < 5; i++) {
var b = ("btn" + i);
this.getField(b).buttonSetCaption(rxArray[i]); //works fine; alphabetizes the list of buttons
//below is what goes wrong
for(var x = 0; x < 5; x++) {
var r = ("txt" + x);
if(rxArray[i] == r.value){
var s = (r + ".setFocus();");
this.getField(b).setAction("MouseUp", s);
//end
Here is what I know:
The alphabetizing and labeling works fine, but the buttons' MouseUp scripts don't work at all. Nothing happens.
If I change the following piece of the above script:
if(rxArray[i] == r.value){
var s = (r + ".setFocus();");
this.getField(b).setAction("MouseUp", s);
To this:
if(rxArray[i] == txt1.value){
var s = (r + ".setFocus();");
this.getField(b).setAction("MouseUp", s);
Because rxArray[0] does equal the value of txt1 ("A name"), then the MouseUp script for btn0 gets set to:
txt4.setFocus();
So I know that, each time the nested loop runs, the if statement is true, and the setFocus script updates. Until the end of the loop, leaving the setFocus as the last item run. So why doesn't my script work? It should only update the setFocus script IF the array item matches the txt field, and should set it to THAT txt field.
Please please help. I know I'm missing something simple in there somewhere.@Try67:
That's a good question. I was running into some other issues and have revamped my code. Here is what I have in my test file:
A list of five buttons and a list of five text fields. One additional button that sets the focus to the next empty text field to add a new item, and two additional buttons, one that sorts my list alphabetically, and one that unsorts it.
with the following field names
The sort button calls function sortName and the unsort calls function sortNumber (the order of entry).
Here are those scripts in final form:
function sortName() {
//first reset the captions for the buttons to blank
for (var a = 0; a < 5; a++) {
var b = ("btn" + a);
this.getField(b).buttonSetCaption("");
var txt0 = this.getField("t0");
var txt1 = this.getField("t1");
var txt2 = this.getField("t2");
var txt3 = this.getField("t3");
var txt4 = this.getField("t4");
var rxArray = [txt0.value, txt1.value, txt2.value, txt3.value, txt4.value];
for(var m = rxArray.length - 1; m > -1; m--){
if(rxArray[m] == ""){
rxArray.splice(m, 1);
rxArray.sort();
var newArray = [txt0, txt1, txt2, txt3, txt4];
for(var n = newArray.length - 1; n > -1; n--){
if(newArray[n].value == ""){
newArray.splice(n, 1);
for (var i = 0; i < rxArray.length; i++) {
var b = ("btn" + i);
this.getField(b).buttonSetCaption(rxArray[i]);
for (var x = 0; x < newArray.length; x++) {
if(rxArray[i] == newArray[x].value){
var s = ("this.getField('" + newArray[x].name + "').setFocus();");
this.getField(b).setAction("MouseUp", s);
//end
function sortNumber() {
var txt0 = this.getField("t0");
var txt1 = this.getField("t1");
var txt2 = this.getField("t2");
var txt3 = this.getField("t3");
var txt4 = this.getField("t4");
var newArray = [txt0, txt1, txt2, txt3, txt4];
for (var x = 0; x < newArray.length; x++) {
var b = ("btn" + x);
this.getField(b).buttonSetCaption(newArray[x].value);
var s = ("this.getField('" + newArray[x].name + "').setFocus();");
this.getField(b).setAction("MouseUp", s);
//end
As you can see, I've used the array lengths rather than fixed numbers, except when clearing the button values. I use a number there because there is no array to reference and didn't feel like making an array just for that. The number of buttons won't change.
I've also added in a splice() method to remove the blank entries from my arrays when appropriate (making using the array length even more important).
The result of the sort is:
The only quirk I've found in all this is with the Add New button, which calls function addNew, which is:
function addNew() {
var txt0 = this.getField("t0");
var txt1 = this.getField("t1");
var txt2 = this.getField("t2");
var txt3 = this.getField("t3");
var txt4 = this.getField("t4");
var newArray = [txt0, txt1, txt2, txt3, txt4];
for (var i = newArray.length - 1; i > -1 ; i--) {
if (newArray[i].value == "") {
newArray[i].setFocus();
//end
For this, I would have though that running through the array from start to finish looking for the first empty text field and setting the focus to it would have been correct. But that resulted in the last empty text field being focused. So I reversed the for loop to run finish to start, and the result was that the first empty field was focused. Not sure why that is... -
Big Problem with Array. FLash 9 Problem?
Hello there
there must be a lag or ssomething here. i have this code:
// A new dimensional Array, the array is korrekt. The Length
and when i ask only one Array ellement is everythin ok
var okeytaslari:Array=new Array();
var d:Number;
var e:Number;
var farbenarray:Array =
["000000","0099FF","FF00FF","FF0000"];
var farbenarray1:Array = ["s","b","g","r"];
var r:Number=0;
for (var farbenn=0;farbenn<4;farbenn++)
for(d=0;d<2;d++)
for(e=1;e<14;e++)
okeytaslari.push({klasse:farbenarray1[farbenn]+"_"+e,farbe:farbenarray[farbenn],zahl:e,in stanzname:"s"+r});
r++
okeytaslari.push({klasse:"j_j",farbe:"FF00FF",zahl:"j",instanzname:"s104"});
okeytaslari.push({klasse:"j_j",farbe:"FF00FF",zahl:"j",instanzname:"s105"});
// here in this array are maximum 15 Numbers in which the
highest Number is 105 because of Array okeytaslari.length
var beispieltaslari:Array = [...]
for (q=0; q<beispieltaslari.length; q++)
trace(q +","+beispieltaslari
quote:
+","+okeytaslari[beispieltaslari
quote:
].instanzname);
//This is the Trace action first Line are the NUmbers in
beispieltasri array
// then after 2nd line the outpu is q and beispieltaslari
quote:
and okeytaslari[beispieltaslari
quote:
].instanzname
// if you can see the numbers SHOULD be the same but it isnt
all the time. After 60 or something the Number changes
14,7,90,63,68,102,44,91,25,42,89,53,92,52,99
0,14,s14
1,7,s7
2,90,s91
3,63,s63
4,68,s68
5,102,s103
6,44,s44
7,91,s92
8,25,s25
9,42,s42
10,89,s90
11,53,s53
12,92,s93
The numbers i get from my Server dynamikly. But you can see
that they come correct and the first array is also correct :S
Help please :(ups sorry i send it twice :D
-
TextField to String array comparison?
Hello, I am wanting to be able to compare a users entry into a textField (single character) to the characters that are in my String array. Is this possible and how can I go about achieving it?
My String array contains single characters in the alphabet - if a user does not type in one of these I would like to output -System.out.println("Out of Bounds");
Thank You.So, to make sure I understand you, you have an array of characters that are "allowable", and if a user enters a string that has any characters that are not in the allowable set, you want an error message? If so, and starting from your code, try this:
char[] myArray = {'a', 'e', 'i', 'o', 'u'};
String allowable = new String(myArray);
// I assume textFieldComponents is the user-entered String, though
// the name doesn't really suggest that
// Run through all characters in the user entry
for (int i = 0; i < textFieldComponents.length(); i++) {
// Check each character in the allowable array
// (I assume the allowable characters array is myArray)
if (allowable.indexOf(textFieldComponents.charAt(i)) == -1) {
System.out.println("Out of bounds");
break;
}Hope that helped
Lee -
Array comparison(houston?houston?help!!!!!!)
hello!!!thank u all for ur help about string sorting...but, actually i have a bigger problem....
i'm creating a game where the user has to input 3 different characters...the program has to calculate the number of characters correct and in the right position(bulls) and the number of characters correct but in the wrong position(hits).
"guess" is the user input and code the three different characters generated by the computer.
With the following code, i asked the computer to display the case where there are three bulls(in that case there is no hit)...is this code correct?
if(guess.equals(code)) //calculate the number of bulls
textArea1.append("\t\t"+3+0)
But i' d like to generate a general code to calculate the number of bulls and hits...
although i think i know (?) in theory what to do(declare the two strings as 2 different arrays and then compare the content of each array index, in practice, i dont know how to start!!!!If u could just show me the way.....
thank u again for ur help.
}You should think of a mechanism that consumes bulls and then hits.
For example, beware of cases like code="abc" and guess="aba".
I guess this should give bulls=2, hits=0 and not bulls=2, hits=1.
Another example: code="abc" and guess="daa" should give bulls=0, hits=1 and not bulls=0, hits=2.
If you are using Java 1.5, you can use StringBuffer.deleteCharAt(int) for that.
Assuming that both code and guess have the same length, here is piece of code for counting/consuming bulls:StringBuffer codeBuf = new StringBuffer(code);
StringBuffer guessBuf = new StringBuffer(guess);
int bullCount = 0;
for(int i=guessBuf.length(); i>= 0; i--) {
if(guessBuf.charAt(i) == codeBuf.charAt(i)) {
bullCount ++;
guessBuf.removeCharAt(i);
codeBuf.removeCharAt(i);
int hitCount = 0;
// Make a loop similar to the first one for finding/consuming hits...Note: if you aren't using Java 1.5, you could make your own method for removing a char in a string. -
PL SQL Array comparisons (Looking for matches)
I have two tables and I am trying to derive a XML structure out of it, based on certain criteria.
The oracle version I am using is
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
PL/SQL Release 9.2.0.7.0 - Production
CORE 9.2.0.7.0 Production
TNS for Solaris: Version 9.2.0.7.0 - Production
NLSRTL Version 9.2.0.7.0 - ProductionStructure and Data
QUOTE_LINES
QUOTE_NO LINE_SEQ CLASS TYPE PERIOD RENT
100 001 MERC LEASE 12 680.00
100 002 MERC LEASE 10 775.00
100 003 JAG LEASE 10 785.00
QUOTE_ADTL
QUOTE_NO LINE_SEQ ADTL_SEQ ADDON CHARGE
100 001 001 GPS 199.99
100 002 001 XM 24.99
100 003 001 GPS 199.99
100 003 002 CHILDSEAT 25.99
There are two cursors to get information.
The first cursor is on the QUOTE_LINES table and the second one is on the QUOTE_ADTL table.
What the program is currently doing is opening the cursor on QUOTE_LINES, getting information, then moving to QUOTE_ADTL and appending this information.
So my XML String is being formed like this.
<QUOTE_LINE>
<LINE_SEQ>001</ LINE_SEQ >
<CLASS>MERC</CLASS>
<PERIOD>12</PERIOD>
<RENT>680.00</RENT>
<QUOTE_ADTL>
<LINE_SEQ>001</LINE_SEQ>
< ADTL_SEQ>001</ADTL_SEQ>
<ADDON>GPS</ADDON>
<CHARGE>199.99</CHARGE>
</QUOTE_ADTL>
</QUOTE_LINE>
<QUOTE_LINE>
<LINE_SEQ>002</ LINE_SEQ >
<CLASS>MERC</CLASS>
<PERIOD>10</PERIOD>
<RENT>775.00</RENT>
<QUOTE_ADTL>
<LINE_SEQ>002</LINE_SEQ>
< ADTL_SEQ>001</ADTL_SEQ>
<ADDON>XM</ADDON>
<CHARGE>24.99</CHARGE>
</QUOTE_ADTL>
</QUOTE_LINE>
<QUOTE_LINE>
<LINE_SEQ>003</ LINE_SEQ >
<CLASS>JAG</CLASS>
<PERIOD>10</PERIOD>
<RENT>785.00</RENT>
<QUOTE_ADTL>
<LINE_SEQ>003</LINE_SEQ>
< ADTL_SEQ>001</ADTL_SEQ>
<ADDON>GPS</ADDON>
<CHARGE>199.99</CHARGE>
<LINE_SEQ>003</LINE_SEQ>
< ADTL_SEQ>002</ADTL_SEQ>
<ADDON>CHILDSEAT</ADDON>
<CHARGE>25.99</CHARGE>
</QUOTE_ADTL>
</QUOTE_LINE> The change that is required is to combine the unit lines if LINE_SEQ /CLASS /TYPE have the same values.
So the new XML will have to be something like this.
<QUOTE_LINE>
<CAR>
<LINE_SEQ>001</ LINE_SEQ >
<CLASS>MERC</CLASS>
<PERIOD>12</PERIOD>
<RENT>680.00</RENT>
</CAR>
<CAR>
<LINE_SEQ>002</ LINE_SEQ >
<CLASS>MERC</CLASS>
<PERIOD>10</PERIOD>
<RENT>775.00</RENT>
</CAR>
<QUOTE_ADTL>
<LINE_SEQ>001</LINE_SEQ>
< ADTL_SEQ>001</ADTL_SEQ>
<ADDON>GPS</ADDON>
<CHARGE>199.99</CHARGE>
<LINE_SEQ>002</LINE_SEQ>
< ADTL_SEQ>001</ADTL_SEQ>
<ADDON>XM</ADDON>
<CHARGE>24.99</CHARGE>
</QUOTE_ADTL>
</QUOTE_LINE>
<QUOTE_LINE>
<LINE_SEQ>003</ LINE_SEQ >
<CLASS>JAG</CLASS>
<PERIOD>10</PERIOD>
<RENT>785.00</RENT>
<QUOTE_ADTL>
<LINE_SEQ>003</LINE_SEQ>
< ADTL_SEQ>001</ADTL_SEQ>
<ADDON>GPS</ADDON>
<CHARGE>199.99</CHARGE>
<LINE_SEQ>003</LINE_SEQ>
< ADTL_SEQ>002</ADTL_SEQ>
<ADDON>CHILDSEAT</ADDON>
<CHARGE>25.99</CHARGE>
</QUOTE_ADTL>
</QUOTE_LINE>Edited by: abhijit74 on Dec 18, 2008 6:46 AM (Added code tags).btw you can use ** tags when posting code to improve readability. See the FAQ.
-
Array problem in FL 1.x
Is there any alternative for array in Flash Lite 1.X
(excluding PSUEDO Array)?kamsky wrote:
> Is there any alternative for array in Flash Lite 1.X
(excluding PSUEDO Array)?
Yes, since arrays structures are not natively supported in
Flash Lite
prior to 2.x, developers must use one of two methods for 1.1
content
(that I know of) to simulate them:
1.) Use the eval statement (2) or a movieclip to store and
reference
vars. Depending on your situation and/or needs one may be
more
appropriate to what you are doing than the other.
1.) eval method:
arr1 = "a"
arr2 = "b"
arr3 = "c";
for ( i=1; i<=3; i++ ) {
trace( eval( "arr" add i ) );
2.) Create an empty movieclip off stage. Assign it an
instance name of
array_mc (or whatever) ... use it to store vars. Use the
syntax:
array_mc[0] = "a";
array_mc[1] = "b";
array_mc[2] = "c";
trace( array_mc[0] );
Also, here is a Pseudo array class for 1.1 from Aral Balkan
you may be
interested in:
http://aralbalkan.com/353
Some addition resources you should also check out if you are
coming from
> 2 and are working in 1.1:
http://www.flashmobilebook.com/
http://www.adobe.com/devnet/devices/articles/as2_to_flashlite_print.html
http://www.adobe.com/devnet/devices/articles/as_flashlite.html
Alessandro Pace has a running list of useful items like this
at:
http://www.biskero.org/?page_id=342 -
XML newbie question - xml into arrays
I am pretty new xml and I am working with a file that has
text
associated with images in the file and I would like to move
the text
into a xml document.
I heard that a good way to deal with xml is to load it into
an array. I
have my text set up in arrays already, so my whole file
aready works in
that way. So all I have to do is load my xml document into my
arrays. I
have the xml document loading fine, but I don't know how to
get the info
into my arrays.
My xml document looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<index_content>
<image no="1">
<imgLink>"pages/collection.html"</imgLink>
<title>"Title 01"</title>
<text>"Text bla bla, bla 01, Text bla bla, bla
01"</text>
<corner>"unisex"</corner>
</image>
<image no="2">
<imgLink>"pages/collection.html"</imgLink>
<title>"Title 02"</title>
<text>"Text bla bla, bla 02, Text bla bla, bla
02"</text>
<corner>"mens & womens"</corner>
</image>
<image no="3">
<imgLink>"pages/collection.html"</imgLink>
<title>"Title 03"</title>
<text>"Text bla bla, bla 03, Text bla bla, bla
03"</text>
<corner>"mens & womens"</corner>
</image>
<image no="4">
<imgLink>"pages/collection.html"</imgLink>
<title>"Title 04"</title>
<text>"Text bla bla, bla 04, Text bla bla, bla
04"</text>
<corner>"mens & womens"</corner>
</image>
</index_content>
My arrays in Flash are:
var imgLinkURLs:Array = [];
var imgTitles:Array = [];
var imgTexts:Array = [];
var imgCornerLabel:Array = [];
So I think i need for loops pushing for example imgLink from
image no1
into imgLinkURLs array, then push imgLink from image no2, and
so forth.
Then do the same for imgTitle and the other arrays...
How would I do this the right way?you can do it in just one loop, going through all the image
tags in index_content and for each tag fill the values of all four
arrays
for (i...) {
get the appropriate child of index_content
first_array[ i ] = value of first tag
second_array[ i ] = value of second tag
no need for multiple loops.
flash has functionality for xml files, but it helps to write
a little wrapper around it, to simplify programming, especially if
you work with xml a lot.. I wrote my for work, so I can't show it
to you, but it's not very complicated to do -
hi,
i'm working on a project and i thought that an easy way to
get around a problem i have would be to make an array to store info
and then output it later. But i have no idea how to make an array
in flash... could someone please explain how to define an array and
possibly ouput the contents of it in a text box, with each 'cell'
of the array on a new line in the text box.
Thanks,
TommyThis is the kind of question that you should get the answer
from reading the help docs that comes with Flash.... but anyways,
To create array, use either, new Array() or the shorthand, [
]. You can use new Array() to make an array with a specific length,
or give the actual elements in it. E.g.:
myArray = new Array(10);
trace(myArray.length); // outputs 10
trace(myArray); // 10x undefined => values not defined yet
OR
myArray = new Array("a ball","a cat",32324324);
With [ ], it would be:
myArray = ["a ball","a cat",32324324];
You can manipulate individual values, using the array access
operator. Arrays are indexed 0-based.
myArray = ["a ball","a cat",32324324];
trace(myArray[0]); // "a ball"
myArray[1] = "a dog";
trace(myArray); // a ball, a dog, 32324324
You can add values to the array using push:
myArray = ["a ball","a cat",32324324];
myArray.push("eeeeeeeeeeeek");
trace(myArray); // a ball, a cat, 32324324, eeeeeeeeeeeek
To put the contents of the array, myArray into a textfield,
my_txt, use:
my_txt.text = myArray.join('\n');
But really, if you want it explained thoroughly, read the
docs! :-) -
I have a list stored in mysql database that looks like this:
12, 45, A, 87, B, 98
I need to use coldfusion to retreive the list and convert
each item to an element of an array. i.e.:
tempArray [0] = 12;
tempArray [1] = 45;
and so on. I need to do this because I'm returning the
created array to flash.
Thanks for your help!If you literally want to return 12, 45, A, 87, B, 98, then
understand that is not an array, it's a list. The example in your
first post indicated you wanted an array - tempArray[1] = 12,
tempArray[2] = 45, etc. Which is it, or am I confused?
BTW, you don't need the [,] in the ListToArray function - I'm
surprised it did not throw a compile error. Just do this: <cfset
tempArray = ListToArray(detailsList)> -
Saving flash object in lingo?
Hi,
I want to use multiple Flash movies in one Director movie
with one XML
file (UTF8).
Is it possible to load the XML data into flash and save it as
object to
a Director global and later put this object on another flash
sprite?
If I have lots of XML data my flash would take a long time to
load and
parase the XML data again and again.
Is it a good idea to store flash data into director?
TIASylvainT wrote:
> Global ocbject :
>
> myFlashObject = newObject("XML")
> -- Add Date to it and Parse it.
>
> mySpriteFlashObject =
sprite("myFlashSprite").newObject("XML")
> mySpriteFlashObject = myFlashObject
>
> I hope this helps
Sorry I don't understand this.
First I parse my XML data in flash and create an array of it.
I tried to get an array from Flash and store it's Data in my
Director
Movie. I tried just to get it via getVariables but I get an
empty string
instead of an array back.
fl2 = sprite(9).getVariable("_level0.strary",false); -
Data Structure: Ragged Array
Is it possible to create a ragged array in flash AS2?
sure:
var a:Array=[];
var a1:Array = [1];
var a2:Array = [1,2];
a = [a1,a2];
Maybe you are looking for
-
Can I manage an externally stored iTunes library with an iPad?
Hi all, To give a better idea of my situation, here's a bit of information about the problem I have. I currently have two Windows 7 machines, a laptop that's seen better days and a desktop which I am looking to get rid of because of space. I have an
-
Issue in evaluation of Role Membership Rule in gtc trusted recon.
Hi All, I got a issue in evaluation of role membership in gtc trusted recon. i created a custom UDF in user profile.i am updating that field from gtc trusted recon. i created a rule based on that custom UDF.But that is not triggering while we run the
-
Hi Can anyone give me step by step procedure for creating an RFC to FILE scenario in XI
-
Hello, i have a pdf form in single page, but is very long and i want cut in 3 pages (3 or more). When i cut the template the first page, mantein the configuration, but other pages not. Any can help me? Thanks.
-
Hi, My client is asking that , we want plant wise authorization in sales order level (va01), how we will do for this and what are the settings needed. please any one knows tell me. Thanks, Anand.k Edited by: Anand2mnp on Mar 3, 2011 9:21 AM