Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

gestione Eventi

This is a discussion on gestione Eventi within the Actionscript 3.0 base forums, part of the Flash CS3 generale category; Buona giornata, vorrei esordire dicendo che questa nuova versione di flash incomincia ad appassionarmi sempre di piu, ma come in ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 e Actionscript 3.0 > Flash CS3 generale > Actionscript 3.0 base

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-05-08, 20:34
etr102108's Avatar
Junior Member
 
Join Date: Aug 2007
Posts: 12
Rep Power: 0
etr102108 is on a distinguished road
Unhappy gestione Eventi

Buona giornata, vorrei esordire dicendo che questa nuova versione di flash incomincia ad appassionarmi sempre di piu, ma come in tutte le cose quando i programmi diventano complessi aumentano anche i problemi ,come nel mio caso, che si e' verificato utilizzando l'aggiunta di un listener mediante il metodo statico ENTER_FRAME.
Il problema che mi accingo a specificare è riferito alla necessita di rimuovere il listener mediante l'apposito metodo che aime non riesco ad utilizzare correttamente .
Presumo che il metodo corretto sia il removeListener ma non so quale siano i parametri che devo inserire.
Questo codice presumo che nella parte finale non sia corretamente impostato in quanto il muovimento della pallina ,dopo aver rilevato la collisione risulta essere il doppio rispetto al muovimento contrario iniziale, proprio perche non sono riuscito a rimuovere correttamente il listener,il problema inoltre si verifica anche dove compaiono gli asterischi.

package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.events.Event;
import flash.utils.setInterval;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;


public class Main extends MovieClip {
public var Curs1:Cursore = new Cursore();
public var Curs2:Cursore = new Cursore();
public var Pall:Palla = new Palla();
public var Disp:Visualizzatore = new Visualizzatore();
public var step:uint = 5;
//public var Text1:TextField;
private var frmt:TextFormat;


public function Main():void {
this.frmt = new TextFormat();
this.frmt = new TextFormat("Verdana",10,0x000000);
this.frmt.align = TextFormatAlign.CENTER;
InizioPartita();

}
public function punteggio():void {

}

public function InizioPartita():void {
Curs1.x = 280;
Curs1.y = 50;
Curs2.x = 280;
Curs2.y = 620;
Pall.x = 280;
Pall.y = 590;
Disp.x = 490;
Disp.y = 660;
Disp.testo_txt.defaultTextFormat = this.frmt;
Disp.testo_txt.text = "punteggio";
Disp
addChild(Curs1);
addChild(Curs2);
addChild(Pall);
addChild(Disp);
stage.addEventListener(KeyboardEvent.KEY_DOWN,move Curs);
stage.addEventListener(KeyboardEvent.KEY_UP,startB all);

}
private function moveCurs(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.LEFT )
this.Curs1.x -= step;
if(evt.keyCode == Keyboard.RIGHT)
this.Curs1.x += step ;
if(evt.keyCode == Keyboard.CONTROL)
this.Curs2.x -= step;
if(evt.keyCode == Keyboard.SHIFT)
this.Curs2.x += step;
}
private function startBall(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.SPACE)
stage.addEventListener(Event.ENTER_FRAME,moveBallU P);

}
private function moveBallUP(evt:Event):void
{
this.Pall.y -= 5;
if(this.Curs1.hitTestPoint(this.Pall.x,this.Pall.y ,true))
stage.addEventListener(Event.ENTER_FRAME,moveBallD OWN);

}
private function moveBallDOWN(evt:Event):void
{
this.Pall.y += 10;
if(this.Curs2.hitTestPoint(this.Pall.x,this.Pall.y ,true))
************************************************** *******************
trace("OK");
}

}
}
la collisione è stata correttamente rilevata perche viene effettuata la trace ma all'interno della condizione dovrei riprendere il metodo che ripristina il muovimento iniziale della pallina e cioè dal basso verso l'alto.


GRAZIE DELL'AIUTO

CORDIALI SALUTI
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 10-05-08, 19:56
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,446
Rep Power: 6
Flep is on a distinguished road
Re: gestione Eventi

Ciao

Se attivi un listener così:
Code:
stage.addEventListener(Event.ENTER_FRAME,moveBallD OWN);
per rimuoverlo:
Code:
stage.removeEventListener(Event.ENTER_FRAME,moveBallD OWN);
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 11-05-08, 11:59
etr102108's Avatar
Junior Member
 
Join Date: Aug 2007
Posts: 12
Rep Power: 0
etr102108 is on a distinguished road
Re: gestione Eventi

grazie della tua cortese attenzione, ora funziona tutto !!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Actionscript 2 Gestione Database AS2 andrea_u_beddu Flash CS3 generale 2 05-11-08 08:07
Actionscript 3 Gestione EVENTI Alarik Actionscript 3.0 avanzato 2 05-11-08 02:00
Gestione degli eventi in una presentazione "Screen" Federico Fontani Flash CS3 generale 10 24-03-08 07:39
Gestione News PHP - XML zizzolo Flash CS3 | PHP | mySQL 22 30-11-07 01:23
scroller eventi: ridimensionare eventi pettedemon AIUTO utilità free 12 22-11-07 11:24


All times are GMT. The time now is 11:30.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406