A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How do I multiplicate my objects?

  1. #1
    Junior Member
    Join Date
    Jan 2016
    Posts
    1

    How do I multiplicate my objects?

    Hello

    First: I'm german and my english is pretty bad, but I can't find any german forum, so this is the only way for me to look for help.
    Second: I don't know very much about flash or actionscript 2.0 and I know that here are some people who think 'If you don't know this then just stop trying!', but I try to do this for a homepage where no one knows something about actionscript. Well, this project is far completed, but I'm missing something. I want to have the colored objects more than one time, but not just copy the layer or something, because this crashes my program if there are just 20 of each object (and I need 50 of each)

    My project looks like this: http://sta.sh/01y21r4oghny

    Is there any code to do this? At the moment it is like this:

    on (press) {
    startDrag("")
    dragging = true}

    on (release, releaseOutside) {
    stopDrag()
    dragging = false}
    on (press) {
    startDrag("")
    dragging = true
    }
    on (release, releaseOutside) {
    stopDrag()
    dragging = false
    if(this._x > 36 && this._x < 52 && this._y > 32 && this._y < 47)
    {
    this._x = 36
    this._y = 32
    }
    dragging = false}


    (the red part is 1462 times for each of the objects, to let them stick at the boxes, maybe there is a better code for this which isn't that long, maybe this is the problem for my program to crash...)

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Not totally sure what you mean, but if you mean shorten the code down to small er amounts then maybe this might help you.

    If you have say 30 buttons/movieclips on stage, each called purple1, purple2,purple3,purple4 and so on, then you can try to use this.

    No need to put the code on the button itself, makes too much work and hard to get at the code.
    put the code on the main timeline.

    PHP Code:
    var purpleBoxes:Number 30;

    for (var 
    i:Number 1<= purpleBoxesi++)
    {
        var 
    purpleBox:MovieClip this["purple" i];

        
    purpleBox.onPress = function()
        {
            
    startDrag(this);
            
    this.dragging true;
        };

        
    purpleBox.onRelease purpleBox.onReleaseOutside = function()
        {
            
    stopDrag();
            var 
    mX:Number this._x;
            var 
    mY:Number this._y;
            if (
    mX 36 && mX 52 && mY 32 && mY 47)
            {
                
    this._x 36;
                
    this._y 32;
                
    trace("yes");
            }
            
    this.dragging false;
            
    //trace(mX + " - " + mY);
        
    };

    Last edited by fruitbeard; 01-18-2016 at 09:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center