Checking convert from AS2 - AS3

I am praticing to convert AS2 to AS3 code . Here moviclip instance name is handle_mc. Here I have AS2 code and trying to convert into AS3. Will u please look at my code of AS3. Is my code is correct ?
AS2 Code 
stop();
    var t1:Number = 0;
    handle_mc.onPress = function() {
        if (t1>=0) {
            if ((getTimer()-t1)<300) {
                popContent_mc.play();
            } else {
                _root.main.pop_mc.startDrag();
        } else {
            t1 = 0;
        var time:Number = getTimer();
        t1 = time;
    handle_mc.onRelease = function() {
        _root.main.pop_mc.stopDrag();
AS3 Code
stop();
    var t1:Number = 0;
    function press_handle_mc(event:KeyEvent)
        if (t1>=0) {
            if ((getTimer()-t1)<300) {
                popContent_mc.play();
            } else {
                _root.main.pop_mc.startDrag();
        } else {
            t1 = 0;
        var time:Number = getTimer();
        t1 = time;
    function click_handle_mc(event,MouseEvent)
        root.main.pop_mc.stopDrag();
    handle_mc.addEventListener(KeyEvent.PRESS,press_handle_mc);
    handle_mc.addEventListener(MouseEvent.CLICK,click_handle_mc;

No, you still have AS2 code elements in your AS3 code.  If you really are trying to learn this, and not just seeing if you can get people to do your design work for you, then you should be running the code, seeing what errors occur, and then researching how to fix them one at a time.  The compiler will be happy to tell you where you have problems.  That is how you will learn it.

Similar Messages

  • Please help convert from as2

    I never learnt as2 and I just purchased a fla file from a stock sight thinking it was in as3 and it isn't!!! doh
    can anyone help me convert this from as2 to as3:
    stop();
    import flash.filters.*;
    //--------------variables to change--------------------------//
    //set this value to true if you want sparkles to be created from the mouse
    //and false if you want automatic sparkles
    var createSparklesFromAnyMouse:Boolean = true;
    //set to true if you want sparkles to stop being created when the mouse
    //is still
    var createSparklesFromClick:Boolean = false;
    //modify the size of the sparkles
    var maxSparkSize:Number = 18;
    var minSparkSize:Number = 8;
    //increase this value to shorten the life, 0 to live forever
    var fadeSpeed:Number = 10;
    //the speed the sparkles fall, higher number quicker the speed
    var speed:Number = 1;
    //choose whether you want the sparkle colour to be random
    var randomColour:Boolean = true;
    //if you don't want a random colour pick a default colour
    defaultColour = 0xFFffFF;
    //do not modify code below here...
    var sparkle:Number = 0;
    var mousePosX:Number;
    var mousePosY:Number;
    var whichBat:Number;
    var count:Number = 0;
    this.createEmptyMovieClip("empty",this.getNextHighestDepth());
    howToCreate();
    function howToCreate() {
              if (createSparklesFromClick == true) {
                        trace("create sparkles every time I click the mouse");
                        //create sparkles from mouse clicks
                        activateClick();
              } else {
                        if (createSparklesFromAnyMouse == true) {
                                  trace("create sparkles from the mouse");
                                  //create sparkles from the mouse
                                  this.onEnterFrame = function() {
                                            createSparkle();
                                            createSparkle();
                        } else {
                                  trace("create sparkles every time I move the mouse");
                                  //create sparkles ONLY when the mouseMoves
                                  createWhenMoving();
    function createWhenMoving() {
              this.onEnterFrame = function() {
                        if (mousePosX != _root._xmouse && mousePosY != _root._ymouse) {
                                  createSparkle();
                        mousePosX = _root._xmouse;
                        mousePosY = _root._ymouse;
    function activateClick() {
              empty.onMouseDown = function() {
                        this.onEnterFrame = function() {
                                  createSparkle();
              empty.onMouseUp = function() {
                        delete this.onEnterFrame;
    function createSparkle() {
              movingSparkle = this.attachMovie("colouredSparkle", "s_"+sparkle, sparkle);
              movingSparkle2 = this.attachMovie("colouredSparkle", "ss_"+sparkle, sparkle+100);
              sparkle++;
                        if(sparkle>100){
                        sparkle = 0;
              setParams(movingSparkle);
              setParams(movingSparkle2);
    function setParams (movingSparkle){
              movingSparkle._x = _root._xmouse+randRange(-8, 8);
              movingSparkle._y = _root._ymouse+randRange(-15, 0);
              movingSparkle._xscale = movingSparkle._yscale=Math.random()*maxSparkSize+minSparkSize;
              movingSparkle._rotation = randRange(0, 360);
              if (randomColour == true) {
                        col = Math.round(Math.random()*0xFFFFFF);
              } else {
                        col = defaultColour;
              colouredFill = new Color(movingSparkle.colour_mc);
              colouredFill.setRGB(col);
              colouredFill = new Color(movingSparkle.white_mc);
              colouredFill.setRGB(col);
              moveSparkle(movingSparkle);
    function moveSparkle(movingSparkle) {
              var ySpeed = randRange(0, speed);
              var rot = randRange(-15, 15);
              var blurX = randRange(2, 5);
              var blurY = blurX;
              var blurFilter = new BlurFilter(blurX, blurY, 3);
              movingSparkle.white_mc.filters = [blurFilter];
              movingSparkle._alpha = randRange(85, 100);
              var alphaDrop = randRange(1, fadeSpeed);
              movingSparkle.onEnterFrame = function() {
                        //change speed
                        this._y += ySpeed;
                        //change rotation
                        this._rotation = this._rotation+rot;
                        //make it smaller
                        this._xscale = this._yscale=this._xscale*0.98;
                        //fade the sparkle
                        this._alpha = this._alpha-alphaDrop;
                        //remove the movieclip if it get tiny
                        if (this._alpha<10) {
                                  this.removeMovieClip();
                                  delete this.onEnterFrame();
                        if (this._height<4) {
                                  this.removeMovieClip();
                                  delete this.onEnterFrame();
    function setColour(mc, col) {
              colourIt = new Color(mc);
              colourIt.setRGB(col);
    function randRange(min:Number, max:Number):Number {
              var randomNum:Number = (Math.random()*(max-min))+min;
              return randomNum;

    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.

  • Can This be Converted from CS4 AS3 to Flash8 AS2?

    Is This Possible To Work In Flash8 AS2?
    import flash.events.Event; addEventListener(Event.ENTER_FRAME, update); var accel = 2 var speed = 0.06 var friction = 0.94 function update(e:Event):void { if (mouseX>400){body.fridge.rotationY += speed + accel} if (mouseX<100){body.fridge.rotationY += speed - accel} if (mouseY<100){body.fridge.rotationX += speed + accel} if (speed>2){speed = 2} if (speed<-2){speed = -2} body.fridge.rotationY *= friction body.fridge.rotationX *= friction }

    no.  flash8 doesn't support 3d manipulation of 2d objects.

  • Rotating knob from AS2 -- AS3 help please

    I'm trying to create a rotating knob that a User can turn
    with the mouse. The initial code worked in AS2 but the rest of my
    project is in AS3. so I started to convert it over (with help) Can
    anybody help make it work in AS3?
    I'm sure the "update Advent" is incorrect. also i would like
    to have the knob only able to rotate 180 deg from initial position.
    I'm thinking i need to fid the initial x,y position and the final
    x, y position and use those as bounderies but not sure if there is
    a way to do it with rotation<180 type of thing. thank you in
    advance for any help, or direction.

    kglad
    can you help me with something so simple that im embarrised
    to mention it :) i can't figure out what i'm doing wrong i have a
    button in a child movie clip and im trying to control another movie
    movie clip, that is also a child of the same main moive clip with
    no luck, i use the "insert target path" but when i try to run test
    the flash it gives me a error " the Toggle_up button was clicked
    TypeError: Error #1010: A term is undefined and has no
    properties.
    at controlpanel_demo_fla::Switch_Air_18/clickButton()"
    any ideas sorry to bother you again

  • Issues converting scroll bar components from AS2 to AS3

    I am working on editing a document that has scroll bar components that I would like to convert from AS2 to AS3 since everytime I try to open the document it shows a WARNING and won't convert them and when I publish and look at the final document the scroll bar seems to act unusally since it is obviously still on AS2.
    Here are two of the scripts I finally was able to find within it. Should I fix it and how so? This first is for the "Creative Scroll Area" and the second is for the "Creative Scrollbar"
    package  {
              import flash.display.MovieClip;
              public class Creative Scroll Area extends MovieClip {
                        public function Creative Scroll Area() {
                                  // constructor code
    package  {
              import flash.display.MovieClip;
              public class Creative Scrollbar extends MovieClip {
                        public function Creative Scrollbar() {
                                  // constructor code

    Okay, well I know the code is making a scroll bar and a scroll area and under the "type" it says they are "compiled..." which is unusual since most of the other components I've worked with have been movie clips or bitmaps. Do I need to look up what AS3 components I need to replace the script from above? Because when I looked for that I couldn't specifically find what I needed or really understood if I was looking at the right information.
    Here is something I found when trying to "debug" it:
    WARNING: The component 'UIScrollBar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scrollbar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scroll Area' requires ActionScript 2.0, which is not supported in this version of Flash Professional.

  • Non video Seekbar code in as2. Can someone convert it to as3?

    Hi all,
    I am a newbie in Flash. Found a code from somewhere that is written to use seekbar to control the complete timeline in as2. Just need help from somone to convert it into as3.
    This code is placed in the slider button that is held to move forward or back the animation.
    on (press)
        dragging = 1;
        _parent._parent.stop();
        _parent._parent.ani.stop();
        _parent._parent.roll.ps.gotoAndStop(2);
    on (release, releaseOutside)
        dragging = 0;
        if (_parent._parent.st == 1)
            _parent._parent.roll.ps.gotoAndStop(1);
            _parent._parent.play();
            _parent._parent.ani.play();
        } // end if
    This function is placed in a symbol that contains a slider, named mcslider. It works perfectly in as2.
    function min(cfr)
        cframe = cfr;
        smod = cframe / 30;
        seco = Math.floor(smod);
        minut = seco / 60;
        minu = Math.floor(minut);
        if (minu < 10)
            minute = "0" + minu;
        else
            minute = minu;
        } // end else if
        return (minute);
    } // End of the function
    function sec(cfr)
        cframe = cfr;
        smod = cframe / 30;
        seco = Math.floor(smod);
        minut1 = seco % 60;
        minu1 = Math.floor(minut1);
        if (minu1 < 10)
            second = "0" + minu1;
        else
            second = minu1;
        } // end else if
        return (second);
    } // End of the function
    i = 0;
    seco = 0;
    m_e = 0;
    s_e = 0;
    minute = 0;
    second = 0;
    mtotal = 0;
    onEnterFrame = function ()
        total = _parent._totalframes;
        knob._x = _parent._currentframe * segmentWidth - segmentWidth;
        cfr = _parent._currentframe;
        s_e = sec(cfr);
        m_e = min(cfr);
        s_e1 = sec(cfr);
        m_e1 = min(cfr);

    var tl:MovieClip=this;
    tl.addEventListener(Event.ENTER_FRAME,enterframeF);
    paramF(tl,1,0,tl.totalFrames,slider.track.width);  // create a horizontal slider movieclip that contains a track movieclip and a thumbscroll movieclip that do the obvious and have left-sided reg point
    paramF(slider,0,1,slider.track.width-slider.thumbscroll.width,tl.totalFrames);
    var scrollRect:Rectangle=new Rectangle(0,0,slider.track.width-slider.thumbscroll.width,0);
    function enterframeF(e:Event):void{
    slider.thumbscroll.x=tl.m*tl.currentFrame+tl.b;
    slider.thumbscroll.addEventListener(MouseEvent.MOUSE_DOWN,scrolldownF);
    slider.thumbscroll.addEventListener(MouseEvent.MOUSE_UP,scrollupF);
    function scrolldownF(e:MouseEvent):void{
    tl.removeEventListener(Event.ENTER_FRAME,enterframeF);
    slider.thumbscroll.startDrag(false,scrollRect);
    slider.addEventListener(Event.ENTER_FRAME,scrollF);
    function scrollupF(e:MouseEvent):void{
    tl.addEventListener(Event.ENTER_FRAME,enterframeF);
    slider.thumbscroll.stopDrag();
    slider.removeEventListener(Event.ENTER_FRAME,scrollF);
    function scrollF(e:MouseEvent):void{
    tl.gotoAndStop(Math.round(slider.thumbscroll.x*slider.m+slider.b));
    function paramF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):void{
    mc.m=(y1-y2)/(x1-x2);
    mc.b=y2-mc.m*x2;

  • Convert code AS2  to  AS3

    Plz any one convert this code from AS2 to AS3???????reoly me on [email protected]
    #initclip
    function Dot() {
        this.color = new Color(this);
        this.color.setRGB(16775372);
        this._rotation = 150;                        /////////////////rotate of object////////////////
        this._width = 30;                        /////////////////width of object////////////////
        this._height = 30;                            /////////////height of object//////////////
        this._x = 300+Math.random();//*8-0(X vibration type effect)            /////////////X position of object//////////
        this._y = 250+Math.random();//*8-0(Y vibration type effect)            /////////////Y posotion of object///////////   
    Dot.prototype = new MovieClip();
    Object.registerClass("myfirst", Dot);
    Dot.prototype.onEnterFrame = move;
    function move() {
        this.age++;
        this.relage=this.age/12;
        R=255<<16;
        G=(255-(this.relage*126)); if (G<0) G=0; G=G<<8;
        B=(255-(this.relage*1024)); if (B<0) B=0;
        this.color.setRGB(R+G+B);
        this._x -= Math.random()*-2-1.25;
        this._y -=Math.random()*+1.75;
        this._alpha -= 3;
        this._xscale -= 2;
        if (this._alpha<5) {
            this.removeMovieClip();
    #endinitclip

    Just remove #initclip and #endinitclip from the code and remove all underscores, example : this._x will be this.x
    Hope this helps!

  • Declare new color from AS2 to AS3

    Hi All,
    Could you let me know how to "convert" the following code from AS2 to AS3:
    var distracterBkgdColor = new Color(this.distracterBkgd_mc);
    Thanks!

    var ct:ColorTransform = this.distracterBkgd_mc.transform.colorTransform;ct.color = 0xrrbbgg;
    this.distracterBkgd_mc.transform.colorTransform=ct;

  • 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).

  • Please help 'Translate' These codes from AS2 to AS3 for me

    Hi, i need help 'translating' these codes from Action Script 2 to Action Script 3. Please Do it for me:
    toc    loadText = new LoadVars();
        loadText.load("Curie.txt");
        loadText.onLoad = function(success) {
            if (success) {
                // trace(success);
                Curie.html = true;
                Curie.htmlText = this.Curie;
    Please translate it for me, i need it ASAP thanks
    Kenneth

    Thank you for helping me
    Kenneth
    Date: Thu, 15 Oct 2009 05:49:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: Please help 'Translate' These codes from AS2 to AS3 for me
    Take a look at that:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
    There is a LoadVars section on that.
    There is also a tutorial here:
    http://www.republicofcode.com/tutorials/flash/as3externaltext/
    Cheers,
    CaioToOn!
    >

  • Major gaming system Migration from AS2 to AS3

    I have a major project entirely in AS2. It is made of a
    Multimedia Application, which provides access to functions needed
    to load games, save information, insert *.jpg files... The 50+
    games each have their own graphic.swf and engine.swf, where the
    graphics deal with gameplay and the engine communicates with the
    Multimedia Application.
    If the Multimedia Application is migrated to AS3 but the game
    swf files remain the same, will the functions still be able to
    communicate (call functions and send references to objects)?

    No, AS2 and AS3 are absolutely different animals. There are
    some techniques (search for as2 as3 bridge in the net) that create
    a bridge which are cumbersome in my view.

  • Load failed due to Overflow converting from 853156+16

    Hi All,
    Load is getting failed from one DSO to another DSO with following error message. and its AP AR load
    Runtime error while executing rule -> see long text
    Message no. RSTRAN301
    Diagnosis
    An error occurred while executing a transformation rule:
    The exact error message is:
    Overflow converting from '8.85315e+16'
    The error was triggered at the following point in the program:
    Z_BFOD_A_AR_LOOKUP_ITEM_E 278
    System Response
    Processing the data record has been terminated.
    Procedure
    The following additional information is included in the higher-level node of
    the monitor:
    Transformation ID
    Data record number of the source record
    Number and name of the rule which produced the error
    Thanks,
    Asim

    Hey,
    Ask the developer that wrote the end routine to check the code where the error occurs. First check if too much data is transferred and if it can be reduced. Then also check if the object needs to be extended 460652 - Extending key figures in BW.
    Regards,
    Michael

  • Unable to install iTunes after converting from Windows Vista to Windows 7.  Am told installation was successful, then "iTunes was not installed correctly", followed by "Error 7 (Windows error 193).

    Unable to install iTunes after converting from Windows Vista to Windows 7.  Am told installation was successful, then "iTunes was not installed correctly", followed by "Error 7 (Windows error 193).  I have my iPod plugged into my computer via USB port.  What am I doing wrong?

    i have the only account on my laptop so have checked and am the account administrator
    i run windows 7 home premium
    I have the same problem and
    have followed the link uninstalling in the correct order,
    then restarted as per instructions,
    went to Apple to download itunes,
    hit download now,
    Visit the iTunes download page. Click Download Now to download the iTunes installer. When prompted, click Save (instead of Run).
    did not get a save instead of run prompt
    Right click on iTunesSetup or iTunes64Setup (the installer you downloaded in step 3).
    If you have Windows Vista, Windows 7, and Windows 8: Choose "Run as administrator."
    i can only click run as administrator from right clicking the shortcut on my desktop screen
    If iTunes fails to install or repair, it might be necessary to remove components left from a previous installation of iTunes and then reinstall.
    sick of doing this
    at least 7 or 8 times i have re installed itunes to no avail
    troubleshooting no better
    please help. pulling my hair out at this stage
    it was working fine until 2 days ago when i opened itunes it offered to update to 12.1
    not working since i clicked yes
    also i have gone to restore previous point and ffs there are no restore points before my multiple reinstalls
    really dont want to have to restore factory settings

  • I'm trying to hi-light objects and text in a pdf converted from a cadd drawing but can't do either?

    I'm trying to hi-light objects and text in a pdf converted from a cadd drawing but can't do either?

    Hi blueteam,
    Please check :http://www.wikihow.com/Highlight-Text-in-a-PDF-Document
    Regards,
    Rave

Maybe you are looking for

  • OFT- Problem while Playback in Oracle Apps 11i

    hi, As earlier Oracle E-biz Application are not working in OFT8.5 but now in the latest version OFT9.0 as per the information it will work fine. But i'm facing the problem while playback the Oracle E-biz Application. I have recorded Order Management

  • Combine pdf + html files

    Hello I am familiar with how to combine several pdfs into one pdf, and I love the Bookmarks as a built-in navigation panel for my project. Now I'm trying to integrate the next step.  My goal is a cd with 3 items in the navigation panel:  book 1 (from

  • My selection tool don't work normally !

    My selection tool won't select swatch colours and I can't move easily text boxes. I "trash" my InDesign preferences. I follow Peter Spier's advice. I put the line in my terminal : rm /Users/petitspaspourlhomme/Library/Caches/Adobe InDesign/Version 8.

  • In PP Interface related issues the role of functional consultant

    In PP Interface related issues what is the role of functional consultant .  what is the approach steps to analyse and resolve the issues  in XI, interface, idoc, etc.,

  • Multiple domain names

    Can you have multiple domain names for your website? I thought that you could, but I don't know how to use dreamweaver do this. I'm using a host that has both of my domain names, and they use the same login and password. I wonder if this is the probl