Archives for the 'ActionScript 3' category

Flash Player loses focus with button + removeChild

Well, this week, I was doing a little game that to the player start to play needs click in one “start game” button and after uses the keyboard to control the character moves. So until this point all OK, but what i didn’t told you is that when click’s in the “start game”, it disappears with one removeChild() (because it appears above all the stage).

After this, my character was no more moving… I fought “wow could be my InputManager class not working so fine…”, but I tried find some bug or something wrong and nothing. After some tries, accidentally I removed the buttonMode = true - propertie that i was defining to that my “start game” Movie Clip behaviors like Button - and tcharam… All working…..

At first we need remind that Keyboard events will just works when Flash Player get focus. And accidentally I found a way of Flash Player loses focus with on removeChild().

So what is happening here?!

First, open the swf file (focus it); after, click at the button (button with focus); later on, the button is removed from the stage (the focus is removed together with the button - so here are the problem). Now if I click on the stage, or other local in the swf file (Flash Player will get focus again) and it will works…
Here is a source code as example :

var spBtn = new Sprite(); spBtn.buttonMode = true; spBtn.graphics.beginFill( 0xff0000, .4 ); spBtn.graphics.drawRect( 0, 0, this.stage.stageWidth, this.stage.stageHeight ); spBtn.graphics.endFill(); addChild( spBtn ); addEventListener ( KeyboardEvent.KEY_DOWN, managekeyDown ); spBtn.addEventListener( MouseEvent.MOUSE_DOWN, mouseClick ); function mouseClick ( e : Event ) : void {         spBtn.removeEventListener( MouseEvent.MOUSE_DOWN, mouseClick );         removeChild( spBtn ); } function managekeyDown ( e : KeyboardEvent ) : void {         if ( e.keyCode == Keyboard.LEFT )         {                 trace ( “JUST TRACE IF FLASH PLAYER HAVE FOCUS ON IT” );         } }

======= Updated at August 1º (expect update more the blog…) ======

To fix this issue you must reset the focus to the stage. So the code will change just in this part:

function mouseClick ( e : Event ) : void {         spBtn.removeEventListener( MouseEvent.MOUSE_DOWN, mouseClick );         removeChild( spBtn );         //After the remove child we’ll reset the focus to stage         this.stage.focus = this; }

:D

5 comments

Papervision3D 2.0 Alpha

 

Foi lançada hoje de madrugada a tão esperada versão 2.o da Biblioteca Papervision 3D.

 

Na nova versão possuímos recursos tais como: ShadeMaterials, Shaders, ASCollada (agora com suporte a animação), Frustrum Culling, Multiple Viewports, Render to Scene e muito mais…

 

Para quem quiser ter uma idéia do que podemos fazer no a nova versão dê uma olhada no link abaixo que exemplifica aplicação de iluminação de phong e bumpMapping.

swf:
http://www.rockonflash.com/papervision3d/downloads/shaderDemos/EarthPhongDemo.swf

FLA:
http://www.rockonflash.com/papervision3d/downloads/shaderDemos/EarthPhongDemo.fla

 

Então aproveite agora mesmo para fazer o download da nova versão a partir do SVN no endereço: http://papervision3d.googlecode.com/svn/trunk/

 

Abraços.

 

2 comments

Material (artigo e exemplos) do minicurso de ActionScript 3.0 para Games

Olá pessoal,

fiquei meio parado nas duas últimas semanas por causa do SBGames 2007 e de uns projetos pessoais.

O SbGames 2007 foi simplesmente ótimo e o pré-evento GDS superou as expectativas.

O AUGRS apresentou duas palestras, uma de AS2 e Advergames com Pedro Taranto e Alberto Amaral e a minha de AS3 para Games.

O meu minicurso teve como título “Conhecendo o ActionScript 3.0 para o desenvolvimento de jogos utilizando o Adobe Flash CS3″ e foram abordadas questões desde o básico do AS3 referindo-se a DisplayList e ao Sistema de Eventos até a parte de Simulações de Física com a APE e 3D com Papervision 3D.

O artigo pode ser adquirido nesse link http://www.filipesilvestrim.com/gds_2007/minicursoAS3Games.pdf e os exemplos (classes e .fla) podem ser feitos o download aqui http://www.filipesilvestrim.com/gds_2007/Fonte.zip .

Atenção: Ao fazer o download dos códigos fonte, favor ler o arquivo leia-me.html para que os exemplos rodem corretamente.

2 comments

Palestra - ActionScript 3.0 para o desenvolvimento de jogos

 

Estarei palestrando um mini curso de ActionScript 3.0 para o desenvolvimento de jogos no pré-evento do SBGames 2007 (Simpósio Brasileiro de Games).

Para assistir a palestra basta se inscrever no SBGames e marcar a opção de que irá assistir ao pré-evento GDS (Game Development School).

 

Detalhes da palestra:

Dia 6 de Novembro
14:00 - 17:00

Conhecendo o ActionScript 3.0 para o desenvolvimento de jogos utilizando o Adobe Flash CS3.

Filipe Ghesla Silvestrim

AUGRS - Adobe User Group do Rio Grande do Sul http://www.augrs.com

Resumo: Introduzir a linguagem de programação ActionScript 3.0 no desenvolvimento de jogos utilizando o software Adobe Flash Professional CS3 como plataforma de desenvolvimento.

Público-Alvo: Intermediário

Pré-Requisitos: Conhecimento de lógica de programação para jogos.

Mais informações sobre o SBGames no site http://www.inf.unisinos.br/~sbgames

Mais informações sobre o pré-evento no endereço http://www.inf.unisinos.br/~sbgames/GDS-port.html

7 comments

TransitionManager Events - ActionScript 3

Bom, hoje um post bem rápido pois a correria anda grande e não queria deixar o blog na inatividade…

Hoje precisei utilizar um evento da classe TransitionManager no AS3 e encontrei o mesmo problema que havia tido no passado como o AS2, temos dois eventos não documentados para a classe TransitionManager. Os eventos são para quando a transição IN acaba e quando a transição OUT acaba.

OK, mas se não está documentado como saber disso? Bom, a questão é futricar, vá até a pasta das classes do ActionScript 3 e procurem as subpastas fl e dentro dela a transitions(ex.: C:\Arquivos de programas\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes\fl\transitions). Aí dentro iremos achar o arquivo da classe (TransitionManager.as) e daí é só abrir ele e futricar ;)

Exemplo de aplicação:

import fl.transitions.*;
import fl.transitions.easing.*;

 

var tmTransicao:TransitionManager = new TransitionManager(myMovieClip);

 

tmTransicao.startTransition({type:Zoom, direction:Transition.IN, duration:1, easing:Bounce.easeOut});
tmTransicao.addEventListener(”allTransitionsInDone”, inDoneHandler);
tmTransicao.addEventListener(”allTransitionsOutDone”, outDoneHandler);

 

function inDoneHandler(event:Event):void
{
     trace(”Acabou a transição de ENTRADA”);
     //começou a transição de saída
     tmTransicao.startTransition({type:Zoom, direction:Transition.OUT, duration:1, easing:Bounce.easeOut});
}

 

function outDoneHandler(event:Event):void
{
     trace(”Acabou a transição de SAÍDA”);
}

No one comment

Newer «