Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

what code do you need to allow people to drop and drag with mouse in Flash

Options
  • 05-04-2008 12:02pm
    #1
    Closed Accounts Posts: 401 ✭✭


    what code do you need to allow people to drop and drag with mouse in Flash? ie to pick objects up with their mouse and to drag them over the screen.


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh




  • Registered Users Posts: 14,761 ✭✭✭✭Winters


    Wow! That google thing is amazing! Is that new? I am going to use it loads now :D


  • Closed Accounts Posts: 401 ✭✭culabula88


    Thanks Lads - never heard of that google thing.... fairly handy aint it!!

    Seriously though i have a flash project and my flash skills aint that good, could anybody give me a little bit of help or would like to designe a bit of flash for me??

    Just want to know, is it possible to put in comments in the keyframes bar as you go along or to have a hidden layer for comments in order to keep track of what you are doing.

    Also , how do you write comments in the actions script.


  • Closed Accounts Posts: 401 ✭✭culabula88


    heres the code i copied off the web for dragging a set of blocks into their compartments.

    Is "this.startDrag(true)" a generic function used to enable the mouse to pick up objects and does this function need a header file??
    could ye explain a few other lines of the code and new functions.


    var counter:Number = 0;
    var woodSound:Sound = new Sound();
    woodSound.attachSound("woodblock");

    onEnterFrame = function():Void{
    if(counter == 4){
    reply_txt.text = "Congrats, you're finished!";
    }
    };


    square_mc.onPress = function():Void {
    this.startDrag(true);
    reply_txt.text = "";
    this.swapDepths(this.getNextHighestDepth());
    xstart = this._x;
    ystart = this._y;
    };
    square_mc.onRelease = function():Void {
    this.stopDrag();
    if (eval(this._droptarget) == squareTarget_mc) {
    reply_txt.text="You got it!";
    this.enabled = false;
    counter++;
    woodSound.start(0,1);
    }
    else{
    reply_txt.text="No, keep trying!";
    this._x = xstart;
    this._y = ystart;
    }
    };


    flower_mc.onPress = function():Void {
    this.startDrag(true);
    reply_txt.text = "";
    this.swapDepths(this.getNextHighestDepth());
    xstart = this._x;
    ystart = this._y;
    };
    flower_mc.onRelease = function():Void {
    this.stopDrag();
    if (eval(this._droptarget) == flowerTarget_mc) {
    reply_txt.text="Yes, that’s right!";
    this.enabled = false;
    counter++;
    woodSound.start(0,1);
    }
    else{
    reply_txt.text="Try again!";
    this._x = xstart;
    this._y = ystart;
    }
    };


    triangle_mc.onPress = function():Void {
    this.startDrag(true);
    reply_txt.text = "";
    this.swapDepths(this.getNextHighestDepth());
    xstart = this._x;
    ystart = this._y;
    };
    triangle_mc.onRelease = function():Void {
    this.stopDrag();
    if (eval(this._droptarget) == triangleTarget_mc) {
    reply_txt.text="Way to go!";
    this.enabled = false;
    counter++;
    woodSound.start(0,1);
    }
    else{
    reply_txt.text="Sorry, try again!";
    this._x = xstart;
    this._y = ystart;
    }
    };


    pentagon_mc.onPress = function():Void {
    this.startDrag(true);
    reply_txt.text = "";
    this.swapDepths(this.getNextHighestDepth());
    xstart = this._x;
    ystart = this._y;
    };
    pentagon_mc.onRelease = function():Void {
    this.stopDrag();
    if (eval(this._droptarget) == pentagonTarget_mc) {
    reply_txt.text="Wow, great job!";
    this.enabled = false;
    counter++;
    woodSound.start(0,1);
    }
    else{
    reply_txt.text="Don't give up yet!";
    this._x = xstart;
    this._y = ystart;
    }
    };


  • Closed Accounts Posts: 975 ✭✭✭squibs


    Seriously though i have a flash project and my flash skills aint that good, could anybody give me a little bit of help or would like to designe a bit of flash for me??

    You will have to learn some coding. You'll have to adapt sample code to your own needs, and you'll need to understand the code to adapt it. I recommend you buy a book on actionscript.


  • Advertisement
  • Closed Accounts Posts: 401 ✭✭culabula88


    i got a book on actionscript and i am reading it now. I tried all of the above from the website tutorial and i can pick up the object but it wont put it down when i release the object. see my other threads.

    It must be something fairly straightforward which i am missing..


  • Registered Users Posts: 35,524 ✭✭✭✭Gordon




Advertisement