вот даже к примеру у меня есть ф-ция которая прописана в кадре

Код AS1/AS2:
function initGame() {
// init balloon variables
nextBulletTime = 0;
// init bullet variables
nextBullet = 0;
bullets = [];
// init score
score = 0;
}
function shootBullet() {
// see whether there has been enough time to reload
if (getTimer() > nextBulletTime) {
trace(nextBulletTime);
// create bullet clip
attachMovie("bullet","bullet"+nextBullet,nextBullet+9999);
// set location
_root["bullet"+nextBullet]._x = _root.cat._x+13;
_root["bullet"+nextBullet]._y = _root.cat._y+25;
// add to array
bullets.push(nextBullet);
//get set for next bullet
nextBullet++;
nextBulletTime = getTimer()+1000;
mySound2 = new Sound();
mySound2.attachSound("booll");
mySound2.start();
}
}
function moveBullets() {
// loop through all bullets
for(i=bullets.length-1;i>=0;i--) {
// get clip
bullet = _root["bullet"+bullets[i]];
bullet._x += 10;
// see whether it reached top
if (bullet._x > 750) {
bullet.removeMovieClip();
bullets.splice(i,1);
// see whether it hit a balloon
}
if (bullet.hitTest(_root.lilo) )
{ _root.lilo.unloadMovie();
bullet.removeMovieClip();
bullets.splice(i,1);
}
}
есть код прописанные в кнопке которая находится в рабочей области

Код AS1/AS2:
on (keyPress "<Space>") {
_root.shootBullet();
}
и есть код в клипе

Код AS1/AS2:
onClipEvent(load) {
_root.initGame();
}
onClipEvent(enterFrame) {
_root.moveBullets();
}
эти ф-ции приводят к тому что персонаж может стрелять по нажатию пробела, мне нужно перевести все это к примеру в 1 класс, как это сделать правильно? у меня не получается может я что то упускаю, может в конструкторе не инициализирую?
Добавлено через 7 минут
вот так я перевел эти ф-ции в класс

Код AS1/AS2:
class Bullets extends MovieClip {
var nextBulletTime = 0;
var nextBullet = 0;
var bullets = [];
function initGame() {
// init balloon variables
// init bullet variables
var nextBulletTime = 0;
var nextBullet = 0;
var bullets = [];
// init score
var score = 0;
}
function shootBullet() {
// init score
var score = 0;
// see whether there has been enough time to reload
if (getTimer() > nextBulletTime) {
// create bullet clip
attachMovie("bullet","bullet"+nextBullet,nextBullet+9999);
// set location
_root["bullet"+nextBullet]._x = _root.cat._x+13;
_root["bullet"+nextBullet]._y = _root.cat._y+25;
// add to array
bullets.push(nextBullet);
//get set for next bullet
nextBullet++;
nextBulletTime = getTimer()+1000;
var mySound2 = new Sound();
mySound2.attachSound("booll");
mySound2.start();
}
}
function moveBullets() {
// loop through all bullets
for(var i=bullets.length-1;i>=0;i--) {
// get clip
var bullet = _root["bullet"+bullets[i]];
bullet._x += 10;
// see whether it reached top
if (bullet._x > 750) {
bullet.removeMovieClip();
bullets.splice(i,1);
// see whether it hit a balloon
}
if (bullet.hitTest(_root.lilo) )
{ _root.lilo.unloadMovie();
bullet.removeMovieClip();
bullets.splice(i,1);
}
}
}
}
это в кнопке

Код AS1/AS2:
on (keyPress "<Space>") {
var Shoot:Bullets = new Bullets;
Shoot.shootBullet();
}
а это в кадре

Код AS1/AS2:
function lod() {
var Bul:Bullets = new Bullets();
Bul.initGame();
}
function game() {
Bul.moveBullets();
}
а это уже в клипе естественно

Код AS1/AS2:
onClipEvent (load)
{
_root.lod();
}
onClipEvent (enterFrame) {
_root.game();
}
ошибок не выдает но с помощью trace проверял различные значения, и они принимают не те значения которые принимали в кадре когда были прописаны, что не так?