
Код AS3:
package
{
import com.adobe.fms.events.PeerStatusEvent;
import flash.events.*;
import flash.ui.Keyboard;
import flash.filters.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.Timer;
public class Main extends Sprite
{
public var BG_clouds:clouds;
public var BG_sun:bg_sun;
public var BG_sky:bg_sky;
public var BG:bg;
public var BG_back:bg_back;
public var BG_back2:bg_back;
public var BG2:bg;
public var player_RUNNER:player_runner;
public var player_KNIGHT_speed:Number = 0;
public var player_KNIGHT:player_knight;
public var RunRunGame:P2PGame;
public var player_runner_timer:Timer = new Timer(1000);
public const SERVER:String = "rtmfp://p2p.rtmfp.net/";
public const DEVKEY:String = "YOUR_CIRRUS_DEVKEY";
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, AppInit);
}
public function AppInit(e:Event)
{
var sun_glow_color:uint = uint("0xECEE8E");
var sun_glow:GlowFilter = new GlowFilter(sun_glow_color,1.0,20,20,1);
var player_runner_mBlur:BlurFilter = new BlurFilter(4,0,1);
BG_sky = new bg_sky();
addChild(BG_sky);
BG_sky.x = 275;
BG_sky.y = 200;
BG_sun = new bg_sun();
addChild(BG_sun);
BG_sun.x = 500;
BG_sun.y = 50;
BG_sun.filters = [sun_glow];
BG_back = new bg_back();
addChild(BG_back);
BG_back.x = 0;
BG_back.y = 275;
BG_back2 = new bg_back();
addChild(BG_back2);
BG_back2.x = 0;
BG_back2.y = 275;
BG = new bg();
BG.x = 8;
BG.y = 210;
addChild(BG);
BG2 = new bg();
addChild(BG2);
BG2.x = 550;
BG2.y = 210;
BG_clouds = new clouds();
addChild(BG_clouds);
BG_clouds.scaleX = 0.8;
BG_clouds.scaleY = 0.8;
BG_clouds.x = 700;
BG_clouds.y = 100;
player_RUNNER = new player_runner();
player_KNIGHT = new player_knight();
addChild(player_RUNNER);
player_RUNNER.x = 500;
player_RUNNER.y = 355;
player_RUNNER.scaleX = 2;
player_RUNNER.scaleY = 2;
player_RUNNER.filters = [sun_glow]
;
addChild(player_KNIGHT);
player_KNIGHT.x = 225;
player_KNIGHT.y = 360;
setChildIndex(app_mask,numChildren-1 );
stage.addEventListener(KeyboardEvent.KEY_DOWN, player_KNIGHT_controls);
stage.addEventListener(KeyboardEvent.KEY_DOWN, player_RUNNER_controls);
stage.addEventListener(Event.ENTER_FRAME, player_KNIGHT_update);
stage.addEventListener(Event.ENTER_FRAME, bg1_move);
stage.addEventListener(Event.ENTER_FRAME, bg2_move);
stage.addEventListener(Event.ENTER_FRAME, bg_back_move);
stage.addEventListener(Event.ENTER_FRAME, bg_back_move2);
stage.addEventListener(Event.ENTER_FRAME,clouds_update);
player_runner_timer.addEventListener(TimerEvent.TIMER_COMPLETE,pl_runner_timerCompl);
player_runner_timer.start();
trace("RunRunGame was initialized");
}
public function pl_runner_timerCompl(event:TimerEvent)
{
trace("1");
var player_RUNNERParticle = new player_runner();
player_RUNNERParticle.x = 500;
player_RUNNERParticle.y = 355;
player_RUNNERParticle.scaleX = 2;
player_RUNNERParticle.scaleY = 2;
addChild(player_RUNNERParticle);
player_RUNNERParticle.x -= 2;
}
public function bg1_move(e:Event)
{
BG.x -= 10;
if (BG2.x == 0)
{
BG.x = 550;
}
}
public function bg2_move(e:Event)
{
BG2.x -= 10;
if (BG.x == 0)
{
BG2.x = 550;
}
}
public function clouds_update(e:Event)
{
BG_clouds.x -= 0.5;
if (BG_clouds.x == -250)
{
removeChild(BG_clouds);
var low:Number = 0.5;
var high:Number = 1;
var clouds_scale:Number = Math.floor(Math.random() * (1+high-low)) + low;
BG_clouds = new clouds();
addChild(BG_clouds);
BG_clouds.x = 600;
BG_clouds.y = Math.floor(Math.random() * 100);
BG_clouds.scaleX = clouds_scale;
BG_clouds.scaleY = clouds_scale;
}
}
public function bg_back_move(e:Event)
{
BG_back.x -= 1;
if (BG_back2.x == 0)
{
BG_back.x = 550;
}
}
public function bg_back_move2(e:Event)
{
BG_back2.x -= 1;
if (BG_back.x == 0)
{
BG_back2.x = 550;
}
}
public function player_RUNNER_controls(e:KeyboardEvent)
{
if (e.keyCode == 37)
{
player_KNIGHT_speed -= 1;
}
}
public function player_KNIGHT_controls(e:KeyboardEvent)
{
if (e.keyCode == 32)
{
player_KNIGHT_speed += 1;
}
}
public function player_KNIGHT_update(e:Event)
{
player_KNIGHT_speed -= 0;
player_KNIGHT.x += player_KNIGHT_speed;
}
}
}
Странно, но при всей правильности кода.. Таймер отказывается трейсить и работать(ошибок не выдает ни при компиляции, ни при рантайме)... в чем причина?
Добавлено через 1 минуту
З.Ы. таймер "player_runner_timer"