Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 01-09-2003, 13:12   #1 (permalink)
experience++;
 
Benutzerbild von salazar
 
Registriert seit: Jul 2002
Ort: Düsseldorf
Beiträge: 11.347
attach movie initObject frage....

hi ihrs.....
habe da mal ne frage.....
hatte es bisher so gemacht.... auf meiner bühne liegen vier mc´s mit jeweils dem folgenden script drauf:
ActionScript:
  1. onClipEvent(load){
  2. _root.planet01X = this._x
  3. _root.planet01Y = this._y
  4. _root.planet01Xscale = this._xscale;
  5. _root.planet01Yscale = this._yscale;
  6. speed = 5
  7. }
  8.  
  9. onClipEvent(enterFrame){
  10. this._x += (_root.planet01X - this._x)/speed;
  11. this._y += (_root.planet01Y - this._y)/speed;
  12. this._xscale += (_root.planet01Xscale - this._xscale)/speed;
  13. this._yscale += (_root.planet01Yscale - this._yscale)/speed;
  14. }

alles wunderbar soweit, aber jetzt will ich diese mc´s attachen!

das soll so geschehen.....:
ActionScript:
  1. for ( var i = 1; i < 4 + 1; i++ ){
  2.     attachMovie("planet", "planet0"+i, i);
  3. }

wie muß nun das initObject aussehen damit ich das ganze as mit dem mc zusammen attachen kann??

thx & cya, sal
__________________
Bitte keine Flashfragen an mich schicken. Dafür ist ja das Forum da! Das betrifft auch Profilnachrichten.
Chuck Norris hat den Flash Player für alle mobilen Betriebssysteme!
salazar ist offline   Mit Zitat antworten
Alt 01-09-2003, 13:30   #2 (permalink)
◘ ◘
 
Benutzerbild von beachmeat
 
Registriert seit: Dec 2001
Ort: Amsterdam
Beiträge: 6.126
das im Onload würd ich ins initObjekt nehmen, denn onLoad funzt bei attach nadürlisch nich
ActionScript:
  1. var obj = {}
  2. obj.wert = bla
  3. var ref =attachMovie("planet", "planet0"+i, i,obj);
  4.  
  5. //das enterFrame dann so:
  6.  
  7. ref.onEnterFrame = function()
  8. {
  9.  // aktion
  10. }
__________________
jeden Tag frisch
beachmeat ist offline   Mit Zitat antworten
Alt 01-09-2003, 13:33   #3 (permalink)
HAY
Neuer User
 
Benutzerbild von HAY
 
Registriert seit: Aug 2002
Ort: Faust-Stadt
Beiträge: 2.577
hi
so in etwa. du must die mc aber noch positionieren.
ActionScript:
  1. for ( var i = 1; i < 4 + 1; i++ ){
  2.         mc= this.attachMovie("planet", "planet0"+i, i,(_x:300,_y:300,_xscale:100,_yscale:100,speed:5);
  3.         _root["planet0"+i+"X"] = mc._x
  4.         _root["planet0"+i+"Y"]= mc._y
  5.         _root["planet0"+i+"Xscale"] = mc._xscale;
  6.         _root["planet0"+i+"Yscale"] = mc._yscale;
  7.                 mc.i=i
  8.         mc.onEnterFrame = function() {
  9.         this._x += (_root["planet0"+this.i+"X"] - this._x)/speed;
  10.         this._y += (_root["planet0"+this.i+"Y"]- this._y)/speed;
  11.         this._xscale += (_root["planet0"+this.i+"Xscale"]- this._xscale)/speed;
  12.         this._yscale += (_root["planet0"+this.i+"Yscale"]- this._yscale)/speed;
  13. }
  14. }
[edit] mir hats hier einiges verrissen
__________________
gruß Harry

Geändert von HAY (01-09-2003 um 13:37 Uhr)
HAY ist offline   Mit Zitat antworten
Alt 01-09-2003, 13:33   #4 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Ort: Aachen
Beiträge: 1.081
hi,

ich würd das so machen :

ActionScript:
  1. for ( var i = 1; i < 4 + 1; i++ ){
  2.     neuerPlanet="planet0"+String(i)
  3.     this.attachMovie("planet", neuerPlanet, i,{_x:300,_y:300,_xscale:100,_yscale:100,speed:5})
  4.     this[neuerPlanet].onEnterFrame=function() {
  5.         this._x += (this.destX - this._x) / this.speed
  6.         this._y += (this.destY - this._y) / this.speed
  7.         this._xscale += (this.Xscale - this._xscale)/speed
  8.         this._yscale += (this.Yscale - this._yscale)/speed
  9.     }
  10. }

untested. sollte aber funktionieren.

[edit]
Beach, schöne Lösung .
__________________
G.M. | working @ source lounge

Geändert von georgexp (01-09-2003 um 13:35 Uhr)
georgexp ist offline   Mit Zitat antworten
Alt 01-09-2003, 13:38   #5 (permalink)
experience++;
 
Benutzerbild von salazar
 
Registriert seit: Jul 2002
Ort: Düsseldorf
Beiträge: 11.347
wow, geilo! vielen dank schonmal an euch... werds gleich mal antesten....

@georgexp:
sieht gut aus.... will aber diese funktion später attachen... also zunächst sollen die mc´s attached werden und dann zu einem späteren zeitpunkt will ich dann auf die "funktion" zugreifen....

wie rufe ich die dann später wieder auf? so?:
ActionScript:
  1. this[neuerPlanet].onEnterFrame=function(_x:300,_y:300,_xscale:100,_yscale:100,speed:5) {



thx & cya, sal
__________________
Bitte keine Flashfragen an mich schicken. Dafür ist ja das Forum da! Das betrifft auch Profilnachrichten.
Chuck Norris hat den Flash Player für alle mobilen Betriebssysteme!
salazar ist offline   Mit Zitat antworten
Alt 01-09-2003, 13:59   #6 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Ort: Aachen
Beiträge: 1.081
Zitat:
... will aber diese funktion später attachen...
Wenn du damit meinst das du diese zu einem späterem Zeitpunkt
ausführen möchtest,

Variable vorschalten,
ActionScript:
  1. for ( var i = 1; i < 4 + 1; i++ ){
  2.         neuerPlanet="planet0"+String(i)
  3.         this.attachMovie("planet", neuerPlanet,  i,{_x:300,_y:300,_xscale:100,_yscale:100,speed:5, alive:false})
  4.        
  5.         this[neuerPlanet].onEnterFrame=function() {
  6.                 if (this.alive) {
  7.                     this._x += (this.destX - this._x) / this.speed
  8.                     this._y += (this.destY - this._y) / this.speed
  9.                     this._xscale += (this.Xscale - this._xscale)/speed
  10.                     this._yscale += (this.Yscale - this._yscale)/speed
  11.                  }
  12.       }
  13. }

Wenn es dann soweit ist, schaltest du "alive" in den mc's auf true.


Du kannst aber auch den mc die Funktion später zuweissen.
Das würde so aussehen :
ActionScript:
  1. planet01.onEnterFrame=function() {
  2.                     this._x += (this.destX - this._x) / this.speed
  3.                     this._y += (this.destY - this._y) / this.speed
  4.                     this._xscale += (this.Xscale - this._xscale)/this.speed
  5.                     this._yscale += (this.Yscale - this._yscale)/this.speed
  6. }

hoffe das hilft weiter....
__________________
G.M. | working @ source lounge
georgexp ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:09   #7 (permalink)
experience++;
 
Benutzerbild von salazar
 
Registriert seit: Jul 2002
Ort: Düsseldorf
Beiträge: 11.347
ich komm der sache auf jedenfall schon näher....
vielen dank soweit für deine mühe.. werde jetzt einfach mal drauflos scripten und schauen wie es klappt

melde mich dann nochmals

thx & cya, sal
__________________
Bitte keine Flashfragen an mich schicken. Dafür ist ja das Forum da! Das betrifft auch Profilnachrichten.
Chuck Norris hat den Flash Player für alle mobilen Betriebssysteme!
salazar ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:11   #8 (permalink)
HAY
Neuer User
 
Benutzerbild von HAY
 
Registriert seit: Aug 2002
Ort: Faust-Stadt
Beiträge: 2.577
hi
ich nochmal ich vermisse die initialiesirung der variablen auf _root.
__________________
gruß Harry
HAY ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:14   #9 (permalink)
experience++;
 
Benutzerbild von salazar
 
Registriert seit: Jul 2002
Ort: Düsseldorf
Beiträge: 11.347
ich auch, aber das kann man ja vorweg machen bzw initialisieren....

also wie bereits gehabt:
ziel ist es z.B. 4 movies zu attachen an feste positionen, welche ich dann aber später noch mit dem vorgestellten as schön "smooth" bewegen will...


thx & cya, sal
__________________
Bitte keine Flashfragen an mich schicken. Dafür ist ja das Forum da! Das betrifft auch Profilnachrichten.
Chuck Norris hat den Flash Player für alle mobilen Betriebssysteme!
salazar ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:15   #10 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Ort: Aachen
Beiträge: 1.081
HAY,

Wozu ? Ich fand sie auf Mc Ebene sinnvoller.
__________________
G.M. | working @ source lounge
georgexp ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:15   #11 (permalink)
HAY
Neuer User
 
Benutzerbild von HAY
 
Registriert seit: Aug 2002
Ort: Faust-Stadt
Beiträge: 2.577
ich glaube so wäre es dann sinnvoll
ActionScript:
  1. MovieClip.prototype.setzen=function(){
  2.         _root[this._name+"X"] =this._x
  3.         _root[this._name+"Y"]= this._y
  4.         _root[this._name+"Xscale"] =this._xscale;
  5.         _root[this._name+"Yscale"] =this._yscale;
  6.                 this.onEnterFrame = function() {
  7.                 this._x += (_root[this._name+"X"]  - this._x)/this.speed;
  8.           this._y += (_root[this._name+"Y"] - this._y)/this.speed;
  9.                 this._xscale += (_root[this._name+"Xscale"]- this._xscale)/this.speed;
  10.                   this._yscale += (_root[this._name+"Yscale"]- this._yscale)/this.speed;
  11. }
  12. }
  13. for ( var i = 1; i < 5; i++ ){
  14.         _root.attachMovie("planet", "planet0"+i, i,{_x:30*i,_y:30*i,_xscale:100,_yscale:100,speed:6})
  15.         _root["planet0"+i].setzen()
  16. }
  17. // das ist nur der Test
  18. _root.planet02X=400

[edit] hatte noch 2_root vergessen
__________________
gruß Harry

Geändert von HAY (01-09-2003 um 14:21 Uhr)
HAY ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:23   #12 (permalink)
experience++;
 
Benutzerbild von salazar
 
Registriert seit: Jul 2002
Ort: Düsseldorf
Beiträge: 11.347
@HAY: das sieht sehr sehr gut aus! bins gerade mal am integrieren

ich melde mich...

thx & cya, sal
__________________
Bitte keine Flashfragen an mich schicken. Dafür ist ja das Forum da! Das betrifft auch Profilnachrichten.
Chuck Norris hat den Flash Player für alle mobilen Betriebssysteme!
salazar ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:28   #13 (permalink)
experience++;
 
Benutzerbild von salazar
 
Registriert seit: Jul 2002
Ort: Düsseldorf
Beiträge: 11.347
müßte es nicht

ActionScript:
  1. this["planet0"+i].setzen()

statt

ActionScript:
  1. _root["planet0"+i].setzen()

lauten?

thx & cya, sal
__________________
Bitte keine Flashfragen an mich schicken. Dafür ist ja das Forum da! Das betrifft auch Profilnachrichten.
Chuck Norris hat den Flash Player für alle mobilen Betriebssysteme!
salazar ist offline   Mit Zitat antworten
Alt 01-09-2003, 14:36   #14 (permalink)
HAY
Neuer User
 
Benutzerbild von HAY
 
Registriert seit: Aug 2002
Ort: Faust-Stadt
Beiträge: 2.577
hi
besser ganz auf _root verzichten (georgexp )
ActionScript:
  1. MovieClip.prototype.setzen=function(){
  2.         this.X=this._x
  3.         this.Y= this._y
  4.         this.Xscale=this._xscale;
  5.         this.Yscale =this._yscale;
  6.                 this.onEnterFrame = function() {
  7.                 this._x += (this.X - this._x)/this.speed;
  8.           this._y += (this.Y- this._y)/this.speed;
  9.                 this._xscale += (this.Xscale- this._xscale)/this.speed;
  10.                   this._yscale += (this.Yscale- this._yscale)/this.speed;
  11.                 }
  12. }
  13. for ( var i = 1; i < 5; i++ ){
  14.         this.attachMovie("planet", "planet0"+i, i,{_x:30*i,_y:30*i,_xscale:100,_yscale:100,speed:6})
  15.         this["planet0"+i].setzen()
  16. }
  17.  
  18. planet02.X=400
  19. planet02.Xscale=10
__________________
gruß Harry
HAY ist offline   Mit Zitat antworten
Alt 01-09-2003, 15:03   #15 (permalink)
HAY
Neuer User
 
Benutzerbild von HAY
 
Registriert seit: Aug 2002
Ort: Faust-Stadt
Beiträge: 2.577
hi salasr
so ist auch nicht schlecht.
ActionScript:
  1. MovieClip.prototype.setzen=function(X,Y,Xscale,Yscale,speed){
  2.                 this.onEnterFrame = function() {
  3.                 this._x += (X - this._x)/speed;
  4.           this._y += (Y- this._y)/speed;
  5.                 this._xscale += (Xscale- this._xscale)/speed;
  6.                   this._yscale += (Yscale- this._yscale)/speed;
  7. }
  8. }
  9. for ( var i = 1; i < 5; i++ ){
  10.         this.attachMovie("planet", "planet0"+i, i,{_x:0,_y:0,_xscale:100,_yscale:100})
  11. }
  12. planet01.setzen(400,400,10,10,6)
  13. planet02.setzen(400,300,30,30,10)
  14. planet03.setzen(300,400,40,40,15)
  15. planet04.setzen(200,200,50,50,20)
__________________
gruß Harry
HAY 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 13:44 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele