A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: change AS1 to AS2

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    20

    change AS1 to AS2

    Actionscript Code:
    timerID = setInterval(functionName, 1000);

    function functionName()
    {
        i = i + 1;
        duplicateMovieClip(_root.circle, "circle" + i, i);
    }

    can anyone help me change this to AS2?

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I guess Im not sure what you mean? are you sure want AS2? not AS3?

    AS2 is very similar.. I think gave us a few more functions/classes..etc..

    but more so just datatyping..

    example:

    var timeDelay:Number = 1000;
    var timerID = setInterval(functionName, timeDelay);

    function functionName() {
    var i:Number = i + 1;
    duplicateMovieClip(_root.circle, "circle" + i, i);
    }

  3. #3
    Junior Member
    Join Date
    Jun 2007
    Posts
    20
    Quote Originally Posted by whispers View Post
    I guess Im not sure what you mean? are you sure want AS2? not AS3?

    AS2 is very similar.. I think gave us a few more functions/classes..etc..

    but more so just datatyping..

    example:

    var timeDelay:Number = 1000;
    var timerID = setInterval(functionName, timeDelay);

    function functionName() {
    var i:Number = i + 1;
    duplicateMovieClip(_root.circle, "circle" + i, i);
    }
    Hi,

    yah, i want to change it to AS2.

    the script you give me is work, but can it be duplicate the circle to 10 circle?

    and how can i interact with those duplicated circle? is it like:
    circle1.onRelease function(){
    this.gotoAndPlay(2)
    }


    here is the working file i attached.
    Attached Files Attached Files

  4. #4
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I only have CS3

    so I couldnt open your file..

    but you want to do something like this? (every couple seconds add a new circle to the stage.. but stop after 10 circles are added to the stage?

    these circle all need to be interactive as well? click on them they need to do something?


    try this:

    make a movieClip...in your LIBRARY.. needs to have the LINKAGE NAME OF circle_mc


    then just use this code:
    Actionscript Code:
    var totalCircles:Number = 10;
    var circleCounter:Number = 0;
    var timeDelay:Number = 100;

    var timerID = setInterval(createCircles, timeDelay);

    function createCircles() {
        trace("fired");
        var newCircle = _root.attachMovie("circle_mc", "circle_"+circleCounter, _root.getNextHighestDepth());
        trace("NEW: "+newCircle);  
        //place randomly on stage
        newCircle._x = random(Stage.width);
        newCircle._y = random(Stage.height);   
        //add interactive code
        newCircle.onPress = function(){
            this.startDrag();
            trace("Name: "+this);
        }
        newCircle.onRelease = function(){
            stopDrag();
        }
        //update counter var
        circleCounter++;
        trace("Counter: "+circleCounter);
        //check to see if last circle added
        if(circleCounter == totalCircles){
            clearInterval(timerID);
        }
    }

  5. #5
    Junior Member
    Join Date
    Jun 2007
    Posts
    20
    Thanks Whispers!
    This work for me.
    sorry for the flash version because my office is using CS5.

    I think i still have something to ask but i will figure it out myself 1st.

    Thanks again!

  6. #6
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    if you wanted to change each circle clip to its own internal frame #2 when clicked/pressed.

    you would just add this:

    newCircle.onPress = function(){
    this.gotoAndStop(2);
    }

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