質問

_root.backMusicOn.onPress = function () {
    _root.backgroundMsc = true;
    trace(_root.backgroundMsc)
}

Hello guys, I have a boolean and this is set to false when initiated and declared.

When you press this button, I want it to be true and play the music, but it doesn't become true and my music doesn't play.

I've used traced command trace (_root.backgroundMsc), when I click on the button it says true.

But when the game starts, it says not true.

Can you please help me, I think flash is confused.

static private function level1Loop():Void 
{
    if (_root._currentframe == 19)
    {

        shoutPicha();
        checkBackGroundMusic();

        switchCharacter();
        gravityEngine(); //and jump lol // and controls rofl
        shootCollision();
        vCam();
        collisionWithGround();
        getHudtoFollowPlayer();
        ifPlayersFallTelethem();
        changeItems();
        collisionWithShapes();
        timer();
        attachItems();
        backButtonLevel1();
        gameWinCondition();
        ifonGamescreen();
        portal();
        candyCollision();
        makePointSfollow();
    }
}
static private function checkBackGroundMusic():Void 
{
    if (backgroundMsc)
    {
        trace("hey")
        soundTrack.start();
        trace(backgroundMsc);
        //if this is true, play sound 

    }
    else
    {
        //dont play sound
        trace("nej");
    }
}

this is where i declare

static var game:Platform;

static public var backgroundMsc:Boolean = true;
static public var SoundFx:Boolean;
static public var myData:LoadVars;
static public var canJumpFrickingHight:Boolean = false;
static private var totalBytes;
役に立ちましたか?

解決

I'm an idiot.

It doesn't know what I'm targetting, because I'm not using "_root."

    if (backgroundMsc) //should be _root.backgroundMsc
    {
        trace("hey")
        soundTrack.start();
        trace(backgroundMsc);
        //if this is true, play sound 

    }

Cheers for the help guys, i just switched from As3 to As2 and I need to code in the main timeline >.M;

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top