Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 05-09-2006, 17:26   #1 (permalink)
Vielfrager
 
Registriert seit: Feb 2004
Beiträge: 67
AS 1.0-Script läuft nicht in AS 2.0 !

hallo alle zusammen,

bitte helft mir, bin relativer AS-Neuling.
Folgendes script läuft einwandfrei als Flash 5. Da ich jedoch auf die Vorzüge von Flash 7 und AS 2.0 nicht verzichten will, soll der Film auch hier laufen. Er tut es aber nicht.

Muss ich bei der Umstellung auf AS 2.0 etwas beachten?

Hier das Script:

movieclip.prototype.zahlenscheibeInit = function(feder, schwung) {
this.feder = feder;
this.schwung = schwung;
for (var i = 0; i<1; i++) {
this.scheibe.winkel = 0;
this.scheibe.drehung = 0;
}
};

movieclip.prototype.zahlenscheibeSteuern = function() {
for (var i = 0; i<1; i++) {
if (i<wert.length) {
this.scheibe.zahl = wert.substr(i);
}
with (this.scheibe) {
ziel = -zahl*36;
diff = ziel-winkel;
if (diff>180) {
diff -= 360;
}
if (diff<-180) {
diff += 360;
}
drehung = drehung*feder+diff*schwung;
winkel += drehung;
if (winkel>360) {
winkel -= 360;
}
if (winkel<-360) {
winkel += 360;
}
_rotation = winkel;
}
}
};

Das ganze zum Download:

Film:
http://www.derbuntmacher.de/flashtes...ng_F5_AS10.swf

Flash-Datei:
http://www.derbuntmacher.de/flashtes...ng_F5_AS10.fla

danke für Eure hilfe ;-)

beste Grüße
Thomas ;-)
derbuntmacher ist offline   Mit Zitat antworten
Alt 05-09-2006, 17:36   #2 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
Es heißt z.B. schon mal
Code:
MovieClip.prototype
__________________
RTFM
Wie man Fragen richtig stellt.

Achim Bindannmalweg

Money makes the world go round, fear makes it turn much faster.
(New Model Army)
sonar ist offline   Mit Zitat antworten
Alt 05-09-2006, 19:15   #3 (permalink)
Vielfrager
 
Registriert seit: Feb 2004
Beiträge: 67
Ersatz für prototype in AS 2.0

@sonar - danke. ich habe vergessen dass Flash ab AS 2.0 etwas strenger geworden ist ;-)

Kann mir jemand eine alternative für "prototype" zeigen? Habe gelesen das AS 2.0 damit nicht umgehen kann.

Danke ;-)
und beste Grüße...
derbuntmacher ist offline   Mit Zitat antworten
Alt 06-09-2006, 08:42   #4 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
Nee, prototype geht in AS 2 auch noch.
Was ich meinte: du musst bspw. mit Groß- und Kleinschreibung aufpassen.
__________________
RTFM
Wie man Fragen richtig stellt.

Achim Bindannmalweg

Money makes the world go round, fear makes it turn much faster.
(New Model Army)
sonar ist offline   Mit Zitat antworten
Alt 06-09-2006, 09:33   #5 (permalink)
Nagelneuer User
 
Benutzerbild von hazy fantazy
 
Registriert seit: Dec 2005
Beiträge: 924
Kleine Anmerkung am Rande, hoffentlich verwirrt das nicht zu sehr. Dein Script ist kein AS2, deshalb macht es auch keinen Sinn, es als AS2 zu kompilieren.

mfg. h
__________________
The fact that you've got "Replica" written on the side of your gun and the fact that I've got "Desert Eagle written on the side of mine ... :D
hazy fantazy ist offline   Mit Zitat antworten
Alt 06-09-2006, 12:11   #6 (permalink)
Vielfrager
 
Registriert seit: Feb 2004
Beiträge: 67
Umformulierung in AS2

@hazy fantazy und @sonar
ich danke euch.

kann mir jemand sagen ich das script in as2 formuliere?

als as1 funktioniert das ganze nur bis flash5 ab flash6 geht nichts mehr!

Danke ;-)
und beste Grüße...
derbuntmacher ist offline   Mit Zitat antworten
Alt 06-09-2006, 12:24   #7 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
Die von mir genannte Änderung mit dem prototype hast eingebaut..?
__________________
RTFM
Wie man Fragen richtig stellt.

Achim Bindannmalweg

Money makes the world go round, fear makes it turn much faster.
(New Model Army)
sonar ist offline   Mit Zitat antworten
Alt 06-09-2006, 12:29   #8 (permalink)
Vielfrager
 
Registriert seit: Feb 2004
Beiträge: 67
@sonar

ja, hab ich. statt "movieclip" eben "MovieClip"

funzt immer noch nicht

hast du eine id?

Flash-Datei (noch als funktionierende Flash5):
http://www.derbuntmacher.de/flashtes...ng_F5_AS10.fla

beste grüße
thomas
derbuntmacher ist offline   Mit Zitat antworten
Alt 06-09-2006, 18:01   #9 (permalink)
Vielfrager
 
Registriert seit: Feb 2004
Beiträge: 67
Unhappy Flash 5 script läuft nicht in F7 - AS2 ?!?

Hallo, habe mein script schon etwas abgekürzt und MovieClip groß geschrieben. Es will trotzdem nicht funktionieren (weder F7 AS1, noch AS2).
Könnt Ihr mir helfen?
Bin für jede Antwort dankbar.

script auf MC "zahlenscheibe":

onClipEvent (load) {
zahlenscheibeInit(0.8, 0.1);
}
onClipEvent (enterFrame) {
zahlenscheibeSteuern();
}


script auf Ebene "Aktion":

MovieClip.prototype.zahlenscheibeInit = function(feder, schwung) {
this.feder = feder;
this.schwung = schwung;
};
MovieClip.prototype.zahlenscheibeSteuern = function() {
for (var i = 0; i<1; i++) {
if (i<wert.length) {
_root.zahlenscheibe.scheibe.zahl = wert.substr(i);
}
with (_root.zahlenscheibe.scheibe) {
ziel = -zahl*36;
diff = ziel-winkel;
if (diff>180) {
diff -= 360;
}
if (diff<-180) {
diff += 360;
}
drehung = drehung*feder+diff*schwung;
winkel += drehung;
if (winkel>360) {
winkel -= 360;
}
if (winkel<-360) {
winkel += 360;
}
_rotation = winkel;
}
}
};

script auf den einzelnen Buttons (z.Bsp. Button1):

on (release) {
_root.zahlenscheibe.wert = "1";
}


hab ich noch irgendwo die Groß- und Kleinschreibung nicht beachtet?
oder was funzt hier nicht?

beste grüße,
thomas
derbuntmacher ist offline   Mit Zitat antworten
Alt 07-09-2006, 12:55   #10 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
Wenn ich mir den Code nochmal so anseh... stell ich fest, dass das eigentlich fast von vorn bis hinten kompletter Unsinn is.

Wenn du ne Funktion als prototype-Methode deklarierst, musst du sie auch so aufrufen:
PHP-Code:
MovieClip.prototype.machWas = function() {
    
// ...
}

// richtig:
deinMC.machWas();

// und nicht:
machWas() 
Das brauchst hier aber eh nicht, und vor allem gehören in ne prototype-Methode ü-ber-haupt keine absoluten Referenzierungen wie _root oder Pfade zu nem MC oder so...

Weiter: diese onClipEvent-Geschichten kann man sich seit Flash MX auch schenken. Kann man alles von der Timeline, in der der Clip lebt, steuern.

Tu mal ne (ggf. abgespeckte) Version deiner FLA, in der du das einsetzen willst, hier hoch.
Weil das jetzt nachzubauen, is mir zu umständlich...

Übrigens gibt's hier Code-Tags, die deinen Code lesbar machen, z.B.

[ php ]
Code...
[ /php ]

(dann ohne Leerzeichen)
__________________
RTFM
Wie man Fragen richtig stellt.

Achim Bindannmalweg

Money makes the world go round, fear makes it turn much faster.
(New Model Army)
sonar ist offline   Mit Zitat antworten
Alt 07-09-2006, 18:32   #11 (permalink)
Vielfrager
 
Registriert seit: Feb 2004
Beiträge: 67
FLA und SWF

@Sonar, danke dir.
habe mir deine ratschläge dankend durchgelesen, bin jedoch noch ziemlich AS-unerfahren. (zum button-verlinken, stop und play setzen hats bis jetzt ausgereicht ;-)

hier habe ich die funktionierende Flash5-Version und die Flash7 als SWF/FLA:

Flash 5/AS1:
http://www.derbuntmacher.de/fl/F5_AS1.swf

http://www.derbuntmacher.de/fl/F5_AS1.fla

Flash 7/AS2:
http://www.derbuntmacher.de/fl/F7_AS2.swf

http://www.derbuntmacher.de/fl/F7_AS2.fla

wäre super wen du dir das ansehen könntest ;-)

danke dir
thomas
derbuntmacher ist offline   Mit Zitat antworten
Alt 09-09-2006, 00:55   #12 (permalink)
brand new user
 
Benutzerbild von RustyCake
 
Registriert seit: May 2002
Ort: Laimbach 6 1/2
Beiträge: 16.884
Ist irgendwie nicht so sauber, aber ich bin bisschen aus der übung
PHP-Code:
for (var 0<= 9k++)
{
    
this.zahlenscheibe.scheibe["_btn"].ID k;
    
this.zahlenscheibe.scheibe["_btn"].onRelease = function ()
    {
        
this._parent._parent.steuern (this.ID.toString ());
    };
}
MovieClip.prototype.wackeln = function (federschwungwinkeldrehung)
{
    
this.feder feder;
    
this.schwung schwung;
    
this.winkel winkel;
    
this.drehung drehung;
};
this.zahlenscheibe.wackeln (0.80.100);
MovieClip.prototype.steuern = function (wert)
{
    
this.wert wert;
    
this.ziel ziel;
    
this.zahl zahl;
    
this.diff diff;
    
this.onEnterFrame = function ()
    {
        for (var 
01i++)
        {
            if (
wert)
            {
                
this.zahl this.wert.substr (i);
            }
            else
            {
                
this.zahl 0;
            }
            
with (this.scheibe)
            {
                
this.ziel = -this.zahl 36;
                
this.diff this.ziel this.winkel;
                if (
this.diff 180)
                {
                    
this.diff -= 360;
                }
                if (
this.diff < -180)
                {
                    
this.diff += 360;
                }
                
this.drehung this.drehung this.feder this.diff this.schwung;
                
this.winkel += this.drehung;
                if (
this.winkel 360)
                {
                    
this.winkel -= 360;
                }
                if (
this.winkel < -360)
                {
                    
this.winkel += 360;
                }
                
this._rotation this.winkel;
            }
        }
    };
}; 
der onEnterFRame müßte noch gestoppt werden, hat ich keine zeit mehr zu
__________________
Bitte keine Fragen, zu Flash per PM. Dazu ist das Forum da. Danke MFG_RustyCake!
"Wer tanzen will, muß erst gehen lernen"
RustyCake ist offline   Mit Zitat antworten
Alt 11-09-2006, 12:57   #13 (permalink)
Vielfrager
 
Registriert seit: Feb 2004
Beiträge: 67
danke RustyCake ;-)

@RustyCake, schönen dank ;-)

bevor ich das ganze teste, wo stoppe ich das onEnterFrame?

in der vorletzte zeile einfach

stop();

? ? ?

oder wo/wie?

beste grüße
thomas
derbuntmacher 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 19:08 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele