Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Flash Problems

  • 07-04-2010 05:10AM
    #1
    Closed Accounts Posts: 2


    Hi folks, have 2 probs, prob stupid but if anybody can help i would be grateful:)

    First prob is the top edge of my stage(600, 420), i want to limit my sprites to the stage and create a barrier to stop them moving off it. the following works for left right and bottom but not for the top
    ---
    if (playerRobot._x>Stage.width) {
    playerRobot._x = (Stage.width-1);
    }
    if (playerRobot._x<0) {
    playerRobot._x = 1;
    }
    if (playerRobot._y>Stage.height) {
    playerRobot._y = (Stage.height-1);
    }
    //problem
    if (playerRobot._y<0) {
    playerRobot._y = (Stage.height-40);
    }

    ---
    Any ideas?



    Secondly, i am creating multple instances of a cpuMissile and want to paas its attributes to the turn() function which moves the missile.The problem only occurs when i try to use multiple instances????


    function cpuMissileLaunch()
    {
    sndMissileLaunch.start();
    i++;
    _root.attachMovie("cpuMissile", "cpuMissile" + i, _root.getNextHighestDepth());
    _root["cpuMissile" + i]._x = cpuRobot._x;
    _root["cpuMissile" + i]._y = cpuRobot._y;
    //cpuMissile._X = cpuGun._x;
    //cpuMissile._Y = cpuGun._y;
    _root["cpuMissile" + i].dir = cpuGun.dir;
    _root["cpuMissile" + i].speed = (((cpuRobot.weapon*5)));
    turn(_root["cpuMissile" + i]);
    }

    .speed and .dir are already declared in an init function
    thoughts?


Comments

  • Closed Accounts Posts: 7,144 ✭✭✭DonkeyStyle \o/


    //problem
    if (playerRobot._y<0) {
    playerRobot._y = (Stage.height-40);
    }

    ---
    Any ideas?
    zero is the top of the Y axis, stage.height-40 would be 40 pixels from the bottom... you could just set this to zero or some other fixed offset depending on the size of the sprite and where the anchor point is.
    if (playerRobot._y<10) { playerRobot._y = 10; }

    Haven't really been able to digest the rest... though you might have better luck using 'this.' instead of '_root["cpuMissile" + i]' as it'll refer to that instance (I presume these are member functions) and with each new instance 'i' might be resetting to default, so it's just passing the same missile over and over?
    Add in some trace() statements, see what the turn function is receiving.
    Sorry my AS3 is still a bit basic.


Advertisement