Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 09-04-2004, 00:47   #1 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
AS-Code ausführen?!

Hallo,

ich baue mir ActionScript-Code in einer Schleife zusammen und will diesen, nachdem die Schleife durchgelaufen ist, ausführen. Gibt es da eine Möglichkeit?

Bsp.:

ActionScript:
  1. var x = "";
  2. for(i = 0; i < de_navi.length; i++) {
  3. temp = eval("naviName"+i);
  4. x += temp1+".onEnterFrame = function() { if ("+temp1+".hitTest(_root._xmouse, _root._ymouse, true)) "+temp+".setTextFormat(over); else "+temp+".setTextFormat(out);};";
  5. } // end for
  6.  

Jetzt würde ich gerne den Inhalt der Variablen x ausführen...

Freue mich über Eure Hilfe.

Vielen Dank,
chris
chrisTheMan ist offline   Mit Zitat antworten
Alt 09-04-2004, 11:25   #2 (permalink)
Flashaholic
 
Benutzerbild von atothek
 
Registriert seit: Feb 2003
Ort: Berlin
Beiträge: 1.459
was spricht gegen

ActionScript:
  1. for (i=0; i<5; i++) {
  2.     temp = this["naviName"+i];
  3.     temp.onEnterFrame = function() {
  4.         if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
  5.             trace(this._name);
  6.         }
  7.     };
  8. }

????
__________________
TVNEXT Solutions
atothek ist offline   Mit Zitat antworten
Alt 09-04-2004, 11:57   #3 (permalink)
Halbzeitflasher
 
Benutzerbild von lepimax
 
Registriert seit: Jul 2001
Ort: München
Beiträge: 823
mußte so machen wie atothek schreibt.
in laufzeit complieren geht so nicht.
eval ist in as nicht so mächtig wie im javascript.
javascript wird ja auch im browser compiliet. wenn man das so sagen darf.

Gruß
Lepi
__________________
have a nice day
lepimax ist offline   Mit Zitat antworten
Alt 09-04-2004, 12:26   #4 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
Vielen Dank atothek! Dein Beispiel funktioniert wunderbar. Wie kriege ich mein Beispiel zum Laufen???

Der folgende Code funktioniert leider nur zum Teil. Ich schätze, dass ich bei
Zitat:
temp1.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) temp.setTextFormat(over);
else temp.setTextFormat(out);
};
die Variable temp irgendwie anders ansprechen muss. Aber wie?


ActionScript:
  1. for(i = 0; i < de_navi.length; i++) {
  2.     depth = "10"+i;
  3.  
  4.     _root.createTextField("naviName"+i,depth,0,0,200,100);
  5.     temp = this["naviName"+i];
  6.     temp.autoSize = true;
  7.     temp.selectable = false;
  8.     temp.html = true;
  9.     temp.htmlText ="<a href=\"asfunction:_root.doNavi,"+ temp +"\">"+ de_navi[i] +" .  </a>";
  10.    
  11.     temp.setTextFormat(myFormat);
  12.     temp._x = xPos;
  13.     temp._y = 154;
  14.    
  15.     clipWidth = temp._width;
  16.    
  17.     _root.attachMovie("bt_bg", "bt_bg"+i, depth-100);
  18.     temp1 = this["bt_bg"+i];
  19.     temp1._xscale = clipWidth;
  20.     temp1._yscale = 20;
  21.     temp1._x = xPos;
  22.     temp1._y = 154;
  23.     temp1._visible = false;
  24.     xPos += temp._width;
  25.  
  26.     temp1.onEnterFrame = function() {
  27.         if (this.hitTest(_root._xmouse, _root._ymouse, true)) temp.setTextFormat(over);
  28.         else temp.setTextFormat(out);
  29.     };
  30. }

Vielen Dank für die Hilfe!
chrisTheMan ist offline   Mit Zitat antworten
Alt 09-04-2004, 16:32   #5 (permalink)
Flashaholic
 
Benutzerbild von atothek
 
Registriert seit: Feb 2003
Ort: Berlin
Beiträge: 1.459
füg mal folgende zeile über das onEnterFrame

ActionScript:
  1. temp1.tf=temp;

und das onEnterFrame in

ActionScript:
  1. temp1.onEnterFrame = function() {
  2.                 if (this.hitTest(_root._xmouse, _root._ymouse, true)) this.tf.setTextFormat(over);
  3.                 else this.tf.setTextFormat(out);
  4.         };

dann müßte es laufen aber ich frag mich jetzt mal warum du ein onEnterFRame für das alles brauchst für mich siht das alles nach einem einfachen RollOver effekt aus oder wie?????
__________________
TVNEXT Solutions
atothek ist offline   Mit Zitat antworten
Alt 09-04-2004, 18:11   #6 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
supercool, genau, das war's

Vielen Dank!!!
chrisTheMan ist offline   Mit Zitat antworten
Alt 09-04-2004, 18:33   #7 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
@atothek: Jetzt hatte ich ganz vergessen auf Deine Frage zu antworten, warum ich das mit dem onEnterFrame mache. Ich habe es mit einem onRollOver versucht, was aber nicht funktioniert hat, weil die Funktion beim Draufrollen und Rausrollen aufgerufen wird...

ActionScript:
  1. temp1.onRollOver = function() {
  2. this.tf.setTextFormat(over);
  3. };
  4. temp1.onRollOut = function() {
  5. this.tf.setTextFormat(out);
  6. };
Ist ein onEnterFrame mit einem hitTest sehr viel rechenaufwendiger?
chrisTheMan ist offline   Mit Zitat antworten
Alt 09-04-2004, 20:35   #8 (permalink)
Flashaholic
 
Benutzerbild von atothek
 
Registriert seit: Feb 2003
Ort: Berlin
Beiträge: 1.459
versuch das ganze mal mit

this.tf.setNewTextFormat(out);

this.tf.setNewTextFormat(over);
__________________
TVNEXT Solutions
atothek ist offline   Mit Zitat antworten
Alt 09-04-2004, 22:36   #9 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
ich fürchte, ich weiss nicht genau was Du meinst.

was bingt das für Vorteile, ob ich setTextFormat oder setNewTextFormat verwende?

Geändert von chrisTheMan (10-04-2004 um 00:13 Uhr)
chrisTheMan ist offline   Mit Zitat antworten
Alt 10-04-2004, 09:06   #10 (permalink)
Flashaholic
 
Benutzerbild von atothek
 
Registriert seit: Feb 2003
Ort: Berlin
Beiträge: 1.459
Ja sorry mein Fehler hab mich mal wieder nur zur hälftew mitgeteilt

ActionScript:
  1. temp1.onRollOver = function() {
  2.         this.tf.setNewTextFormat(over);
  3. };
  4. temp1.onRollOut = function() {
  5.         this.tf.setNewTextFormat(out);
  6. };

Versuch doch mal die rollOvers mit setNewTextFormat. Den dauernd Laufende onEnterframes sind Performancekiller nr1 und gerade bei solch
na ich sage mal "ridimentären" sachen wie eine art Rollover effekt
__________________
TVNEXT Solutions
atothek ist offline   Mit Zitat antworten
Alt 10-04-2004, 11:58   #11 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
ok, das habe ich verstanden :-)

Das Problem, dass ich habe ist, dass das onRollOut auch beim draufrollen (und nicht nur beim "runterRollen", wie der Name doch eigentlich sagt) ausgeführt wird. Das bedeutet, dass ein onRollOver nur kurz angezeigt und sofort wieder rückgängig gemacht wird.

Mache ich etwas falsch, oder muss ich etwas zusätzliches beachten???
chrisTheMan ist offline   Mit Zitat antworten
Alt 10-04-2004, 13:01   #12 (permalink)
Flashaholic
 
Benutzerbild von atothek
 
Registriert seit: Feb 2003
Ort: Berlin
Beiträge: 1.459
ne das geht nicht da muß der wurm woanders drin sein schick doch mal ne datei oder sowas zum anschauen weil das mit nem onEnterFrame zu lösen ist echt nicht clever
__________________
TVNEXT Solutions
atothek ist offline   Mit Zitat antworten
Alt 10-04-2004, 13:28   #13 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
ok, hier die Datei. Habe das für mich funktionierende Script auskommentiert dringelassen.

Danke, dass Du reinschaust!
Angehängte Dateien
Dateityp: zip thenavi.zip (5,1 KB, 5x aufgerufen)
chrisTheMan ist offline   Mit Zitat antworten
Alt 11-04-2004, 13:08   #14 (permalink)
Flashaholic
 
Benutzerbild von atothek
 
Registriert seit: Feb 2003
Ort: Berlin
Beiträge: 1.459
so eine etwas aufgeräumtere Version

ActionScript:
  1. this.getTextWidth = function(pText) {
  2.     //
  3.     this.createEmptyMovieClip("__TFWidth", 16547);
  4.     this.__TFWidth.createTextField("txt", -2654, 0, 0, 0, 0);
  5.     var tempTf = this.__TFWidth["txt"];
  6.     tempTf.autoSize = true;
  7.     tempTf.html = true;
  8.     tempTf.htmlText = pText;
  9.     tempTf.setTextFormat(this.myFormat);
  10.     var w = tempTf._width;
  11.     _root.__TFWidth.removeMovieClip();
  12.     return w;
  13. };
  14. //
  15. this.setPosition = function(pClip, pX, pY) {
  16.     pClip._x = pX;
  17.     pClip._y = pY;
  18. };
  19. //
  20. this.initSwf = function() {
  21.     //
  22.     this.de_navi = new Array("Produkte", "Neu", "Profil", "Termine", "Kontakt", "Impressum");
  23.     this.myFormat = new TextFormat();
  24.     this.myFormat.embedFonts = true;
  25.     this.myFormat.bold = false;
  26.     this.myFormat.font = "Verdana";
  27.     this.myFormat.size = 12.5;
  28.     //
  29.     this.over = new TextFormat();
  30.     this.over.bold = true;
  31.     //
  32.     this.out = new TextFormat();
  33.     this.out.bold = false;
  34.     //
  35.     this.xPos = 140;
  36.     //
  37.     for (var i = 0; i<this.de_navi.length; i++) {
  38.         //
  39.         var depth = "10"+i;
  40.         var aktName = "butMc"+i;
  41.         var w = this.getTextWidth("<a href=\"asfunction:_root.doNavi,"+temp._name+"\">"+de_navi[i]+" .  </a>");
  42.         // container für bg clip und tf
  43.         this.createEmptyMovieClip(aktName, depth);
  44.         _root[aktName].attachMovie("bt_bg", "bt_bg"+i, 1);
  45.         this.setPosition(_root[aktName], this.xPos, 154);
  46.         //
  47.         var tempMc = _root[aktName]["bt_bg"+i];
  48.         //
  49.         tempMc._xscale = w;
  50.         tempMc._yscale = 20;
  51.         //
  52.         this.xPos += _root[aktName]._width;
  53.         //
  54.         _root[aktName].createTextField("naviName", 2, 0, 0, 0, 0);
  55.         this.setPosition(_root[aktName].naviName, 0, 0);
  56.         //
  57.         var tf = _root[aktName].naviName;
  58.         //
  59.         tf.selectable = false;
  60.         tf.html = true;
  61.         tf.autoSize = true;
  62.         tf.htmlText = "<a href=\"asfunction:_root.doNavi,"+tempMc._name+"\">"+de_navi[i]+" .  </a>";
  63.         tf.setTextFormat(this.myFormat);
  64.         //
  65.         _root[aktName].onRollOver = function() {
  66.             this.naviName.setTextFormat(this._parent.over);
  67.         };
  68.         _root[aktName].onRollOut = function() {
  69.             this.naviName.setTextFormat(this._parent.out);
  70.         };
  71.     }
  72. };
  73. this.initSwf();
__________________
TVNEXT Solutions
atothek ist offline   Mit Zitat antworten
Alt 12-04-2004, 02:01   #15 (permalink)
Neuer User
 
Registriert seit: Apr 2004
Beiträge: 26
supercool, atothek, was soll ich dazu noch sagen??? Von mir würdest Du eine 1 kriegen !

Merke halt schon, dass ich sehr lange kein Flash mehr gemacht habe und mich da erst wieder reinfuxen muss

Aber es macht Spass.

Vielen vielen Dank!!!
chrisTheMan 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 23:22 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele