To AS2 AS3, need help.

I learned Flash using AS2 and I try now migrate to AS3, but some of the simplest things have changed.  I know I can't put script directly on movieclips now, but I do not know how to use if the conditions to check for movieclips hit some frames, etc.

Can someone direct me to the tutorials on the displacement of AS2 AS3 and some of the fundamental behaviors of AS3.

For example:

If I had a movieclip I used as a button and I tried jumping a specific image when another movieclip on the stage struck a framework?  With AS2, I could simply put a script on the movieclip itself that says something like:

onClipEvent (EnterFrame)

{

If (this ._currentframe is 10)

{

_parent.sampleClip.gotoAndStop (2);

}

}

I don't know how to do simple same navigation like this in AS3 code.

Thanks for the help.

There are a lot of tutorials and a few great books too. For tutorials that you probably want just a search on any specific problems that you find. Regarding the example you gave, it is a little different in 3 and also better:

someMovieClip.addEventListener (Event.ENTER_FRAME, checkFrame);
function checkFrame(e:Event) {}
if(someMovieClip.currentFrame == 10) {}
sampleClip.gotoAndStop (2);
}
}

I say better because you don't need to worry about scope as you did in 2 - checkFrame is not executed in the context of the someMovieClip - sampleClip is available directly, you don't need to 'parent' to access.

Tags: Adobe Animate

Similar Questions

  • Plan a game in AS3, need help

    Hi so I'll make quite a big game/app in AS3 and I need someone to point me in the right direction, I know as3 and have programmed many games.

    This game will include multiplayer and we're going to do this, use smartFox.

    Now the area I need some information on are servers to hold the details of the player. (Level etc., species)

    First of all:

    How to set up a server? Use MySQL? Is a Web page that I can connect to my game?

    How would I connect to it via AS3? I have to use SELECT MySQL and MySQL files to find the player and then send back it details?

    Basically, I need to know how the games as configuration servers FarmVile to contain details of the player because I have to do the same thing for this game.

    It's really how to get data to the game to you. When you use classes like URLLoader you can send variables (via GET or POST) on the server to authenticate and process your application. At that time then your PHP script is responsible to read the request and to answer with the information however you like it.

    For your first game, that I would recommend you stick with very structures known as XML or JSON for responses from your PHP scripts.

    For example, if you use JSON, first configure you your application in AS3, to say things that you receive text gross (binary or varying URL) return code. Your PHP script receives the request, performs the necessary operations (on the basis of data, etc.) to get the information you need. He is then responsible for structuring this back to what awaits Flash (JSON) and as you probably know PHP has built-in JSON (http://php.net/JSON) encoding. After your response of crafts and print, AS3 that will consider a response. Can you decode side AS3 as JSON and use the information according to your needs.

    Finally in the future when your game balance grows, you can start making web services which manage more efficient binary formats such as the authority of the financial markets. Then you can do it with the standard messages is not even worth performance wise. Also, you will go from HTTP requests to direct applications of socket. If your game is standard you can even use web based RESTful services so look at those if you're not familiar.

    Yes, you will need a host, but I can't recommend one because I have no idea what you're building. If you plan to build an MMO so no web host will really make you account inexpensive cluster hosted for this scale of a game. If it's just tracking the leader boards and user accounts then I often use hosts that adapts to of lowercase/cheap dedicated using my own equipment, like site5.com.

  • AS3: need help to solve a problam function

    Hey, I need your help once again.

    I have a wheelchair clip that I want to just move left and right in a loop, I have this code:

    var wheelChairRightTimer:Timer = new Timer (120,24);
    var wheelChairLeftTimer:Timer = new Timer (120,24);

    wheelChairRightTimer.addEventListener (TimerEvent.TIMER, moveRight);
    wheelChairRightTimer.addEventListener (TimerEvent.TIMER_COMPLETE, startMoveLeft);
    wheelChairLeftTimer.addEventListener (TimerEvent.TIMER, moveLeft);
    wheelChairLeftTimer.addEventListener (TimerEvent.TIMER_COMPLETE, startMoveRight);

    wheelChairRightTimer.start ();

    function moveRight(event:TimerEvent):void {}
    wheelChair.x = wheelChair.x + 20;
    }

    function moveLeft(event:TimerEvent):void {}
    wheelChair.x = wheelChair.x - 20;
    }

    function startMoveLeft(event:TimerEvent):void {}
    wheelChairLeftTimer.start ();
    }

    function startMoveRight(event:TimerEvent):void {}
    wheelChairRightTimer.start ();
    }

    The problam is with the last function "startMoveRight". Without this feature the wheelchair goes right and left as he should and everything stops. I added the last function loop the movment, but after the first round of movment left and right (which works well), it seems that all 4 functions are called together so the wheelchair is battery mobile 20 px right and left 20 px.

    I know this probably isn't the best way, in other ways, or just a way to fix this will help a lot!

    This should do it:

    // speed
    var vx:Number = 20;
    
    var chairTimer:Timer = new Timer(120);
    chairTimer.addEventListener(TimerEvent.TIMER, moveChair);
    chairTimer.start();
    
    function moveChair(e:TimerEvent):void {
         wheelChair.x += vx;
         if (chairTimer.currentCount % 24 == 0) {
              // change direction
              vx *= -1;
         }
         e.updateAfterEvent();
    }
    

    Post edited by: Andrei1

  • New to AS3 needing help with the key

    OK Im a newb full when it comes to AS3.  Here's what I'm trying to accomplish, I try to make my link button to another page of mine and it loads into the central computer of the original source page.  I found some code to bind the button to a Web site or else my page, but it just opened another window and as previously indicated, I want it to load into the central computer, the button is in the left frame.  Any help would be great, here is the code I use to bind.

    aboutbtn.addEventListener (MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function mouseDownHandler(event:MouseEvent):void {}
    navigateToURL (new URLRequest (". (("/ aboutus.htm '));
    }

    Thanks in advance for the help

    You beat me to it: Yes, it was the parenthesis.

  • Charger (need help to convert AS2 AS3)

    Because I know that this code works very well and that I use it in one of my flash AS3, I need it in one of my flash AS2 and I do not know how to adapt. I searched more than 100 threads and I can not find something similar... Thank you to help me make it work in AS2! As I need in AS2, I thought it would be the right place to post.

    I posted the entire process of loading code, but I need help especially with the charger part. How to do this in AS2? Thank you!

    var img = 0;
    var image_total = 0;

    var myImages_array:Array = new Array();
    var myBitmaps_array:Array = new Array();

    function Init();

    {

    Image URLS is loaded into a table before this call
    LoadImage();

    }


    function LoadImage()
    {
    If (img, myImages_array.length) / / img is the index of the current image and myImages_array is my URL table
    {

    I need help with this framework, you can
    var loader: Loader = new Loader();

    / / Returns the full path of the image and load it
    Loader.Load (new URLRequest (my_site_url + myImages_array [img]));
    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, imageLoaded);

    }
    on the other
    {
    If (count == 0)
    {

    When everything is loaded, I'll start loading my Bitmaps in a short slide show
    Count += 1;
    init_slideshow();
    }
    }
    }

    function imageLoaded(e:Event):void
    {
    Bitmap of the image: var = e.target.content;

    Bitmap manipulation (deleted) here

    image_total = myBitmaps_array.push (image);

    If (img < myImages_array.length)
    {
    IMG += 1;

    Call the following image
    LoadImage();
    }
    }

    function init_slideshow (): void
    {

    The current index for the first Reserts
    IMG = 0;

    Start the slide show, since everything is loaded
    animate_slideshow();
    }

    Look at the MoveClipLoader class and the addListener method that supports.

  • Need help with as2 as3 conversion. Please, I beg you.

    Could someone help me to convert as2 as3, please?

    Source code:

    _root.magnet = 500;
    _root.magic = 10;

    and

    onClipEvent (load)
    {
        homex = this._x;
        homey = this._y;
        forcex = 1;
        forcey = 1;
    }
    onClipEvent (enterFrame)
    {
        x0 = this._x;
        y0 = this._y;
        x1 = this._xmouse;
        y1 = this._ymouse;
        distancex = x1 - x0;
        distancey = y1 - y0;
        distance = Math.sqrt(distancex * distancex + distancey * distancey);
        powerx = this._x - distancex / distance * _root.magnet / distance;
        powery = this._y - distancey / distance * _root.magnet / distance;
        forcex = (forcex + (homex - x0) / 2) / _root.magic;
        forcey = (forcey + (homey - y0) / 2) / _root.magic;
        this._x = powerx + forcex;
        this._y = powery + forcey;
    }

    I am a newbie in flash so if anyone can help with this would be great.

    I really need to be done please help me.

    MovieClip(root).magnet = 500;MovieClip(root).magic = 10;
    

    and

    var homex:Number = yourmc.x;var homey:Number = yourmc.y;var forcex:Number = 1;var forcey:Number = 1;
    
    yourmc.addEventListener(Event.ENTER_FRAME, loopF);
    
    function loopF(e:Event){    var x0:Number = e.currentTarget.x;    var y0:Number = e.currentTarget.y;    var x1:Number = e.currentTarget.mouseX;    var y1:Number = e.currentTarget.mouseY;    var distancex:Number = x1 - x0;    var distancey:Number = y1 - y0;    var distance:Number = Math.sqrt(distancex * distancex + distancey * distancey);    var powerx:Number = e.currentTarget.x - distancex / distance * MovieClip(root).magnet/distance;    var powery:Number = e.currentTarget.y - distancey / distance * MovieClip(root).magnet/distance;    forcex = (forcex + (homex - x0) / 2) /MovieClip(root).magic;    forcey = (forcey + (homey - y0) / 2) / MovieClip(root).magic;    e.currentTarget.x = powerx + forcex;    e.currentTarget.y = powery + forcey;}
    
  • Need help w / skip intro AS3 code

    Hello world!

    I'm building a site that needs an intro.

    I have everything set up for the intro and the main site on the same file; Intro is a scene and website is another.

    I made a text, converted to the symbol, the name of the instance of "skip_btn" and placed just after the start of the animation timeline.

    Shortly before the end of the animation, the "skip" button disappears, and in its place a button 'enter site'; It's in the same place, but it has a different instance name: "enter_btn."

    I use this code for the "skip" button (and by editing a little, I would like to use it for the button 'enter site' as well):

    skip_btn.addEventListener (MouseEvent.CLICK, skipIntro);

    function skipIntro(event:MouseEvent):void {}

    gotoAndPlay ("site", 1);

    }

    And I get this error:

    1067: constraint implied a value of type int to type String unrelated.

    I placed the code on the first frame of the ActionScript layer that lies on the other layers and the action 'stop' to the last image.

    I attach the project file so that everyone can check to detect the error.

    I appreciate your help.

    Thank you very much.

    JC

    If you are familiar with AS2, AS3 reverses the order of the arguments to the function gotoAndPlay...

    skip_btn.addEventListener (MouseEvent.CLICK, skipIntro);

    function skipIntro(event:MouseEvent):void {}

    gotoAndPlay (1, "site");

    }

    In addition, you can probably use the same function of skipIntro as that is for the Enter key.  You only need to create the listener for it.

  • AS2 AS3 help.

    Hi guys.

    I had a major problem when trying to convert an old AS2 AS3 code.

    It would be great if you guys can help in anyway you can.

    What I try to do is, load in a clip again and again to create a rain effect, the clip is a drop of falling rain.

    I need for the MovieClip name is also updated every time. For example, Name1, name2, Name3, name4 ect

    AS2 code:

    {onClipEvent (load)}

    _root.d_counter = 1;

    }

    {onClipEvent (enterFrame)}

    If () {}

    _root.attachMovie ("particles", "particle", + _root.d_counter, _root.d_counter, {_x:0, _y:0});})

    _root.d_counter = _root.d_counter + 1;

    }

    }

    =====================================

    My AS3 Code:

    particle.addEventListener (Event.ADDED_TO_STAGE, loaded);
    function loaded(event:Event):void {}
    var _counter:Number = 1;
    }
    particle.addEventListener (Event.ENTER_FRAME, entered);
    function entered(event:Event):void {}
    if (MovieClip (root) .d_counter < 100) {}
    MovieClip (root) .addChild (particle);
    . D_counter (root) of MovieClip is MovieClip (root) .d_counter + 1;.
    }
    }
    =====================================
    My code is close to what I want, but it does not load in multiple instances of the same object.
    Any help would be great.

    use:

    var d_counter:Number = 1;
    particle.addEventListener (Event.ENTER_FRAME, entered);
    function entered(event:Event):void {}
    If (MovieClip (root) .d_counter< 200){="">
    trace ("Yes");
    rain in the var: MovieClip = new Particle();
    Rain.x = Math.Random () * stage.stageWidth;
    MovieClip (root) .addChild (rain);
    . D_counter (root) of MovieClip is MovieClip (root) .d_counter + 1;.
    } else {}
    remove your particles and their ready for gc
    particle.removeEventListener (Event.ENTER_FRAME, entered)
    }
    }
  • Help to convert as2 as3

    Please, I need help convert this script in as3 bellow. Thank you.

    SCREEN_WIDTH = 800

    screen_height = 200

    frequency = 0

    MovieClip.prototype.serConfeti = function () {}

    This._x = Math.ceil (Math.Random () * SCREEN_WIDTH)

    This._xscale = Math.ceil (Math.Random () * screen_height)

    This ._yscale = this ._xscale

    This.Mover)

    This.coloreame)

    }

    function getPorcentaje() {}

    var number = Math.ceil (Math.random () * 100)

    return number

    }

    getOffset() {} function

    var number = Math.ceil (Math.random () * 255)

    var buleano = Math.round (Math.random () * 1)

    If (buleano == 1) {}

    number = number * 1

    }

    return number

    }

    MovieClip.prototype.coloreame = function () {}

    var color = new Color (this)

    var nuevo_color = new Object()

    nuevo_color. RA = getPorcentaje)

    nuevo_color. RB = GetOffset)

    nuevo_color.GA = getPorcentaje)

    nuevo_color. GB = GetOffset)

    nuevo_color.BA = getPorcentaje)

    nuevo_color.BB = GetOffset)

    my_color.SetTransform (nuevo_color)

    }

    MovieClip.prototype.mover = function () {}

    this.onEnterFrame = function () {}

    If (this ._y < 600) {}

    This ._y += 10

    This ._xscale = Math.random () * 200

    This ._rotation = Math.random () * 360

    } else {}

    this.removeMovieClip)

    }

    }

    }

    MovieClip.prototype.caidaConfeti = function () {}

    this.createEmptyMovieClip("caida_mc",1)

    var count = 0

    var confCount = 1

    This.caida_mc.onEnterFrame = Function () {}

    if(Count<frecuency) {}

    Count ++

    } else {}

    this.attachMovie ("conf", "conf" + confCount, confCount)

    eval("this.caida_mc.conf"+confCount).serConfeti)

    Count = 1

    confCount ++

    }

    }

    }

    //

    _root.caidaConfeti)

    see if it's what you want:

    var screen_width:int = 800;

    var screen_height:int = 200;

    var frecuency:int = 0;

    function coloreame(mc:MovieClip):void { / / can't tell what is your coloreame but try this. }

    var ct:ColorTransform = mc.transform.colorTransform;

    CT. Color = 0xffffff * Math.random ();

    mc.transform.colorTransform = ct;

    }

    function serConfeti(mc:MovieClip):void {}

    MC.x = Math.ceil (Math.random () * screen_width);

    mc.scaleX = mc.scaleY = Math.ceil (Math.random () * screen_height);

    Mover (MC);

    coloreame (MC);

    }

    function mover(mc:MovieClip):void {}

    mc.addEventListener (Event.ENTER_FRAME, moverF);

    }

    function moverF(e:Event):void {}

    var mc:MovieClip = MovieClip (e.currentTarget);

    If (mc.y<>

    MC.y += 10;

    mc.scaleX = Math.random () * 200;

    MC.rotation = Math.random () * 360;

    } else {}

    mc.removeEventListener (Event.ENTER_FRAME, moverF);

    mc.parent.removeChild (mc);

    }

    }

    function caidaConfeti(mc:MovieClip):void {}

    var caida:MovieClip = new MovieClip();

    Caida.Count = 0;

    caida.confCount = 1;

    mc.addChild (caida);

    caida.addEventListener (Event.ENTER_FRAME, enterFrameF);  / / I can't tell when it has to end.

    }

    function enterFrameF(e:Event):void {}

    var caida:MovieClip = MovieClip (e.currentTarget);

    If (caida.count<>

    Caida.Count ++;

    } else {}

    var conf_mc:MovieClip = new conf();

    caida.addChild (conf_mc);

    serConfeti (conf_mc);

    }

    }

    caidaConfeti (this);

  • Need help with AS3!

    Hello! I need help on as3. I'm still a noob at this stuff.

    I'm doing a simple game. You must click on the bugs that moves randomly to the bottom of the screen. When you click on the bugs, they will become invisible

    and if none of the bugs through the bottom of the screen, you lose 1 live.

    But right now, im of the problems with the script. When I click on the bugs and she go, life is further reduced. I don't understand.

    And theres also error coming out. "TypeError: Error #1009: cannot access a property or method of a null object reference."

    " to buh_fla::MainTimeline/tekan().

    Here is the script:

    ===================================

    Stop();

    import flash.events.Event;

    import flash.events.MouseEvent;

    var iscore:int = 0;

    score. Text = iscore.toString ();

    var health: int;

    health = 3;

    trace (Health);

    for (var i: int = 0; i < 10; i ++) {}

    var f: bug = new bogues();

    addChild (f);

    var fn = Math.round (Math.random () * 2) + 1;

    f.gotoAndPlay (fn);

    f.x = Math.random () * stage.stageWidth;

    f.SP = Math.random () * 7;

    f.addEventListener (Event.ENTER_FRAME, animate);

    f.addEventListener (MouseEvent.CLICK, klik);

    }

    function klik(e:MouseEvent) {}

    e.target.visible = false;

    iscore += 1;

    score. Text = iscore.toString ();

    }

    function animate (e: Event) {}

    e.Target.y += e.target.sp;

    if(e.Target.y > stage.stageHeight) {}

    -health;

    trace (Health);

    e.Target.y = - 20;

    e.Target.Visible = true;

    {if(health==0)}

    gotoAndPlay ("gameover")

    }

    }

    }

    ============================================

    You lose life because you are not to remove bugs or their listener but only making them invisible

    function klik(e:MouseEvent) {}

    e.Target.Visible = false;

    iscore += 1;

    score. Text = iscore.toString ();

    to this code

    var delbug = e.currentTarget
    delbug (Event.ENTER_FRAME, animate) .removeEventListener;

    removeChild (delbug)

    }

    --

    http://ww.darshanrane.com

  • Need help with a simple basketball game.

    Hi im new here and I need help with what makes this simple basketball game.

    Im trying to recreate this this video game. I'm not sure if it uses as2 or as3

    If someone could help me make a game like this or point me to a link on how to do it would be greatly appreciated.

    AS2 is used in the video.  If you have other issues, please post in the forum AS1/AS2.

  • actions AS2 as3 scripts

    can someone help me to get comparable to as2 as3 actions? as

    1. "Loadmovie" on different levels. Level 0, level 1, etc.

    2 in, click on "loadmovie".

    3 fscommand like, quiet, full screen, enable scale.

    4. on the release to go and play

    5. on the release of play and stop.

    6. play the content to the side of the clip with liberation.

    1 AS3 doesn't have a Level0, level1, etc..  You can use the Loader class to load an external swf,

    2 AS2 doesn't have any such orders - the loader allows you to load an external file.  If you want to have an insider click it then use an event listener for a CLICK MouseEvent.

    3. search Google AS3 fscommand

    4 AS3 uses the same command gotoAndStop that AS2, except that the arguments for scene/frame are reversed to frame/scene - again, happens with a click, use an event listener for a CLICK MouseEvent

    5 AS2 doesn't have any orders to play and stop, they are against orders, nor is AS3.  If you want to say stop, it's the same for both except, once again, the order of the arguments

    6. This would be the same in AS2 where you target the movieclip using the dot notation and tell the play() - once again, using an event listener for a CLICK MouseEvent.

    Explaining the AS3 button Code
    --------------------------

    Assume that you create a button symbol.  Since this is a button, it is already a car animation object that will react to mouse interactions, but only visually at this stage.  The first thing you need to do to make it useful down must assign a unique instance name.  If you drag a copy of it on the stage of the library, and while it is still selected, enter you this unique instance for her name in the Panel properties... say you name "btn1.

    In AS3, to make a button with the code, you must add a listener of events and event handler for it function.  You may need to add a little (for different events, like reversal, deployment, by clicking on it, but for now let's just say you want to be able to click them to get a web page.)  In the scenario that contains this button, a layer of separate actions that you create in a similar framework where this button exists, numbered, you must add the event listener:

    Btn1.addEventListener (MouseEvent.CLICK, btn1Click);

    The name of the unique function for the treatment, the click of this button is specified at the end of the assignment of event listener, so now you just have to write this function:

    function btn1Click(evt:MouseEvent):void {}

    var url: String = "http://www.awebsite.com/awebpage.html";

    var req:URLRequest = new URLRequest (url);

    navigateToURL (req);

    }

    Here's what this is:

    evt:MouseEvent - event listeners get an argument automatically the function should be implemented to receive.  In this case I just this argument a name of variable evt, although I could choose anything.

    : Sub - this defines the class of the value that the function returns.  In this case, the function does not return anything, so "Sub" is used.  If she returned a value, you will see a line that contains "return xyz." in the function (where xyz is not literal, it represents just the variable or the value returned)

    The normal code that opens a web page contains three distinct elements, the url, the application and command to get the page, so I showed in three separate lines.  Many people combine in a single line.

    In AS3, in strict mode, it is necessary to identify the types/classes of variables being created, that's why you see: String,: MouseEvent, etc. display everywhere.

    I know it's probably clear as mud in the explanation, but I hope that it will shed some light on what you're working with.

    Now, to create another button with a single function for it, you could just drag another copy of the library, give it a unique name, say btn2, copy / paste the code from btn1 and replace "btn1" "btn2" in this code copied, adding a new url to the page, this button opens.

  • AS2 AS3 conversion please!

    Hi guys.

    I had a major problem when trying to convert an old AS2 AS3 code.

    It would be great if you guys can help in anyway you can.

    onClipEvent (enterFrame)

    {

    This;

    If (_x > 520)

    {

    setProperty (this, _x,-20);

    } / / end if

    This;

    If (_x <-20)

    {

    setProperty (this, _x, 520);

    } / / end if

    setProperty (this, _x, _x + (1.250000E + 000) Number);

    }

    In the chronology of the object in question, try:

    addEventListener (Event.ENTER_FRAME, moveX);

    function moveX(evt:Event):void {}

    If (x > 520) {}

    x = - 20;

    }

    If (x<>

    x = 520;

    }

    x += 1.25;

    }

  • Hi, I need help with my flash mp3 player

    Hi, I need help with my mp3 player, I wan't to add the pause button... Can you help me?

    I created the button I added btn_pause and it won't work.

    function soundStatus() {}

    var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded () / _root.sound_mc.sound_obj.getBytesTotal ();

    _root. Loader.loadBar._width = amountLoaded * 260;

    duration = _root.sound_mc.sound_obj.duration;

    position = _root.sound_mc.sound_obj.position;

    _root.playHead._x = position / duration * 272 + 5;

    }

    btn_play.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_pause.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj.pause ();

    };

    btn_stop.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj. Stop();

    };

    btn_fw.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == songfile.length - 1)? _Global.song_nr = 0: _global.song_nr ++;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_rev.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == 0)? _Global.song_nr = songfile. Length-1:-_global.song_nr;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

    < proposed by the mod to as3 - kglad >

    :

    function soundStatus() {}

    var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded () / _root.sound_mc.sound_obj.getBytesTotal ();

    _root. Loader.loadBar._width = amountLoaded * 260;

    duration = _root.sound_mc.sound_obj.duration;

    position = _root.sound_mc.sound_obj.position;

    _root.playHead._x = position / duration * 272 + 5;

    }

    btn_play.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_pause.onRelease = function() {}

    clearInterval (timeInterval);  you must re - set interval when the unpause button is clicked

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj. Stop()

    };

    {btn_unpause.onRelease = Function ()}

    This._parent.sound_mc.sound_obj. Start(position/1000);

    }

    btn_stop.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj. Stop();

    };

    btn_fw.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == songfile.length - 1)? _Global.song_nr = 0: _global.song_nr ++;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_rev.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == 0)? _Global.song_nr = songfile. Length-1:-_global.song_nr;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

  • Conversion function XML AS2 AS3

    Hi guys, how are you?

    Once again I m here to ask for your help.

    I m trying to convert an AS2 AS3 script, but I m not good in AS3 síntax yet. I Don t know how to create this structure. Please, could someone help me?

    xml:
    
    <resources>
    
             <levelTitle1>Iniciante</levelTitle1>
              <levelTitle5>Aprendiz</levelTitle5>
              <levelTitle10>Aspirante</levelTitle10>
              <levelTitle15>Recruta</levelTitle15>
              <levelTitle20>Experiente</levelTitle20>
              <levelTitle30>Profissional</levelTitle30>
              <levelTitle50>Star</levelTitle50>
              <levelTitle70>Ás</levelTitle70>
              <levelTitle90>Campeão</levelTitle90>
              <levelTitle120>Lenda</levelTitle120>
    
    </resources>
    
    
    AS2 Function:
    
    public static function getLanguage(tag:String):String
    {
               if (languageObject[tag].data){
    
    
                        return slanguageObject.resources[tag].data;
               }
                 return "Error";
     }
    

    I can´t find a way to work in as3 without the parameter 'data '.

    I want to call this as2 function, pass "levelTitle30" to the "tag" parameter and return by the return of the function of the content of "levelTitle30" of the xml tag.

    Kind regards

    is your code xml in an external file?

    If so, (for example, resources.xml), you would use:

    var xml

    var urlLoader:URLLoader = new URLLoader();

    urlLoader.addEventListener (Event.COMPLETE, completeF);

    urlLoader.load (new URLRequest ("resources.xml"));

    function completeF(e:Event):void {}

    XML = e.Target.Data;

    }

    public static function getLanguage(tag:String):String{
    if(xml[tag]){
    return xml[tag];

    } else {
    return "Error";
    }
    }

Maybe you are looking for

  • 'Create a Windows 7 or a later version installation disc' does not appear as an option to select tasks

    I have a MacBook Pro (15 inch, late 2011) race El Capitan.  I just installed a new hard drive and am trying to install Windows 7 using Boot Camp Assistant.  In the window select tasks 'Create a later version or Windows 7 installation disk' does NOT a

  • Option Clean-Install for Windows 7

    I think that's what it's called. You know, the one where he deletes everything? Yes, that one. That's what I did for my HP Pavilion dv6t laptop when I've upgraded Windows Vista to Windows 7. I think that this messed up some of my installed software a

  • Deployment configuration Assistant problem

    I did everything up to the point where I enter the IP address of the Simulator, but it returns the following error: "Unable to connect: connect to /192.168.xxx.xxx:443 has expired.". Check the settings of IP address for the target. You may need to re

  • Error "TI drivers video card are out of date" when you try to play videos on Windows Media Player

    I tried to convert videos using the converter from DVDVideosoft video I received a message that says ATI video card drivers are outdated. I tried to download and install the latest drivers and I got the blue screen of death. When I rebooted the compu

  • DEPARTMENT Local relief account does not

    Hi all I have a RADIUS server on windows 2003. I use a switch cisco 2960, everything works fine, but I need to test the account of local user on the switch so that I'm locked out if the radius server is not available. should what command I enter to a