Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Array multidimensionali

This is a discussion on Array multidimensionali within the Actionscript 3.0 avanzato forums, part of the Flash CS3 generale category; Ciao, vorrei prendere i dati da un'xml e portarli in un'array multidimensionale.... Questo l'Xml: <?xml version=&...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 e Actionscript 3.0 > Flash CS3 generale > Actionscript 3.0 avanzato

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-03-08, 22:40
Author
 
Join Date: Nov 2007
Posts: 12
Rep Power: 0
powerSassa is on a distinguished road
Array multidimensionali

Ciao,
vorrei prendere i dati da un'xml e portarli in un'array multidimensionale....

Questo l'Xml:
<?xml version="1.0" ?>
<photosite>
<containerOne imgUrl="img/lea.jpg">
<containerTwo imgUrl="img/person.jpg">
<containerTrhee imgUrl="uff1.jpg"></containerTrhee>
<containerTrhee imgUrl="uff1.jpg"></containerTrhee>
<containerTrhee imgUrl="uff1.jpg"></containerTrhee>
</containerTwo>
<containerTwo imgUrl="img/person.jpg">
<containerTrhee imgUrl="uff2.jpg"></containerTrhee>
<containerTrhee imgUrl="uff2.jpg"></containerTrhee>
<containerTrhee imgUrl="uff2.jpg"></containerTrhee>
</containerTwo>
</containerOne>
</photosite>



Il problema è che non riesco a ficcare un'Array dentro l'altro.
Quello che vorrei riuscire ad avere è questo:

containerOne[0] = img/lea.jpg
containerOne[0][0] = img/person.jpg
containerOne[0][1] = img/person.jpg
containerOne[0][0][0] = uff1.jpg
containerOne[0][0][1] = uff1.jpg
containerOne[0][0][2] = uff1.jpg

containerOne[0][1][0] = uff2.jpg
containerOne[0][1][1] = uff2.jpg
containerOne[0][1][2] = uff2.jpg


...chi mi da una mano? :)


Olà!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 06-03-08, 05:33
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,446
Rep Power: 6
Flep is on a distinguished road
Re: Array multidimensionali

Ciao Sassa,
tridimensionali non li ho mai fatti ( credo siano una bella bega da gestire ).

Però potresti partire da uno bidimensionale e provare ad andare oltre.

Trovi un paio di esempi bidimensionali quì:

Multiple Gallery XML Slideshow

http://www.flepstudio.org/forum/util...li-da-xml.html
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 14-03-08, 17:32
Junior Member
 
Join Date: Jan 2008
Posts: 7
Rep Power: 0
grptx is on a distinguished road
Re: Array multidimensionali

un array multidimensionale non è altro che un array i cui elementi sono altri array.
Quindi :
un array 3d è un array i cui elementi sono array 2d
un array 2d è un array i cui elementi sono array 1d
un array 1d è un array normale.

Code:
var container3D:Array=new Array();
for (var i:uint=0; i<20; i++) {
    var container2D:Array=new Array();
    for (var j:uint=0; j<20; j++) {
        var container1D:Array=new Array();
        for (var k:uint=0; k<20; k++) {
            container1D[k]="cella["+i+"]["+j+"]["+k+"]";

        }
        container2D[j]=container1D;
    }
    container3D[i]=container2D;
}
trace(container3D[3][2][4]);
__________________
blog : myspace : work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 16-03-08, 23:47
Author
 
Join Date: Nov 2007
Posts: 12
Rep Power: 0
powerSassa is on a distinguished road
Re: Array multidimensionali

Ciao grptx,
in realtà l'Array 3D mi serviva per "riprodurre" un' xml, ma non riesco ad applicare la tua soluzione.
L'xml è fatto così:

<?xml version="1.0" ?>
<photosite>
<containerOne imgUrl="img/lea.jpg">
<containerTwo imgUrl="img/person.jpg">
<containerTrhee imgUrl="uff1.jpg"></containerTrhee>
<containerTrhee imgUrl="uff1.jpg"></containerTrhee>
<containerTrhee imgUrl="uff1.jpg"></containerTrhee>
</containerTwo>
<containerTwo imgUrl="img/person.jpg">
<containerTrhee imgUrl="uff2.jpg"></containerTrhee>
<containerTrhee imgUrl="uff2.jpg"></containerTrhee>
<containerTrhee imgUrl="uff2.jpg"></containerTrhee>
</containerTwo>
<containerTwo imgUrl="img/person.jpg">
<containerTrhee imgUrl="uff3.jpg"></containerTrhee>
<containerTrhee imgUrl="uff3.jpg"></containerTrhee>
<containerTrhee imgUrl="uff3.jpg"></containerTrhee>
</containerTwo>
<containerTwo imgUrl="img/person.jpg">
<containerTrhee imgUrl="uff4.jpg"></containerTrhee>
<containerTrhee imgUrl="uff4.jpg"></containerTrhee>
<containerTrhee imgUrl="uff4.jpg"></containerTrhee>
</containerTwo>
</containerOne>
</photosite>

Grazie.
PowerSassa
__________________
Sassa
Papervision3D Code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 17-03-08, 01:05
Junior Member
 
Join Date: Jan 2008
Posts: 7
Rep Power: 0
grptx is on a distinguished road
Re: Array multidimensionali

bhè se hai un file xml come quello, già dopo il load del file hai un array multidimensionale:

Code:
var myXML:XML=new XML;
var XML_URL:String="xmlfile.xml";
var myXMLURL:URLRequest=new URLRequest(XML_URL);
var myLoader:URLLoader=new URLLoader(myXMLURL);
myLoader.addEventListener(Event.COMPLETE,xmlLoaded);
function xmlLoaded(event:Event):void {
    myXML=XML(myLoader.data);
    trace(String(myXML.containerOne[0].containerTwo[1].containerTrhee[0].@imgUrl));
}
questo darà in output: uff2.jpg

p.s. si scrive Three non Trhee ... ;)

gx
__________________
blog : myspace : work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Flash Multi Gallery
  #6 (permalink)  
Old 17-03-08, 01:17
Junior Member
 
Join Date: Jan 2008
Posts: 7
Rep Power: 0
grptx is on a distinguished road
Re: Array multidimensionali

se poi vuoi proprio un array classico puoi costruirlo manualmente:

Code:
var myXML:XML=new XML;
var XML_URL:String="xmlfile.xml";
var myXMLURL:URLRequest=new URLRequest(XML_URL);
var myLoader:URLLoader=new URLLoader(myXMLURL);
myLoader.addEventListener(Event.COMPLETE,xmlLoaded);
function xmlLoaded(event:Event):void {
    myXML=XML(myLoader.data);
    var containerArr:Array=new Array();
    for each (var item0:XML in myXML.containerOne) {
        var containerTwo:Array=new Array();
        for each (var item1:XML in item0.containerTwo) {
            var containerTrhee:Array=new Array();
            for each (var item2:XML in item1.containerTrhee) {
                containerTrhee.push(item2);
            }
            containerTwo.push(containerTrhee);
        }
        containerArr.push(containerTwo);
    }
    trace(containerArr[0][1][0].@imgUrl);
    trace(String(myXML.containerOne[0].containerTwo[1].containerTrhee[0].@imgUrl));
}
__________________
blog : myspace : work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7 (permalink)  
Old 18-03-08, 00:18
Author
 
Join Date: Nov 2007
Posts: 12
Rep Power: 0
powerSassa is on a distinguished road
Re: Array multidimensionali

Ciao grptx,
perfetto, sei stato chiarissimo.

Per il "containerTrhee" .. è stato un copia/incolla errato, I'm sorry!
__________________
Sassa
Papervision3D Code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
array multidimensionali mobbu Actionscript 3.0 avanzato 20 26-08-08 09:53
L' importanza di un Array Flep Articoli e tutorials 1 16-06-08 23:44
array in an array madmad Actionscript 3.0 newbies 1 22-05-08 10:09
filosofia...XML o Array? acca2o Actionscript 3.0 base 0 10-04-08 10:15
array mobbu Actionscript 3.0 base 8 26-09-07 16:57


All times are GMT. The time now is 11:10.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406