Migrating AS2 Code to AS3

ORIGINAL AS1 SCRIPT
I have already tried several ways to migrate this code, but I
get unexpected behaviors. Can any one help me?
The volume control on the stage is made out of two
movieClips: one called knob and the other volume_track over which
the knob slides (is dragged by user) This two Clips are turned into
one movieClip called volume_control. The Sound Object is within an
Empty MovieClip called soundMc. the pos variable gathers the knob's
position on the volume_track.
The following code is the original one, which works
perfectly.

Hi, Kglad,
I had made a mistake, that's why the code didn't work at all.
My bad.
I modified a little the code you suggested as well as the
Clips Instance Names.
I used the Rectangle Class to get the
startDrag(lockCenter:Boolean = false, bounds:Rectangle = null)
method's bound argument. This is how the Rectangle is set up:
Rectangle(x:Number, y:Number, width:Number, height:Number);
It works now, but there's a couple of unexpected things
happening.
1. It really hard to make the knob move left and right
because the cursor seems not to get a firm hold of it.
2. Once it starts dragging, I have to move it very slowly
otherwise I lose a hold on the knob.
3 - In order to get the knob to drag within the bounderies of
its track, I had to add extra numbers in the x (8 instead of 0),
width (a -12), and height (0 instead of e.currentTarget.y), but
this poses a problem later when I try to get a definite value to
control the volume intensity between 0.0 (Minimum volume) and 1.0
(Max Vol). Tracing pos, I got these results:
Min pos: 0.10810810810810811
Max pos: 0.9459459459459459
Is there a way to clean up those results, like a Math
function, so that I can get something like this 0.1 and 0.9 instead
of those long numbers?
volume_control.volKnob.addEventListener(MouseEvent.MOUSE_DOWN,
dragKnob);
volume_control.volKnob.addEventListener(MouseEvent.MOUSE_UP,
stopKnob);
volume_control.volKnob.addEventListener(MouseEvent.MOUSE_OUT,
stopKnob);
var t:Timer=new Timer(70,0);
t.addEventListener(TimerEvent.TIMER,volF);
function dragKnob(e:MouseEvent) {
trace("Begin dragging");
var rect:Rectangle = new Rectangle(8, e.currentTarget.y,
e.currentTarget.parent.volTrack.width-12, 0);
e.currentTarget.startDrag(false, rect);
t.start();
function stopKnob(e:MouseEvent) {
trace("Stop draggin");
e.currentTarget.stopDrag();
t.stop();
function volF(e:TimerEvent) {
var pos:Number =
(volume_control.volKnob.x/volume_control.volTrack.width);
//soundObjChannel.soundTransform.volume =pos; // you need to
define your soundChannel object whereever you're applying the play
method to your sound object
trace("pos" + pos);
}

Similar Messages

  • Dummy Guide needed for converting AS2 code into AS3

    I have to convert my existing AS2 code into AS3, but I might as well be reading chinese. I never even began to learn AS3, it was still fairly new at the time and the class ended before we had an opportunity to even touch on it. My major was not web design, it was the print side of design. I took an additional class, after I graduated, to learn web design and our teacher told us, basically, that we were designers, not coders so we won't be getting much into actionscripting, beyond the basics. At the time I was relieved, but looking back, I really wish we would have gotten more into it. Bottom line, I need to learn now.
    Is there ANYONE that can help me out? I will list my code below, buy I am way beyond lost any help that can be provided, I would be so grateful!!!!
    On the main timeline I have the basic..
    stop(); -- I found the AS3 version, but I don't know what I'm looking at. I get "not_yet_set.stop()" and there are are 8 options I can choose from. I just want the timeline to stop until I tell it where to go next. And what is "not_yet_set"
    Then I have my buttons, which are, basically...
    on (release) {
    gotoAndStop("Home");
    Or "gotoAndPlay("Whatever");"
    I also have buttons for scrolling...
    on (press) {
    play();
    on (release) {
    stop();
    AND
    on (press) {
    _root.AboutMe_Controller.gotoAndPlay(…
    on (release) {
    _root.AboutMe_Controller.gotoAndStop(…
    For the on(release) command, this is what I found as the AS3 version: not_set_yet.dispatchEvent()

    because that's really as1 code, you have steeper learning curve than going from as2 to as3.
    first, remove all code from objects, assign instance names to your buttons and you can then start on as3:
    // so, if you name your home button, home_btn:
    home_btn.addEventListener(MouseEvent.CLICK,homeF);
    function homeF(e:MouseEvent):void{
    gotoAndStop("Home");
    p.s.  the not_yet_set stuff is there because you tried to use script assist or some other actionscript shortcut.

  • Help! Convert simple Flash AS2 code to AS3

    Hi everyone,
    I'm a Flash beginner and followed a tutorial: http://www.webwasp.co.uk/tutorials/018/tutorial.php ... to learn how to make a "live paint/draw" effect. I didn't realize  that if I made something in AS2, I wouldn't be able to embed it (and  have it work) into my root AS3 file, where I've got a bunch of other  stuff going on. I've tried following tips on how to change AS2 code to  AS3, but it just doesn't work. I know it's simple code, and that some  genius out there can figure it out, but I'm at a loss. Please help!
    Here's the AS2 code:
    _root.createEmptyMovieClip("myLine", 0);
    _root.onMouseDown = function() {
       myLine.moveTo(_xmouse, _ymouse);
       ranWidth = Math.round((Math.random() * 10)+2);
       myLine.lineStyle(ranWidth, 0xff0000, 100);
       _root.onMouseMove = function() {
          myLine.lineTo(_xmouse, _ymouse);
    _root.onMouseUp = function() {
       _root.onMouseMove = noLine;
    Thanks in advance!
    Signed,
    Nicolle
    Flash Desperado

    Considering the code is on timeline:
    var myLine:Sprite = new Sprite();
    addChild(myLine);
    var g:Graphics = myLine.graphics;
    addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
    function onMouseDown(e:MouseEvent):void {
         var ranWidth:Number = Math.round((Math.random() * 10) + 2);
         g.clear();
         g.lineStyle(ranWidth, 0xFF0000, 1);
         addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
         addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
    function onMouseMove(e:MouseEvent):void {
         g.lineTo(mouseX, mouseY);
    function onMouseUp(e:MouseEvent):void {
         removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
         removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);

  • Change as2 code to as3

    I used a tutorial http://www.flash-game-design.com/flash-tutorials/funky-flash-website-tutorial-5.html to make a menu for my application, I've tried following tips on how to change AS2 code to AS3, but it just doesn't work.
    menu = ["bulls", "about", "roster", "schedule"];
    var current = menu[0];
    for (var i = 0; i<menu.length; i++) {
    var b = menu[i];
    this[b+"_btn"].stars._visible = false;
    this[b+"_btn"].txt = b;
    this[b+"_btn"].onPress = function() {
    _root.site[current+"_btn"].stars._visible = false;
    _root.site[this.txt+"_btn"].stars._visible = true;
    current = this.txt;
    _root.site.content.gotoAndStop(this.txt)
    this[current+"btn"].stars._visible = true;
    this.onEnterFrame = function() {
    this[current+"_btn"].stars.s1._rotation += 1;
    this[current+"_btn"].stars.s2._rotation += 0.5;
    Thank you,
    Glenn

    Just a note. Function declarations in a loop is an EXTREMELY bad practice that will lead to many problems if it doesn't have some already. So, the following lines:
    for (var i:int = 0; i<menu.length; i++) {
        var b:String = menu[i];
        this[b+"_btn"].stars.visible = false;
        this[b+"_btn"].addEventListener(MouseEvent.CLICK,fn);
        this[b+"_btn"].txt=b;
        function fn(e:MouseEvent):void{
            this[current].stars.visible = false;
            var nam:String=e.target.parent.name;
            this[nam].stars.visible = true;
            current = nam;
            //MovieClip(root).site.content.gotoAndStop(this.txt)
    should be:
    for (var i:int = 0; i < menu.length; i++) {
         var b:String = menu[i];
         this[b+"_btn"].stars.visible = false;
         this[b+"_btn"].addEventListener(MouseEvent.CLICK,fn);
         this[b+"_btn"].txt=b;
    function fn(e:MouseEvent):void {
         this[current].stars.visible = false;
         var nam:String=e.target.parent.name;
         this[nam].stars.visible = true;
         current = nam;
         //MovieClip(root).site.content.gotoAndStop(this.txt)

  • Migrate existing code of AS3 to AS2 - URLRequest, URLLoader

    Hi,
    I have written code to read an XML file by using URLRequest and URLLoader in ActionScript 3.0. Code is pasted below. This runs well in AS3.  Problem I am facing is because I wrote this in AS3, I am not able to use the DateChooser component in another part of the flash module because it seems like DateChooser component is not supported in AS3. So I want to migrate my below AS3 code back to AS2.
    **** Code in AS3 (I need help in writing equivalent code in AS2) :-
    var xmlText:XML ;
    var xmlReq:URLRequest = new URLRequest("myFile.xml");
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(xmlReq);
    xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
    function xmlLoaded(event:Event):void
        xmlText = new XML(xmlLoader.data);  
        info_txt.htmlText = xmlText.someTag ;
    **** I cannot use the above as is because, when I change the publish settings from AS3 to AS2, I get following errors -
    The class or interface 'URLRequest' could not be loaded.
    The class or interface 'URLLoader' could not be loaded.
    The class or interface 'Event' could not be loaded.
    Same works well in AS3. What should I do to make this work in AS2 or can anyone direct me in writing an equivalent in AS2.
    Please assist.
    Thanks in advance.
    MG

    parsing is done using the xmlnode methods and properties.  how you parse an xml file (in as2) depends on its structure.  but generally, you use firstChild, nextSibling, childNodes and nodeValue in the appropriate sequence to extact data.  the flash help files have sample code.  for tutorials, check google.
    if you're trying to load a cross-domain xml file, you'll have a cross-domain security issue to deal with.

  • Noob question: How to update very basic as2 code to as3.

    I've been asked to update a web banner with old as2 code, and not being a coder or a regular Flash user, I'm stuck with what I'm sure is a simple problem. The code in the opening frame is;
    function timeOut(pauseTime) {
      stop();
      pauseTimer = setInterval(this, "goPlay", pauseTime);
    function goPlay() {
      play();
      clearInterval(pauseTimer);
    After that there are a few frames that include timeOut(500); code, which seems basic enough, so I imagine my problems are all in the opening code.
    I get 4 errors that all refer to Frame 1;
    1120: Access of undefined property pauseTimer.
    1067: Implicit coercion of a value of type CapOne_MM_648x480b_fla:MainTimeline to an unrelated type Function.
    1067: Implicit coercion of a value of type String to an unrelated type Number.
    1120: Access of undefined property pauseTimer.
    Can anyone help or point me in the right direction? Thanks.

    For the code you show there would be no need to convert to AS3 since between AS2 and AS3 it hasn't changed.  One thing you do need to do is declare variables and since pauseTimer is used in mutliple functions it needs to be declared outside any functions.  Another thing you need to do is specify the variable types, including the arguments passed into function.  As for the setInterval call itself it appears to be written incorrectly....
    var   pauseTimer:Number;
    function timeOut(pauseTime:Number) {
          stop();
         pauseTimer = setInterval(goPlay, pauseTime);

  • Help plsss converting this AS2 code to AS3!!

    here is a little AS2 code that is in fact a photo gallery
    that i use in my site and i want to convert it to AS3 but i just
    cant seem to get it right... could someone plssss help me?!?!

    with what part are you having trouble?

  • Need assistance converting some AS2 code to AS3

    Hi,
    I have some simple AS2 code that brings in a MovieClip when
    you click a button. This is currently AS2, and I would rather
    convert it to AS3. I also have some code which closes the MovieClip
    upon button Click.
    The code I am currently using is below:

    addMC is the name of one of the event handler functions, not
    the button(s). the button instance names are: addButton and
    removeButton.
    To have three of them, duplicate what you see and have new
    variables, functions, and button names for all three sets, adjusted
    appropriately.
    I'm pretty sure this isn't over yet, I'm just giving you code
    per your defined scenario, which may have a hole or two in it. Try
    it out and see what you really want to do, then come back when you
    find out things need to be tamed in some way or aren't working as
    you want. There are more complicated ways to deal with a situation
    depending on what you really want, and I'm one who prefers to see
    some work done at your end that shows you've tried something (I'm
    not mean, much, I just have this thing about learning by doing).

  • As2 code to As3 conversion please

    Hey, could someone help me converting the following code to AS3. Thanks for any help..
    id=_root.id;
    if(this._y<>_root.txk){
    this._y=_root.txk;
    _root.txk+=60;
    this._x=_root.txx;
    textyazı="";
    onEnterFrame=function(){
    this._name=namet.text;
    if(_root.txk==360){
    _root.txx+=60;
    _root.txk=60;
    this.onPress=function(){
    if(_root["t"+namet.text].txtn.text<>namet.text){
    _root.attachMovie("txt_dd","t"+namet.text,_root.derinlik);
    _root["t"+namet.text]._x=100;
    _root["t"+namet.text]._y=100;
    _root["t"+namet.text].txtyname.text=namet.text;
    _root["t"+namet.text].txtn.text=namet.text;
    _root["t"+namet.text].txtyazılar.text=textyazı;
    _root.derinlik++;
    txtac = SharedObject.getLocal(id);
    setInterval(function(){
    if(txtac.data.namet<>"" && txtac.data.id>0){
    namet.text=txtac.data.namet;
    textyazı=txtac.data.textyazı;
    id=txtac.data.id;
    }else{
    namet.text=_name;
    if(namet.text=="undefined"){
              namet.text=_name;
    if(textyazı==undefined){
              textyazı="";
    },50);
    this.useHandCursor=false;

    1.download flashdevelop (Flash has bad code hinting and error descriptions)
    2.start with deleting underscores in _root,_x,_y
    3.work your way up from there
    4.Lines like:
    this.onPress=function
    are probably attached directly to a button or MovieClip: This is not possible in as3 anymore. You have to take the code out of the button and put it on the timeline of the button, if it is a MovieClip.
    5.The Event Model has changed considerably:
    onEnterFrame=function(){
    // do stuff here
    is now
    addEventListener(ENTER_FRAME, enterFrameHandler);
    function enterFrameHandler(e:Event):void{
    //do stuff here

  • What is this little AS2 code in AS3?

    Hey guys!
    I got something to embed HTML with it's pics and text and stuff...
    But this is in AS2.0 and I would need it in AS3.0..
    I was checking the AS2.0 migration on Adobe website, but I can't find / don't know some things..
    What I got in AS2.0:
    function(){return A.apply(null,[this].concat($A(arguments)))}
    myLoadVars = new LoadVars();
    myLoadVars.onLoad = function() {
    myText.htmlText = myLoadVars.myHTMLdata;
    myLoadVars.load("myHTML.txt");
    And to where I got by myself (not much AND IF this is correct..):
    function(){return A.apply(null,[this].concat($A(arguments)))}
    import flash.net.URLLoader
    myLoadVars = new URLLoader();
    myLoadVars.onLoad = function() {
    myText.htmlText = myLoadVars.myHTMLdata;
    myLoadVars.load("myHTML.txt");
    Could someone help me with this plz?
    Thanks!

    Hey thanks for the fast answer!
    This is totaly it!
    I forgot something stupid in my own AS3... lol
    BUT when I copy your code, I get a error.. You made a very very very little mistake...
    function(){return A.apply(null,[this].concat($A(arguments)))}
    var myLoader:URLLoader = new URLLoader();
    myLoader.addEventListener(Event.COMPLETE, onLoad)
    myLoader.load(new URLRequest("myHTML.txt"));   ----> That's what you forgot :-)
    function onLoad(e:Event):void
         myText.htmlText = e.target.data;
    Edit yours a bit or something... I'll give you the correct answer thingy :-)
    Thanks very very much! :-)

  • Trying to convert AS2 code to AS3

    I had this code in AS2 and it worked I am trying to convert
    it to AS3 however and am stuck Please Help!!
    Thanks,
    Alex

    just add your click listeners and handlers:

  • Convert as2 code to as3 please help

    function fDieList()
        if (pDieList.length > 0)
            _root.inSFX.die.start();
            for (var _loc2 = 0; _loc2 <= pDieList.length; ++_loc2)
                pDieList[_loc2].fDie();
            } // end of for
            pDieList = [];
            actioner.pKills = true;
        } // end if
    } // End of the function
    function fDieListSetup()
        if (pDieList.length > 0)
            for (var _loc1 = 0; _loc1 <= pDieList.length; ++_loc1)
                pDieList[_loc1].fDieSetup();
            } // end of for
        } // end if
    } // End of the function
    function recur(fromx, fromy, tox, toy)
        var _loc2 = fromy;
        var _loc1 = fromx;
        var _loc3 = toy;
        if (_loc1 == tox && _loc2 == _loc3)
            return (true);
        else
            ++len;
            drum[len][0] = _loc1;
            drum[len][1] = _loc2;
            wa[_loc1][_loc2] = 1;
            if (_loc1 > tox && _loc2 > _loc3)
                if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
                    ok = recur(_loc1 - 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
                    ok = recur(_loc1, _loc2 - 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
                    ok = recur(_loc1 + 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
                    ok = recur(_loc1, _loc2 + 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
            else if (_loc1 <= tox && _loc2 > _loc3)
                if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
                    ok = recur(_loc1, _loc2 - 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
                    ok = recur(_loc1 + 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
                    ok = recur(_loc1, _loc2 + 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
                    ok = recur(_loc1 - 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
            else if (_loc1 > tox && _loc2 <= _loc3)
                if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
                    ok = recur(_loc1 - 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
                    ok = recur(_loc1, _loc2 + 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
                    ok = recur(_loc1 + 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
                    ok = recur(_loc1, _loc2 - 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
            else
                if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
                    ok = recur(_loc1, _loc2 + 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
                    ok = recur(_loc1 + 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
                    ok = recur(_loc1, _loc2 - 1, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end if
                } // end if
                if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
                    ok = recur(_loc1 - 1, _loc2, tox, _loc3);
                    if (ok)
                        return (ok);
                    } // end else if
                } // end else if
            } // end else if
            --len;
            return (ok);
        } // end else if
    } // End of the function
    function way(fromx, fromy, tox, toy)
        len = 0;
        ok = false;
        for (i = 1; i <= limits; i++)
            for (j = 1; j <= limits; j++)
                wa[i][j] = ma[i][j];
            } // end of for
        } // end of for
        wa[fromx][fromy] = 0;
        return (recur(fromx, fromy, tox, toy));
    } // End of the function
    function init()
        var _loc2 = _root;
        scorerule = new Array(40, 50, 60, 70, 80);
        score = 0;
        totalballs = 7;
        nextballs = 3;
        limits = 9;
        kkk = 1000;
        xnext = next1._x - 19;
        ynext = next1._y + 21;
        ballsput = 0;
        drum = new Array();
        wa = new Array();
        st = new Array();
        for (i = 1; i <= limits * limits; i++)
            drum[i] = new Array(0, 0);
        } // end of for
        for (i = 1; i <= limits * limits; i++)
            wa[i] = new Array(limits + 1);
        } // end of for
        selected = new Array(0, 0);
        ma = new Array();
        for (i = 1; i <= limits; i++)
            ma[i] = new Array(limits + 1);
            for (j = 1; j <= limits; j++)
                ma[i][j] = 0;
                _loc2.inGame["balls" + i + j].x = i;
                _loc2.inGame["balls" + i + j].y = j;
            } // end of for
        } // end of for
        nextarray = new Array();
        for (i = 1; i <= nextballs; i++)
            nextarray[i] = new Array(0, 0, 0);
            attachMovie("balls", "nextballs" + i, kkk++);
            _loc2.inGame["nextballs" + i]._x = xnext;
            _loc2.inGame["nextballs" + i]._y = ynext + i * 60;
            _loc2.inGame["nextballs" + i]._xscale = 140;
            _loc2.inGame["nextballs" + i]._yscale = 140;
        } // end of for
        actioner2.swapDepths(20000);
    } // End of the function
    function generatenext()
        var _loc2 = _root;
        if (ballsput <= 81 - nextballs)
            togenerate = nextballs;
        else
            togenerate = 81 - ballsput;
        } // end else if
        for (i = 1; i <= togenerate; i++)
            do
                x = random(limits) + 1;
                y = random(limits) + 1;
            } while (ma[x][y] != 0)
            nextarray[i][0] = random(totalballs) + 1;
            nextarray[i][1] = x;
            nextarray[i][2] = y;
            _loc2.inGame["nextballs" + i].gotoAndStop(nextarray[i][0] + 1);
            _loc2.inGame["nextballs" + i].buton._visible = false;
        } // end of for
        for (i = togenerate + 1; i <= nextballs; i++)
            _loc2.inGame["nextballs" + i].gotoAndStop("blank");
        } // end of for
        nextballs3.buton._visible = false;
    } // End of the function
    function putnextballs()
        var _loc2 = _root;
        _loc2.inSFX.grow.start();
        if (ballsput <= 81 - nextballs)
            togenerate = nextballs;
        else
            togenerate = 81 - ballsput;
        } // end else if
        for (i = 1; i <= togenerate; i++)
            if (ma[nextarray[i][1]][nextarray[i][2]] == 0)
                ma[nextarray[i][1]][nextarray[i][2]] = nextarray[i][0];
            else
                do
                    x = random(limits) + 1;
                    y = random(limits) + 1;
                } while (ma[x][y] != 0)
                nextarray[i][1] = x;
                nextarray[i][2] = y;
                ma[nextarray[i][1]][nextarray[i][2]] = nextarray[i][0];
            } // end else if
            _loc2.inGame["balls" + nextarray[i][1] + nextarray[i][2]].gotoAndStop(nextarray[i][0] + 1);
            line(nextarray[i][1], nextarray[i][2], ma[nextarray[i][1]][nextarray[i][2]]);
        } // end of for
        ballsput = ballsput + togenerate;
        if (ballsput == limits * limits)
            _loc2.fEndGame();
        } // end if
    } // End of the function
    function line(x, y, c)
        var _loc4 = 0;
        var _loc6 = new Array();
        var _loc5 = new Array();
        var _loc2 = new Array();
        var _loc3 = new Array();
        for (var _loc4 = 1; _loc4 <= limits; ++_loc4)
            _loc6[_loc4] = new Array(2);
            _loc5[_loc4] = new Array(2);
            _loc2[_loc4] = new Array(2);
            _loc3[_loc4] = new Array(2);
        } // end of for
        var _loc7 = 0;
        fl = 0;
        for (var _loc4 = 1; _loc4 <= limits; ++_loc4)
            if (ma[_loc4][y] == c)
                if (fl == 0)
                    ++_loc7;
                    _loc6[_loc7][0] = _loc4;
                    _loc6[_loc7][1] = y;
                } // end if
                continue;
            } // end if
            if (_loc7 < 4)
                _loc7 = 0;
                continue;
            } // end if
            fl = 1;
        } // end of for
        st1 = 0;
        fl = 0;
        for (var _loc4 = 1; _loc4 <= limits; ++_loc4)
            if (ma[x][_loc4] == c)
                if (fl == 0)
                    ++st1;
                    _loc5[st1][0] = x;
                    _loc5[st1][1] = _loc4;
                } // end if
                continue;
            } // end if
            if (st1 < 4)
                st1 = 0;
                continue;
            } // end if
            fl = 1;
        } // end of for
        fl = 0;
        st2 = 0;
        imin = x;
        for (jmin = y; imin > 1 && jmin > 1; jmin--)
            --imin;
        } // end of for
        imax = x;
        for (jmax = y; imax < limits && jmax < limits; jmax++)
            ++imax;
        } // end of for
        if (imin == 1)
            for (var _loc4 = imin; _loc4 <= imax; ++_loc4)
                if (ma[_loc4][jmin + _loc4 - 1] == c)
                    if (fl == 0)
                        ++st2;
                        _loc2[st2][0] = _loc4;
                        _loc2[st2][1] = jmin + _loc4 - 1;
                    } // end if
                    continue;
                } // end if
                if (st2 < 4)
                    st2 = 0;
                    continue;
                } // end if
                fl = 1;
            } // end of for
        else
            for (var _loc4 = jmin; _loc4 <= jmax; ++_loc4)
                if (ma[imin + _loc4 - 1][_loc4] == c)
                    if (fl == 0)
                        ++st2;
                        _loc2[st2][0] = imin + _loc4 - 1;
                        _loc2[st2][1] = _loc4;
                    } // end if
                    continue;
                } // end if
                if (st2 < 4)
                    st2 = 0;
                    continue;
                } // end if
                fl = 1;
            } // end of for
        } // end else if
        fl = 0;
        st3 = 0;
        imin = x;
        for (jmin = y; imin > 1 && jmin < limits; jmin++)
            --imin;
        } // end of for
        imax = x;
        for (jmax = y; imax < limits && jmax > 1; jmax--)
            ++imax;
        } // end of for
        if (imin == 1)
            for (var _loc4 = imin; _loc4 <= imax; ++_loc4)
                if (ma[_loc4][jmin - _loc4 + 1] == c)
                    if (fl == 0)
                        ++st3;
                        _loc3[st3][0] = _loc4;
                        _loc3[st3][1] = jmin - _loc4 + 1;
                    } // end if
                    continue;
                } // end if
                if (st3 < 4)
                    st3 = 0;
                    continue;
                } // end if
                fl = 1;
            } // end of for
        else
            for (var _loc4 = jmax; _loc4 <= jmin; ++_loc4)
                if (ma[jmin - _loc4 + jmax][_loc4] == c)
                    if (fl == 0)
                        ++st3;
                        _loc3[st3][0] = jmin - _loc4 + jmax;
                        _loc3[st3][1] = _loc4;
                    } // end if
                    continue;
                } // end if
                if (st3 < 4)
                    st3 = 0;
                    continue;
                } // end if
                fl = 1;
            } // end of for
        } // end else if
        destroyed = 0;
        if (_loc7 >= 4)
            for (var _loc4 = 1; _loc4 <= _loc7; ++_loc4)
                pDieList.push(_root.inGame["balls" + _loc6[_loc4][0] + _loc6[_loc4][1]]);
                ma[_loc6[_loc4][0]][_loc6[_loc4][1]] = 0;
            } // end of for
            destroyed = destroyed + _loc7;
            score = score + scorerule[_loc7 - 4];
        } // end if
        if (st1 >= 4)
            for (var _loc4 = 1; _loc4 <= st1; ++_loc4)
                pDieList.push(_root.inGame["balls" + _loc5[_loc4][0] + _loc5[_loc4][1]]);
                ma[_loc5[_loc4][0]][_loc5[_loc4][1]] = 0;
            } // end of for
            destroyed = destroyed + st1;
            score = score + scorerule[st1 - 4];
        } // end if
        if (st2 >= 4)
            for (var _loc4 = 1; _loc4 <= st2; ++_loc4)
                pDieList.push(_root.inGame["balls" + _loc2[_loc4][0] + _loc2[_loc4][1]]);
                ma[_loc2[_loc4][0]][_loc2[_loc4][1]] = 0;
            } // end of for
            destroyed = destroyed + st2;
            score = score + scorerule[st2 - 4];
        } // end if
        if (st3 >= 4)
            for (var _loc4 = 1; _loc4 <= st3; ++_loc4)
                pDieList.push(_root.inGame["balls" + _loc3[_loc4][0] + _loc3[_loc4][1]]);
                ma[_loc3[_loc4][0]][_loc3[_loc4][1]] = 0;
            } // end of for
            destroyed = destroyed + st3;
            score = score + scorerule[st3 - 4];
        } // end if
        if (destroyed >= 10)
            --destroyed;
        } // end if
        ballsput = ballsput - destroyed;
        scoretxt = score;
        if (destroyed != 0)
            fDieListSetup();
            _root.inSFX.pickup.start();
        } // end if
        return (destroyed != 0);
    } // End of the function
    function fromactioner(fromx, fromy, tox, toy)
        var _loc3 = toy;
        var _loc2 = tox;
        var _loc4 = fromy;
        ma[_loc2][_loc3] = ma[fromx][_loc4];
        ma[fromx][_loc4] = 0;
        _root.inGame["balls" + fromx + _loc4].gotoAndStop("blank");
        _root.inGame["balls" + fromx + _loc4].ball.gotoAndStop(1);
        _root.inGame["balls" + _loc2 + _loc3].gotoAndStop(ma[_loc2][_loc3] + 1);
        _root.inGame["balls" + _loc2 + _loc3].ball.gotoAndStop(1);
        selected[0] = 0;
        selected[1] = 0;
        line(_loc2, _loc3, ma[_loc2][_loc3]);
        actioner.gotoAndPlay(2);
    } // End of the function
    function move(fromx, fromy, tox, toy)
        var _loc2 = _root;
        var _loc3 = false;
        if (way(fromx, fromy, tox, toy))
            _loc3 = true;
            fromactioner(fromx, fromy, tox, toy);
            _loc2.inGame["balls" + _loc2.inGame.drum[ii][0] + _loc2.inGame.drum[ii][1]].gotoAndStop("blank");
        } // end if
        return (_loc3);
    } // End of the function
    function movetest(fromx, fromy, tox, toy)
        var _loc1 = false;
        if (way(fromx, fromy, tox, toy))
            _loc1 = true;
        } // end if
        return (_loc1);
    } // End of the function
    pLastClicked = "none";
    pLastClickedType = 1;
    pClicked = false;
    pDieList = [];
    init();
    generatenext();
    putnextballs();
    generatenext();
    stop ();

    Zhanbolat,
    In theory, conversion of this code is not difficult, especially because it is clear what the logic is designed to do. The issue is that you will not have an expected result once only this code is converted in isolation. This puppy uses some other objects that are written in AS2 including entities in the FLA library.
    In short, it looks like this application needs a total overhaul at every level in order for it to properly function as an AS3 program.
    With that said, although this is, again, not a difficult task, it is unlikely to find someone to do it for free. You may have a better luck if you start conversion yourself and post focused questions as you go.

  • Convert onEnterFrame Event Handler  AS2 code into AS3

    My code of AS2 is given below. I do not know what event handler type is used and which event handler is used in AS3.
    onEnterFrame = function(){

    this.addEventListener(Event.ENTER_FRAME,onEf);
    // "this" references the movie itself, you can also use "stage" or the instance name of an object on the stage
    // look up addEventListener in the online help. This method takes two arguments, the event that you want to "listen" for and the name of the function to execute when the event occurs.
    // the function that will be called when the event occurs. It takes one argument that corresponds with the first argument of the addEventListener method.
    function onEf(event:Event):void {

  • How to convert this random pos AS2 code to AS3?

    Hi! I'm doing a sort of screensaver and need to random the logo all over the screen. In ActionScript 2 it was easy, just paste some code to the object and it works. The things to do this is total different in ActionScript 3 and I can't figure out how to solve this. It would be nice if someone could take a look at my very simple example and point me in the right direction. Maybe there is some example out there done in AS3?
    I can't figure out how to post fla so I renamed it to jpg. Just change the extension to fla again...
    Regards / Jimmy

    SORRY FOR THE LATE RESPONSE I WAS NOT ONLINE FOR THREE DAYS....
    I am still not able to download the file.
    What you can do is enclose the code which is called directly on the timeline in a function and call that function whenever required.
    You can also send the file on my mail ID at [email protected] [Make sure you zip it and the version is saved in CS3]

  • Help Converting old AS2 code to AS3

    I just updated an old flash file with some new photos.  I don't know much about Flash - enough to change the photos and hit export BUT now I'm getting errors.  I had a _root issue which I fixed thanks to this forum but I'm still getting these errors:
    Scene 1, Layer 'Actions', Frame 3, Line 14, Column 2
    1120: Access of undefined property timer1.
    Scene 1, Layer 'Actions', Frame 3, Line 18, Column 2
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 29, Column 2
    1120: Access of undefined property timer2.
    Scene 1, Layer 'Actions', Frame 3, Line 33, Column 35
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 34, Column 5
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 35, Column 17
    1120: Access of undefined property timer2.
    Scene 1, Layer 'Actions', Frame 3, Line 40, Column 2
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 40, Column 6
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 44, Column 16
    1120: Access of undefined property timer1.
    Preloader, Layer 'Actions', Frame 1, Line 1, Column 1
    1120: Access of undefined property bytes_loaded.
    Preloader, Layer 'Actions', Frame 1, Line 2, Column 1
    1120: Access of undefined property bytes_total.
    Preloader, Layer 'Actions', Frame 1, Line 3, Column 1
    1120: Access of undefined property getPercent.
    Preloader, Layer 'Actions', Frame 1, Line 3, Column 14
    1120: Access of undefined property bytes_loaded.
    Preloader, Layer 'Actions', Frame 1, Line 3, Column 27
    1120: Access of undefined property bytes_total.
    Preloader, Layer 'Actions', Frame 1, Line 4, Column 25
    1120: Access of undefined property getPercent.
    Preloader, Layer 'Actions', Frame 1, Line 5, Column 30
    1120: Access of undefined property getPercent.
    Preloader, Layer 'Actions', Frame 1, Line 7, Column 5
    1120: Access of undefined property bytes_loaded.
    Preloader, Layer 'Actions', Frame 1, Line 7, Column 21
    1120: Access of undefined property bytes_total.
    Preloader, Layer 'Actions', Frame 1, Line 8, Column 24
    1067: Implicit coercion of a value of type int to an unrelated type String.
    I didn't originally write the code and I don't know nearly enough about Flash to fix them.  Here's the code:
    stop();
    var fadeSpeed = 40; //Sets fad-in speed of images, default is 30
    var imageTime = 5; //Sets time each image is on screen, in seconds
    MovieClip(root).attachMovie("mc_Images", "mcFader", 10, {x:0, y:0});
    MovieClip(root).mcFader._alpha = 0;
    MovieClip(root).mcFader._visible = false;
    var imageNum = 1;
    startShow();
    function startShow(){
              timer1 = setInterval(loadImage, imageTime * 1000);
    function loadImage(){
              i = 0;
              imageNum ++;
              if(imageNum == MovieClip(root).mcImages._totalFrames + 1){
                        imageNum = 1;
              MovieClip(root).mcImages._x = 0;
              MovieClip(root).mcImages._y = 0;
              MovieClip(root).mcFader._alpha = 0;
              MovieClip(root).mcFader._visible = true;
              MovieClip(root).mcFader.gotoAndStop(imageNum);
              MovieClip(root).nextImage = imageNum;
              timer2 = setInterval(fadeImage, fadeSpeed);
    function fadeImage(){
              MovieClip(root).mcFader._alpha = i;
              if(i > 100){
                        clearInterval(timer2);
                        MovieClip(root).mcImages.gotoAndStop(MovieClip(root).nextImage);
                        MovieClip(root).mcFader._alpha = 0;
                        MovieClip(root).mcFader._visible = false;
              i = i + 10;
    function goLink(fNum){
              clearInterval(timer1);
              MovieClip(root).mcImages.gotoAndStop(fNum);
    ANY help would be GREATLY appreciated!! 

    Ok, I researched a little.
    The variable i is set to 0 in loadImage, which is called by a timed out function startShow, which is called directly.
    So I was right to surmise I=0, but you don't even need to define it yet.
    If you add
    var i;
    var timer1,timer2;
    to the top of the program, all the variables are defined globally, which as far as I can see is the intention.
    That leaves me with one undefined variable and curious syntax:
    r36:
    this.mcImages.gotoAndStop(this.nextImg age);
    What is intended here? Age is never defined. I guess it might be defined by Flashvars, as in as2, these would be accesible as a root variable, but this doesn't mean much to me. I'd expect something like this.nextImg+age or something.
    So I searched again: nextImg is not defined but I found this.nextImage = imageNum;
    So there is just a space that got in there somehow.
    Fixed that and it compiles, but immeadeately after compilation you get a problem with attachMovie
    this.attachMovie("mc_Images", "mcFader", 10, {x:0, y:0});
    This is a as2 way of taking things out of your library and placing them as a child of another.
    The new way to do that is to make a clip accessible in your library and then instantiate a new class with:
    var mcFader:mc_Images= new mc_Images();
    this.setChildIndex(mcFader,10);
    mcFader.x=0; // this is not needed, as it is default, as it was in as2, so it was obsolete there as well!
    mcFader.y=0;// this is not needed, as it is default, as it was in as2, so it was obsolete there as well!
    this.addChild(mcFader);
    There are some other issues after that,
    I would have to look at the source to fix them, because they have to do with the structure of mc_images. Which is not in code, but in your library.
    The whole code would the look like this:
    stop();
    var fadeSpeed = 40; //Sets fad-in speed of images, default is 30
    var imageTime = 5; //Sets time each image is on screen, in seconds
    var mcFader:mc_Images= new mc_Images();
    this.setChildIndex(mcFader,10);
    mcFader.x=0; // this is not needed, as it is default, as it was in as2, so it was obsolete there as well!
    mcFader.y=0;// this is not needed, as it is default, as it was in as2, so it was obsolete there as well!
    this.addChild(mcFader);
    this.mcFader._alpha = 0;
    this.mcFader._visible = false;
    var imageNum = 1;
    var i=0;
    var timer1,timer2;
    startShow();
    function startShow(){
             timer1 = setInterval(loadImage, imageTime * 1000);
    function loadImage(){
              i = 0;
              imageNum ++;
              if(imageNum == this.mcImages._totalFrames + 1){
                        imageNum = 1;
              this.mcImages._x = 0;
              this.mcImages._y = 0;
              this.mcFader._alpha = 0;
              this.mcFader._visible = true;
              this.mcFader.gotoAndStop(imageNum);
              this.nextImage = imageNum;
              var timer2 = setInterval(fadeImage, fadeSpeed);
    function fadeImage(){
              this.mcFader._alpha = i;
              if(i > 100){
                        clearInterval(timer2);
                        this.mcImages.gotoAndStop(this.nextImgage);
                        this.mcFader._alpha = 0;
                        this.mcFader._visible = false;
              i = i + 10;
    function goLink(fNum){
              clearInterval(timer1);
              this.mcImages.gotoAndStop(fNum);
    jencreates wrote:
    I just updated an old flash file with some new photos.  I don't know much about Flash - enough to change the photos and hit export BUT now I'm getting errors.  I had a _root issue which I fixed thanks to this forum but I'm still getting these errors:
    Scene 1, Layer 'Actions', Frame 3, Line 14, Column 2
    1120: Access of undefined property timer1.
    Scene 1, Layer 'Actions', Frame 3, Line 18, Column 2
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 29, Column 2
    1120: Access of undefined property timer2.
    Scene 1, Layer 'Actions', Frame 3, Line 33, Column 35
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 34, Column 5
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 35, Column 17
    1120: Access of undefined property timer2.
    Scene 1, Layer 'Actions', Frame 3, Line 40, Column 2
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 40, Column 6
    1120: Access of undefined property i.
    Scene 1, Layer 'Actions', Frame 3, Line 44, Column 16
    1120: Access of undefined property timer1.
    Preloader, Layer 'Actions', Frame 1, Line 1, Column 1
    1120: Access of undefined property bytes_loaded.
    Preloader, Layer 'Actions', Frame 1, Line 2, Column 1
    1120: Access of undefined property bytes_total.
    Preloader, Layer 'Actions', Frame 1, Line 3, Column 1
    1120: Access of undefined property getPercent.
    Preloader, Layer 'Actions', Frame 1, Line 3, Column 14
    1120: Access of undefined property bytes_loaded.
    Preloader, Layer 'Actions', Frame 1, Line 3, Column 27
    1120: Access of undefined property bytes_total.
    Preloader, Layer 'Actions', Frame 1, Line 4, Column 25
    1120: Access of undefined property getPercent.
    Preloader, Layer 'Actions', Frame 1, Line 5, Column 30
    1120: Access of undefined property getPercent.
    Preloader, Layer 'Actions', Frame 1, Line 7, Column 5
    1120: Access of undefined property bytes_loaded.
    Preloader, Layer 'Actions', Frame 1, Line 7, Column 21
    1120: Access of undefined property bytes_total.
    Preloader, Layer 'Actions', Frame 1, Line 8, Column 24
    1067: Implicit coercion of a value of type int to an unrelated type String.
    I didn't originally write the code and I don't know nearly enough about Flash to fix them.  Here's the code:
    stop();
    var fadeSpeed = 40; //Sets fad-in speed of images, default is 30
    var imageTime = 5; //Sets time each image is on screen, in seconds
    MovieClip(root).attachMovie("mc_Images", "mcFader", 10, {x:0, y:0});
    MovieClip(root).mcFader._alpha = 0;
    MovieClip(root).mcFader._visible = false;
    var imageNum = 1;
    startShow();
    function startShow(){
              timer1 = setInterval(loadImage, imageTime * 1000);
    function loadImage(){
              i = 0;
              imageNum ++;
              if(imageNum == MovieClip(root).mcImages._totalFrames + 1){
                        imageNum = 1;
              MovieClip(root).mcImages._x = 0;
              MovieClip(root).mcImages._y = 0;
              MovieClip(root).mcFader._alpha = 0;
              MovieClip(root).mcFader._visible = true;
              MovieClip(root).mcFader.gotoAndStop(imageNum);
              MovieClip(root).nextImage = imageNum;
              timer2 = setInterval(fadeImage, fadeSpeed);
    function fadeImage(){
              MovieClip(root).mcFader._alpha = i;
              if(i > 100){
                        clearInterval(timer2);
                        MovieClip(root).mcImages.gotoAndStop(MovieClip(root).nextIm age);
                        MovieClip(root).mcFader._alpha = 0;
                        MovieClip(root).mcFader._visible = false;
              i = i + 10;
    function goLink(fNum){
              clearInterval(timer1);
              MovieClip(root).mcImages.gotoAndStop(fNum);
    ANY help would be GREATLY appreciated!! 

Maybe you are looking for

  • Need to sync my iPod Touch in a new Installation of Snow Leopard

    Hi! I've recently re-installed Snow Leopard in my MacBook. I installed iTunes 9.2.1 (5) and when I plug my iPod Touch (2G, iOS4), iTunes ask me to clear all data. I really need to have the content of my iPod Touch not modified. What can I do?

  • Preview only shows first page of TIF files

    Hello, I am having problems with Preview version 3.0.9 (409). When opening a multi-page TIF file, only the first page is displayed. The "page down" button does allow to jump to the following pages. (I am able to view the whole document with other pro

  • Ipad mini/HDMI question?

    I want to buy the lightning to HDMI adapter for my ipad mini to use it to record video WHILE it's hooked to the monitor.  Does this keep the record screen ACTIVE while it mirrors the video, or is this not possible?

  • T-Code SAAB

    Hi I have set in T-Code SAAB the Checkpoint Group WF_SYSTEM_OTHERS and created a new Variant ZTEST and have activated both. In the variant I have set up FUnctiongrup BBP_PDH_WFL and BBP_WFLH. But if start SRM Web (Internet Explorer) the break point d

  • How MFG_LEAD_TIME in OE_ORDER_LINES_ALL is populated?

    How MFG_LEAD_TIME in OE_ORDER_LINES_ALL is populated?