04/05/2012, 21:45
|
| | Fecha de Ingreso: mayo-2012
Mensajes: 2
Antigüedad: 12 años, 6 meses Puntos: 0 | |
Respuesta: Galería de fotos en Action Script 3 Copio y pego el código que estoy usando de base:
---------------------------------------------------------------------------------------------------------------------
01.import fl.containers.UILoader;
02.import caurina.transitions.*;
03.
04.//---------loading the external xml file-------
05.var urlRequest:URLRequest = new URLRequest("pics.xml");
06.var urlLoader:URLLoader = new URLLoader();
07.var myXML:XML = new XML();
08.var xmlList:XMLList;
09.myXML.ignoreWhitespace = true;
10.urlLoader.addEventListener(Event.COMPLETE,fileL oaded);
11.urlLoader.load(urlRequest);
12.//--------holds the paths to the thumbnails-------
13.var arrayURL:Array = new Array();
14.//--------holds the paths to the big photos-------
15.var arrayName:Array = new Array();
16.//--------holds the thumbnail objects-------
17.var holderArray:Array = new Array();
18.//--------represents the number of collumns-------
19.var nrColumns:uint = 5;
20.//-------represents the container of our gallery
21.var sprite:Sprite = new Sprite();
22.addChild(sprite);
23.var thumb:Thumbnail;
24.//-------- the thumbnails container-------
25.var thumbsHolder:Sprite = new Sprite();
26.sprite.addChild(thumbsHolder);
27.//-------- the photoLoader container-------
28.var loaderHolder:Sprite = new Sprite();
29.loaderHolder.graphics.beginFill(0xffffff,1);
30.loaderHolder.graphics.drawRect(0,0,550,330);
31.loaderHolder.graphics.endFill();
32.loaderHolder.x = 1000;
33.loaderHolder.y = 10;
34.sprite.addChild(loaderHolder);
35.//-------- loads the big photo-------
36.var photoLoader:UILoader = new UILoader();
37.photoLoader.width = 540;
38.photoLoader.height = 320;
39.photoLoader.y = 5;
40.photoLoader.x = 5;
41.photoLoader.buttonMode = true;
42.photoLoader.addEventListener(MouseEvent.CLICK,o nClickBack);
43.loaderHolder.addChild(photoLoader);
44.
45./* we loop through the xml file
46.populate the arrayURL, arrayName and position the thumbnalis */
47.function fileLoaded(event:Event):void {
48.myXML = XML(event.target.data);
49.xmlList = myXML.children();
50.for (var i:int=0; i<xmlList.length(); i++) {
51.var picURL:String = xmlList[ i ].url;
52.var picName:String = xmlList[ i ].big_url;
53.arrayURL.push(picURL);
54.arrayName.push(picName);
55.holderArray[ i ] = new Thumbnail(arrayURL[ i ],i,arrayName[ i ]);
56.holderArray[ i ].addEventListener(MouseEvent.CLICK,onClick);
57.holderArray[ i ].name = arrayName[ i ];
58.holderArray[ i ].buttonMode = true;
59.if (i<nrColumns) {
60.holderArray[ i ].y = 65;
61.holderArray[ i ].x = i*110+65;
62.} else {
63.holderArray[ i ].y = holderArray[ i-nrColumns].y+110;
64.holderArray[ i ].x = holderArray[ i-nrColumns].x;
65.}
66.thumbsHolder.addChild(holderArray[ i ]);
67.}
68.}
69.//----handles the Click event added to the thumbnails--
70.function onClick(event:MouseEvent):void {
71.photoLoader.source = event.currentTarget.name;
72.Tweener.addTween(thumbsHolder, {x:-650, time:1, transition:"easeInElastic"});
73.Tweener.addTween(loaderHolder, {x:10, time:1, transition:"easeInElastic"});
74.Tweener.addTween(thumbsHolder, {alpha:0, time:1, transition:"linear"});
75.Tweener.addTween(loaderHolder, {alpha:1, time:1, transition:"linear"});
76.}
77.//----handles the Click event added to the photoLoader----
78.function onClickBack(event:MouseEvent):void {
79.Tweener.addTween(thumbsHolder, {x:0, time:1, transition:"easeInElastic"});
80.Tweener.addTween(loaderHolder, {x:1000, time:1, transition:"easeInElastic"});
81.Tweener.addTween(thumbsHolder, {alpha:1, time:2, transition:"linear"});
82.Tweener.addTween(loaderHolder, {alpha:0, time:2, transition:"linear"});
83. |