Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 09-07-2006, 01:29   #1 (permalink)
Neuer User
 
Registriert seit: May 2006
Beiträge: 79
actionscript

hallo! ich hoffe mir kann jm. helfen, wäre super! mache es kurz: dies ist das sccript einer dynamischen bildergalerie. 4 kategorien mit thumbs. WIE KANN ICH KATEGORIEN HINZUFÜGEN (jede kat. ist glaub ich ein separater movieclip) irgendwas mit container spielt auch ne rolle hab schon rumprobiert, klappt nur nicht... VIELEN DANK!!!








var tnNr;
//abstand des rahmens zum bild
spacing = 20;
container._alpha = 0;
var curLength;
MovieClip.prototype.loadPic = function(pic, id) {
info.text = "";
this._alpha = 0;
this.loadMovie(pic);
temp = this._parent.createEmptyMovieClip("temp2", 998);
temp.onEnterFrame = function() {
var t = container.getBytesTotal(), l = container.getBytesLoaded();
if (Math.round(l/t) == 1 && container._width != 0 && container._height != 0) {
var w = container._width+spacing, h = container._height+spacing;
border.resizeMe(w, h, id);
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.resizeMe = function(w, h, id) {
var speed = 4; // geschwindigkeit des bildwechsels
container._alpha = 0;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1) {
this._width = w;
this._height = h;
container._x = this._x-this._width/2+spacing/2; // position der bilder im rahmen
container._y = this._y-this._height/2+spacing/2;
info._y = Math.round(this._y+this._height/2+spacing/2);
container._alpha += 5; //alphawert der bilder
if (container._alpha>90) {
info.text = id;
container._alpha = 100; //alphawert der bilder nach erscheinen
delete this.onEnterFrame;
}
}
};
};
function galleryChoice(q) {
pArray = new Array();
tArray = new Array();
iArray = new Array();
my_xml = new XML();
for (var j = 0; j<curLength; j++) {
this.th_nav["thmb"+j].removeMovieClip();
}
my_xml.ignoreWhite = true;
my_xml.onLoad = function(loaded) {
if (loaded) {
gallery = this.firstChild.childNodes[q];
curLength = gallery.childNodes.length;
for (var i = 0; i<gallery.childNodes.length; i++) {
pArray.push(gallery.childNodes[i].attributes.source);
tArray.push(gallery.childNodes[i].attributes.thumb);
iArray.push(gallery.childNodes[i].attributes.title);
}
}
delay = setInterval(makeButtons, 50);
};
my_xml.load("gallery.xml");
}
function makeButtons() {
tnNr = 0; //gibt an, wieviele thumbs unsichtbar sein sollen
clearInterval(delay);
for (var i = 0; i<tArray.length; i++) {
var thb = th_nav.thmb.duplicateMovieClip("thmb"+i, 1000+i);
thb.id = i;
thb._x = i%3*60; //3 steht für die spaltenanzahl der thumbs; 50 für die abstände zw. den thumbs
thb._y = Math.floor(i/3)*50;
}
loadButtons();
}
function loadButtons() {
var tbox = th_nav["thmb"+tnNr].box;
tbox.loadMovie(tArray[tnNr]);
temp = this.createEmptyMovieClip("tmp"+tnNr, 999);
temp.onEnterFrame = function() {
bt = tbox.getBytesTotal();
bl = tbox.getBytesLoaded();
if (bt == bl && bt>4) {
nextButton();
delete this.onEnterFrame;
}
};
}
function nextButton() {
if (tnNr<tArray.length-1) {
tnNr++;
loadButtons();
} else {
activateButtons();
}
}
function activateButtons() {
mainButtons();
for (var i = 0; i<pArray.length; i++) {
var but = th_nav["thmb"+i];
but.id = i;
but.onRelease = function() {
container.loadPic(pArray[this.id], iArray[this.id]);
disButtons2(this.id);
};
}
container.loadPic(pArray[0], iArray[0]);
disButtons2(0);
}
butArray = new Array();
butArray = ["gal1_btn", "gal2_btn", "gal3_btn", "gal4_btn"];
function mainButtons() {
for (var i = 0; i<butArray.length; i++) {
this[butArray[i]].id = i;
this[butArray[i]].onRelease = function() {
galleryChoice(this.id);
disButtons(this.id);
};
}
}
function disButtons2(d) {
for (var i = 0; i<tArray.length; i++) {
if (i != d) {
this.th_nav["thmb"+i].enabled = 1;
this.th_nav["thmb"+i].box._alpha = 100; //alphawert der thumbs im normalzustand
} else {
this.th_nav["thmb"+i].enabled = 0;
this.th_nav["thmb"+i].box._alpha = 20; //alphawert der thumbs im gedrückten zustand
}
}
}
function disButtons(d) {
for (var i = 0; i<butArray.length; i++) {
if (i != d) {
this[butArray[i]].enabled = 1;
this[butArray[i]].gotoAndStop(1);
} else {
this[butArray[i]].enabled = 0;
this[butArray[i]].gotoAndStop(2);
}
}
}
disButtons(0);
galleryChoice(0);
momento ist offline   Mit Zitat antworten
Alt 09-07-2006, 11:02   #2 (permalink)
Der Wunderhund
 
Benutzerbild von gaspode
 
Registriert seit: Jun 2002
Ort: Hattingen
Beiträge: 10.515
Hallo.

Wie sieht denn das passende XML-Dokument aus?

gruß, gaspode
gaspode ist offline   Mit Zitat antworten
Alt 09-07-2006, 12:02   #3 (permalink)
Flashworker
 
Benutzerbild von sebastian
 
Registriert seit: Nov 2001
Ort: Wiesbaden
Beiträge: 10.945
Einrückungen und Code Tags sind was feines.. Sowas geht ja noch
bei 5 Zeilen Code, aber was ist das bitte?



ActionScript:
  1. var tnNr;
  2. //abstand des rahmens zum bild
  3. spacing = 20;
  4. container._alpha = 0;
  5. var curLength;
  6. MovieClip.prototype.loadPic = function(pic, id)
  7. {
  8.     info.text = "";
  9.     this._alpha = 0;
  10.     this.loadMovie(pic);
  11.     temp = this._parent.createEmptyMovieClip("temp2", 998);
  12.     temp.onEnterFrame = function()
  13.     {
  14.         var t = container.getBytesTotal(), l = container.getBytesLoaded();
  15.         if (Math.round(l/t) == 1 && container._width != 0 && container._height != 0)
  16.         {
  17.             var w = container._width+spacing, h = container._height+spacing;
  18.             border.resizeMe(w, h, id);
  19.             delete this.onEnterFrame;
  20.         }
  21.     };
  22. };
  23. MovieClip.prototype.resizeMe = function(w, h, id)
  24. {
  25.     var speed = 4;
  26.     // geschwindigkeit des bildwechsels
  27.     container._alpha = 0;
  28.     this.onEnterFrame = function()
  29.     {
  30.         this._width += (w-this._width)/speed;
  31.         this._height += (h-this._height)/speed;
  32.         if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1)
  33.         {
  34.             this._width = w;
  35.             this._height = h;
  36.             container._x = this._x-this._width/2+spacing/2;
  37.             // position der bilder im rahmen
  38.             container._y = this._y-this._height/2+spacing/2;
  39.             info._y = Math.round(this._y+this._height/2+spacing/2);
  40.             container._alpha += 5;
  41.             //alphawert der bilder
  42.             if (container._alpha>90)
  43.             {
  44.                 info.text = id;
  45.                 container._alpha = 100;
  46.                 //alphawert der bilder nach erscheinen
  47.                 delete this.onEnterFrame;
  48.             }
  49.         }
  50.     };
  51. };
  52. function galleryChoice(q)
  53. {
  54.     pArray = new Array();
  55.     tArray = new Array();
  56.     iArray = new Array();
  57.     my_xml = new XML();
  58.     for (var j = 0; j<curLength; j++)
  59.     {
  60.         this.th_nav["thmb"+j].removeMovieClip();
  61.     }
  62.     my_xml.ignoreWhite = true;
  63.     my_xml.onLoad = function(loaded)
  64.     {
  65.         if (loaded)
  66.         {
  67.             gallery = this.firstChild.childNodes[q];
  68.             curLength = gallery.childNodes.length;
  69.             for (var i = 0; i<gallery.childNodes.length; i++)
  70.             {
  71.                 pArray.push(gallery.childNodes[i].attributes.source);
  72.                 tArray.push(gallery.childNodes[i].attributes.thumb);
  73.                 iArray.push(gallery.childNodes[i].attributes.title);
  74.             }
  75.         }
  76.         delay = setInterval(makeButtons, 50);
  77.     };
  78.     my_xml.load("gallery.xml");
  79. }
  80. function makeButtons()
  81. {
  82.     tnNr = 0;
  83.     //gibt an, wieviele thumbs unsichtbar sein sollen
  84.     clearInterval(delay);
  85.     for (var i = 0; i<tArray.length; i++)
  86.     {
  87.         var thb = th_nav.thmb.duplicateMovieClip("thmb"+i, 1000+i);
  88.         thb.id = i;
  89.         thb._x = i%3*60;
  90.         //3 steht für die spaltenanzahl der thumbs; 50 für die abstände zw. den thumbs
  91.         thb._y = Math.floor(i/3)*50;
  92.     }
  93.     loadButtons();
  94. }
  95. function loadButtons()
  96. {
  97.     var tbox = th_nav["thmb"+tnNr].box;
  98.     tbox.loadMovie(tArray[tnNr]);
  99.     temp = this.createEmptyMovieClip("tmp"+tnNr, 999);
  100.     temp.onEnterFrame = function()
  101.     {
  102.         bt = tbox.getBytesTotal();
  103.         bl = tbox.getBytesLoaded();
  104.         if (bt == bl && bt>4)
  105.         {
  106.             nextButton();
  107.             delete this.onEnterFrame;
  108.         }
  109.     };
  110. }
  111. function nextButton()
  112. {
  113.     if (tnNr<tArray.length-1)
  114.     {
  115.         tnNr++;
  116.         loadButtons();
  117.     }
  118.     else
  119.     {
  120.         activateButtons();
  121.     }
  122. }
  123. function activateButtons()
  124. {
  125.     mainButtons();
  126.     for (var i = 0; i<pArray.length; i++)
  127.     {
  128.         var but = th_nav["thmb"+i];
  129.         but.id = i;
  130.         but.onRelease = function()
  131.         {
  132.             container.loadPic(pArray[this.id], iArray[this.id]);
  133.             disButtons2(this.id);
  134.         };
  135.     }
  136.     container.loadPic(pArray[0], iArray[0]);
  137.     disButtons2(0);
  138. }
  139. butArray = new Array();
  140. butArray = ["gal1_btn", "gal2_btn", "gal3_btn", "gal4_btn"];
  141. function mainButtons()
  142. {
  143.     for (var i = 0; i<butArray.length; i++)
  144.     {
  145.         this[butArray[i]].id = i;
  146.         this[butArray[i]].onRelease = function()
  147.         {
  148.             galleryChoice(this.id);
  149.             disButtons(this.id);
  150.         };
  151.     }
  152. }
  153. function disButtons2(d)
  154. {
  155.     for (var i = 0; i<tArray.length; i++)
  156.     {
  157.         if (i != d)
  158.         {
  159.             this.th_nav["thmb"+i].enabled = 1;
  160.             this.th_nav["thmb"+i].box._alpha = 100;
  161.             //alphawert der thumbs im normalzustand
  162.         }
  163.         else
  164.         {
  165.             this.th_nav["thmb"+i].enabled = 0;
  166.             this.th_nav["thmb"+i].box._alpha = 20;
  167.             //alphawert der thumbs im gedrückten zustand
  168.         }
  169.     }
  170. }
  171. function disButtons(d)
  172. {
  173.     for (var i = 0; i<butArray.length; i++)
  174.     {
  175.         if (i != d)
  176.         {
  177.             this[butArray[i]].enabled = 1;
  178.             this[butArray[i]].gotoAndStop(1);
  179.         }
  180.         else
  181.         {
  182.             this[butArray[i]].enabled = 0;
  183.             this[butArray[i]].gotoAndStop(2);
  184.         }
  185.     }
  186. }
  187. disButtons(0);
  188. galleryChoice(0);
so doch lesbarer oder?

Geändert von sebastian (09-07-2006 um 12:03 Uhr)
sebastian ist offline   Mit Zitat antworten
Alt 09-07-2006, 13:52   #4 (permalink)
Neuer User
 
Registriert seit: May 2006
Beiträge: 79
das passende xml-dokument ist dieses hier:



<?xml version="1.0" encoding="UTF-8"?>
<menu>



<gallery name="galerie1">
<image source="pics/pic63.jpg"
thumb="pics/th63.jpg"/>
<image source="pics/pic64.jpg" thumb="pics/th64.jpg"/>
<image source="pics/pic67.jpg" thumb="pics/th67.jpg"/>
<image source="pics/pic66.jpg" thumb="pics/th66.jpg"/>
<image source="pics/pic65.jpg" thumb="pics/th65.jpg"/>
<image source="pics/pic68.jpg" thumb="pics/th68.jpg"/>
<image source="pics/pic5.jpg" thumb="pics/th5.jpg"/>
<image source="pics/pic6.jpg" thumb="pics/th6.jpg"/>
<image source="pics/pic7.jpg" thumb="pics/th7.jpg"/>
<image source="pics/pic8.jpg" thumb="pics/th8.jpg"/>
<image source="pics/pic26.jpg" thumb="pics/th26.jpg"/>
<image source="pics/pic74.jpg" thumb="pics/th74.jpg"/>
<image source="pics/pic10.jpg" thumb="pics/th10.jpg"/>
<image source="pics/pic75.jpg" thumb="pics/th75.jpg"/>
<image source="pics/pic77.jpg" thumb="pics/th77.jpg"/>
<image source="pics/pic76.jpg" thumb="pics/th76.jpg"/>
<image source="pics/pic9.jpg" thumb="pics/th9.jpg"/>
<image source="pics/pic46.jpg" thumb="pics/th46.jpg"/>
<image source="pics/pic47.jpg" thumb="pics/th47.jpg"/>
<image source="pics/pic48.jpg" thumb="pics/th48.jpg"/>
<image source="pics/pic49.jpg" thumb="pics/th49.jpg"/>
<image source="pics/pic51.jpg" thumb="pics/th51.jpg"/>
<image source="pics/pic52.jpg" thumb="pics/th52.jpg"/>
<image source="pics/pic53.jpg" thumb="pics/th53.jpg"/>
<image source="pics/pic54.jpg" thumb="pics/th54.jpg"/>
<image source="pics/pic73.jpg" thumb="pics/th73.jpg"/>
<image source="pics/pic70.jpg" thumb="pics/th70.jpg"/>



</gallery>


<gallery name="galerie2">
<image source="pics/pic11.jpg" thumb="pics/th11.jpg"/>
<image source="pics/pic12.jpg" thumb="pics/th12.jpg"/>
<image source="pics/pic13.jpg" thumb="pics/th13.jpg"/>
<image source="pics/pic14.jpg" thumb="pics/th14.jpg"/>
<image source="pics/pic15.jpg" thumb="pics/th15.jpg"/>
<image source="pics/pic16.jpg" thumb="pics/th16.jpg"/>
<image source="pics/pic17.jpg" thumb="pics/th17.jpg"/>
<image source="pics/pic18.jpg" thumb="pics/th18.jpg"/>
<image source="pics/pic19.jpg" thumb="pics/th19.jpg"/>
<image source="pics/pic20.jpg" thumb="pics/th20.jpg"/>
<image source="pics/pic21.jpg" thumb="pics/th21.jpg"/>
<image source="pics/pic22.jpg" thumb="pics/th22.jpg"/>
<image source="pics/pic23.jpg" thumb="pics/th23.jpg"/>
<image source="pics/pic24.jpg" thumb="pics/th24.jpg"/>
<image source="pics/pic25.jpg" thumb="pics/th25.jpg"/>
<image source="pics/pic33.jpg" thumb="pics/th33.jpg"/>
<image source="pics/pic34.jpg" thumb="pics/th34.jpg"/>
<image source="pics/pic35.jpg" thumb="pics/th35.jpg"/>





</gallery>








<gallery name="galerie3">
<image source="pics/pic27.jpg" thumb="pics/th27.jpg"/>
<image source="pics/pic28.jpg" thumb="pics/th28.jpg"/>
<image source="pics/pic29.jpg" thumb="pics/th29.jpg"/>
<image source="pics/pic30.jpg" thumb="pics/th30.jpg"/>
<image source="pics/pic31.jpg" thumb="pics/th31.jpg"/>
<image source="pics/pic58.jpg" thumb="pics/th58.jpg"/>
<image source="pics/pic59.jpg" thumb="pics/th59.jpg"/>
<image source="pics/pic60.jpg" thumb="pics/th60.jpg"/>
<image source="pics/pic61.jpg" thumb="pics/th61.jpg"/>
<image source="pics/pic62.jpg" thumb="pics/th62.jpg"/>
<image source="pics/pic71.jpg" thumb="pics/th71.jpg"/>


</gallery>




<gallery name="galerie4">

<image source="pics/pic1.jpg" thumb="pics/th1.jpg"/>
<image source="pics/pic2.jpg" thumb="pics/th2.jpg"/>
<image source="pics/pic3.jpg" thumb="pics/th3.jpg"/>
<image source="pics/pic4.jpg" thumb="pics/th4.jpg"/>
<image source="pics/pic36.jpg" thumb="pics/th36.jpg"/>
<image source="pics/pic37.jpg" thumb="pics/th37.jpg"/>
<image source="pics/pic38.jpg" thumb="pics/th38.jpg"/>
<image source="pics/pic39.jpg" thumb="pics/th39.jpg"/>
<image source="pics/pic40.jpg" thumb="pics/th40.jpg"/>
<image source="pics/pic41.jpg" thumb="pics/th41.jpg"/>
<image source="pics/pic42.jpg" thumb="pics/th42.jpg"/>
<image source="pics/pic43.jpg" thumb="pics/th43.jpg"/>
<image source="pics/pic44.jpg" thumb="pics/th44.jpg"/>
<image source="pics/pic45.jpg" thumb="pics/th45.jpg"/>
<image source="pics/pic69.jpg" thumb="pics/th69.jpg"/>
<image source="pics/pic72.jpg" thumb="pics/th72.jpg"/>



</gallery>
momento ist offline   Mit Zitat antworten
Alt 09-07-2006, 14:19   #5 (permalink)
Flash...
 
Benutzerbild von Scheidlf
 
Registriert seit: Dec 2005
Ort: Österreich
Beiträge: 961
1. wieso nennst du deine Knoten gleich??

2. Hups hast du eh (ich muss genauer lesen)

Geändert von Scheidlf (09-07-2006 um 14:28 Uhr)
Scheidlf ist offline   Mit Zitat antworten
Alt 09-07-2006, 14:25   #6 (permalink)
Neuer User
 
Registriert seit: May 2006
Beiträge: 79
na ja, wie gesagt, ich habe diese vorlage im netz gefunden und frage mich nun, wie ich weitere bilder-kategorien erstellen kann. weiß nicht, wo das festgelegt ist, da ich im scrpit nicht durchsteige...
momento ist offline   Mit Zitat antworten
Alt 09-07-2006, 14:27   #7 (permalink)
Flash...
 
Benutzerbild von Scheidlf
 
Registriert seit: Dec 2005
Ort: Österreich
Beiträge: 961
wenn du so eins

PHP-Code:
<gallery name="galerie4">

<
image source="pics/pic1.jpg" thumb="pics/th1.jpg"/>
<
image source="pics/pic2.jpg" thumb="pics/th2.jpg"/>
<
image source="pics/pic3.jpg" thumb="pics/th3.jpg"/>
<
image source="pics/pic4.jpg" thumb="pics/th4.jpg"/>
<
image source="pics/pic36.jpg" thumb="pics/th36.jpg"/>
<
image source="pics/pic37.jpg" thumb="pics/th37.jpg"/>
<
image source="pics/pic38.jpg" thumb="pics/th38.jpg"/>
<
image source="pics/pic39.jpg" thumb="pics/th39.jpg"/>
<
image source="pics/pic40.jpg" thumb="pics/th40.jpg"/>
<
image source="pics/pic41.jpg" thumb="pics/th41.jpg"/>
<
image source="pics/pic42.jpg" thumb="pics/th42.jpg"/>
<
image source="pics/pic43.jpg" thumb="pics/th43.jpg"/>
<
image source="pics/pic44.jpg" thumb="pics/th44.jpg"/>
<
image source="pics/pic45.jpg" thumb="pics/th45.jpg"/>
<
image source="pics/pic69.jpg" thumb="pics/th69.jpg"/>
<
image source="pics/pic72.jpg" thumb="pics/th72.jpg"/>



</
gallery
noch dazutust, kommt eine neue kategorie
also für jeden Knoten (das oben ist einer) wird eine Kategorie dazugefügt.
Scheidlf ist offline   Mit Zitat antworten
Alt 09-07-2006, 14:58   #8 (permalink)
Flashworker
 
Benutzerbild von sebastian
 
Registriert seit: Nov 2001
Ort: Wiesbaden
Beiträge: 10.945
Zitat:
Zitat von momento
na ja, wie gesagt, ich habe diese vorlage im netz gefunden und frage mich nun, wie ich weitere bilder-kategorien erstellen kann. weiß nicht, wo das festgelegt ist, da ich im scrpit nicht durchsteige...
Hilfe, ich hab keine Ahnung von Flash und hab mir im Web
was runtergeladen und poste mal die 200 Zeilen und lass
es mir umschreiben...

Muss leider mal wieder den Kopf schütteln, aber vielleicht
arbeitet sich da ja wirklich jemand rein.

greetz
sebastian ist offline   Mit Zitat antworten
Alt 09-07-2006, 16:35   #9 (permalink)
Neuer User
 
Registriert seit: May 2006
Beiträge: 79
danke @scheidlf. hab das schon versucht, es funktioniert nicht. müsste ja theoretisch noch einen weiteren movieclip (jedes wort, also jede kategorie ist ein movieclip) hinzufügen. hab das versucht indem ich einen movieclip kopiert habe, aber sobald ich das gemacht habe, kann ich das wort nicht mehr anklicken.


@sebastian. 1. hab ich ahnung in flash. (es gibt aber eben auch sachen wie diese, die ich nicht drauf hab) und 2. hab ich schon soweit alles selbst versucht wie es geht und bin gescheitert... ach ja, und 3. ist das hier doch ein forum für fragen bezüglich flash, oder irre ich mich da? sorry, aber solche antworten sind sowas von überhaupt gar nicht hilfreich... das ärgert mich, wenn einem unterstellt wird, man habe nur kopiert und will anderen die arbeit überlassen... du weißt nicht wie lange ich daran schon herum probiere... gruß, julia
momento ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 05:01 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele