AS3 to AS2 code

Hello,  I have a problem with a small code.
I'm doing a photo gallery in as3 to insert into my website, the problem is that my site is made in as2 and when I insert the gallery into website the up and down buttons don´t work. Someone could tell me how to modify this code ? I need the code in AS2. Thanks
stop ();
var arriba = Boolean;
var abajo = Boolean;
//scroll
abajobtn.addEventListener (MouseEvent.MOUSE_DOWN, mover_abajo);
function mover_abajo (event:MouseEvent) :void {
  abajo = true;
arribabtn.addEventListener (MouseEvent.MOUSE_DOWN, mover_arriba);
function mover_arriba (event:MouseEvent) :void {
  arriba = true;
addEventListener (Event.ENTER_FRAME, mover);
function mover (event:Event) :void {
  if (abajo == true) {
  if (tiravip.y >= -965) {
  tiravip.y -= 12;
  if (arriba == true) {
  if (tiravip.y <= 7) {
  tiravip.y += 12;
abajobtn.addEventListener (MouseEvent.MOUSE_UP, detener_abajo);
function detener_abajo (event:MouseEvent) :void {
  abajo = false;
arribabtn.addEventListener (MouseEvent.MOUSE_UP, detener_arriba);
function detener_arriba (event:MouseEvent) :void {
  arriba = false;

Ned, thanks for answering.
I tried with this code and doesn´t work. Do you know why ?
stop ();
var arriba = Boolean;
var abajo = Boolean;
//scroll
abajobtn..onMouseDown = mover_abajo;
function mover_abajo () :void {
  abajo = true;
arribabtn..onMouseDown = mover_arriba;
function mover_arriba () :void {
  arriba = true;
addEventListener (Event.ENTER_FRAME, mover);
function mover (event:Event) :void {
  if (abajo == true) {
  if (tiravip._y >= -965) {
  tiravip._y -= 12;
  if (arriba == true) {
  if (tiravip._y <= 7) {
  tiravip._y += 12;
abajobtn..onMouseUp = detener_abajo;
function detener_abajo () :void {
  abajo = false;
arribabtn..onMouseUp = detener_arriba;
function detener_arriba () :void {
  arriba = false;

Similar Messages

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

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

  • 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! 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);

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

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

  • How do you convert this code from AS3 to AS2?

    Hi,
    I created some AS3 code that is working perfectly for us.
    However now we need to convert it to AS2 so that it can be Flash
    Player 8 compatible. If it could also be compatible for Flash
    Player 7 that would be ideal but not a requirement.
    Thanks in advance.

    Are you wanting someone to do the conversion for you, or are
    you asking for general tips for doing the conversion yourself?
    i can give you tips:
    have a look at the
    ActionScript
    2.0 Migration page.
    In this you'll find the property conversions eg(going from
    AS3 to AS2). y becomes _y, height becomes _height, scaleX becomes
    _xscale, void becomes Void etc.
    you'll find that events need to be converted, eg.
    particle.addEventListener(Event.ENTER_FRAME,
    animateParticle);
    becomes:
    particle.onEnterFrame=animateParticle;
    the onEnterFrame class doesn't pass an Event parameter to the
    event listener. Instead, the event listener is automatically in the
    scope of the event dispatcher, so instead of 'event.target' you
    will be able to just target 'this'.
    You'll need to use setInterval() instead of the Timer class.
    You'll need to use attachMovie() instead of
    addChild().

  • Change some code from as3 to as2

    Hi, I want to use as2 because it compatible with my website.
    I want to change some code from as3 to as2
    /////////////////////////////image1//////////////////////////////// if(MovieClip(this.parent).imagetxt.text == "a") {     var imgurl:String = "C:/Users/Thái/Desktop/ls/cotton-1.jpg";     var myrequest:URL = new URL(imgurl);     myloader.scaleContent = true;     myloader.load(myrequest); } /////////////////////////////image2//////////////////////////////// else if(MovieClip(this.parent).imagetxt.text == "b") {     var imgurl2:String = "http://aloflash.com/images/upload/3.jpg";     var myrequest2:URLRequest = new URLRequest(imgurl2);     myloader.scaleContent = true;     myloader.load(myrequest2); }thank you for your support.

    use:
    var myloader:MovieClip=this.createEmptyMovieClip("loader_mc",this.getNextHighestDepth());
    if (MovieClip(this._parent).imagetxt.text == "a") {
        var imgurl:String = "C:/Users/Thái/Desktop/ls/cotton-1.jpg";
        myloader.load(imgurl);
    } else if (MovieClip(this._parent).imagetxt.text == "b") {
        var imgurl2:String = "http://aloflash.com/images/upload/3.jpg
        myloader.load(imgurl2);

  • Converting AS3 to AS2

    Does anyone know how to translate this code into AS2? My client can't support AS3.
    var exitTimer:Timer = new Timer(15000, 1);
    exitTimer.addListener(TimerEvent.TIMER, jump);
    function jump(event:TimerEvent):void {
        gotoAndStop("Scene 1")
    exitTimer.start();
    Thank you!

    I put the wrong script in. This is the one I'm trying to convert from AS3 to AS2. Do I still use the setTimeout function or is the getTimer function more appropriate?
    var exitTimer:Timer = new Timer(15000, 1);
    exitTimer.addListener(TimerEvent.TIMER, jump);
    function jump(event:TimerEvent):void {
        navigateToURL(new URLRequest("http://www.url.com"));
    exitTimer.start();

  • Mixing as3 and as2 objects

    I'd just like to check something. When I was trying out a bit
    of as3, I tried having as3 objects, but as2 code on the timeline,
    so I'm guessing that you can't nest or load as3 objects inside as2
    movieclips because it probably treats everything like it's as2, so
    as3 objects don't work..
    But does it work the other way around? To have as3 objects
    nesting as2 "objects" or loading as2 swfs?
    Or is it either-either, no mixing whatsoever?

    you can load as2 swfs into as3 swfs. to communicate between
    the two, use the localconnection class.

  • Problem translating AS2 code

    Hi
    I'd appreciate it if anyone can help me with this.
    I have a basic menu that I created in AS2, this can be seen
    here:
    http://www.qwerty-design.co.uk/example2.html
    I have the menu working in AS3 but I just can't get the
    buttons to stay down like they do in this example. My scripting
    knowledge is limited and I need to get this sorted by Monday.
    Please help.
    if it would help I can post the AS2 code.
    My code so far

    Tried the code and I think we are nearly there, but there are
    two small problems,
    1. I need one the first button to be down at the start
    2. When I click one of the buttons an error is thrown up as
    follows
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at Test_fla::MainTimeline/onButtonClicked()
    The code now looks like this:

  • Do  new  FLASH CS3  support s AS2  codes ?

    Hi folks . . .
    When we use AS3 development tools , will old flash codes (
    AS1 and AS2 ) work correctly after this ?
    And can we use AS2 codes by flash cs3 tools ?
    Do ADOBE support AS1 and AS2 codes for a long time ??

    Yes. Flash CS3 is pretty much Flash 8 with new features and
    support for what
    it supported before (AS1 and AS2) and more (now additionally
    AS3)
    "firatadobeturk" <[email protected]> wrote
    in message
    news:f2l4f9$9i3$[email protected]..
    > Hi folks . . .
    > When we use AS3 development tools , Do old flash codes (
    AS1 and AS2 )
    > will work correctly after this ?
    > For a long time , does ADOBE supports , AS1 and AS2
    codes?
    >

  • AS3 to AS2 communication

    I have a SWFLoader in my AS3 application and into my AS3 SWFLoader, I load a AS2Shell.
    In this AS2 Shell, I load a movie in an empty MovieClip that I created.
    Try as I might, I am not able get the movie (thatt is loaded within AS2) to stay within my AS3 SWF Loader width and height. Below in my AS3 SWF Loader definition and my AS2 Shell code. Does someone know how to get this to work. By the way, setting Stage.scaleMode in my AS2 Shell does not seem to fix the problem.
    AS3 SWF Loader def:
            <mx:SWFLoader id="swfPlayer"
                right="22" left="22" top="18" bottom="18"
                scaleContent="false" maintainAspectRatio="true"
                horizontalAlign="center" verticalAlign="middle"
                enabled="true">
            </mx:SWFLoader>
    ===========================================
    AS2 code
    import mx.utils.Delegate;
    function init()
        //Stage.align         = "TL";
        //Stage.scaleMode     = "showAll";
        var LC_IN_NAME:String    = "_JXLFlashProxy_IN";
        var LC_OUT_NAME:String    = "_JXLFlashProxy_OUT";
        // Flex talks to me
        in_lc = new LocalConnection();
        in_lc.playVideo = Delegate.create(this, playVideo);
        in_lc.stopVideoPlayer = Delegate.create(this, stopVideoPlayer);
        in_lc.gotoNextFrame = Delegate.create(this, gotoNextFrame);
        in_lc.gotoPrevFrame = Delegate.create(this, gotoPrevFrame);
        // the underscore prefix gets around domain restrictions
        in_lc.connect(LC_IN_NAME);
        // I talk to Flex
        out_lc = new LocalConnection();
    function playVideo(fileName:String):Void
        var __vid:MovieClip;
        var __vidMCL:MovieClipLoader;
        if(__vid == null)
            __vid = createEmptyMovieClip(__vid, 0);
            __vid._lockroot = true;
            __vidMCL = new MovieClipLoader();
            __vidMCL.addListener(this);
            __vidMCL.loadClip(fileName, __vid);
            out_lc.send(LC_OUT_NAME, "onPlayVideoResult", true);
        else
            out_lc.send(LC_OUT_NAME,
                        "onPlayVideoResult",
                        false,
                        "ERROR: Video already playing.");
    function gotoNextFrame():Void
        __vid.nextFrame();
    function gotoPrevFrame():Void
        __vid.prevFrame();
    function onLoadInit():Void
        out_lc.send(LC_OUT_NAME, "onVideoPlayerLoaded");
    function stopVideoPlayer():Void
        if(__vid != null)
            //__vid.videoPlayer.stop();
            __vid.removeMovieClip();
            delete __vid;
            out_lc.send(LC_OUT_NAME, "onStopVideoPlayerResult", true);
        else
            out_lc.send(LC_OUT_NAME, "onStopVideoPlayerResult", false, "ERROR: Video player already stopped.");
    init();

    I'm in the process of documenting a process I developed on
    creating a
    Flash-wrapper to launch/control/track Captivate and
    Presenter-based files.
    It's based on the same component I build (and documented)
    here:
    http://www.connectusers.com/tutorials/2009/02/certificates/index.php
    The current article is about creating custom Flash-based
    certificates in
    Presenter/Captivate. The component will be the same, but I
    just realized in
    the last day or so, that I'll have to provide an update to
    better support
    funcitonality required in the Flash shell (but the component
    can be used for
    both purposes).
    Keep an eye out on ConnectUsers.com for more articles and
    interesting
    tidbits, I will be documenting.
    Regards,
    Andrew

Maybe you are looking for

  • Reg: How to Stop Polling of JDBC Adapter without Scheduling the adapter

    Dear Gurus, Here I am having one requirement. My clients wants to send data from JDBC adapter (ORcale System table) to R3 system via RFC. His Requirement:: 1. He is not telling the time of data flow from Oracle server so that based on that we can sch

  • Why can't I use fire-wire to sync my ipod?!?!

    The system won't allow me to synch my ipod with fire wire!! Why!?! I just bought a super nice mac pro you would think they would let me step it from from SLOW USB!!!!!!!!

  • Could not resolve Script

    I am getting an error message "Could not resolve <Script> to a component implementation." This is the code I am attempting to run, from the tutorials offered by Adobe. <Script> {import mx.controls.Alert;} </Script> I've tried this without brackets, w

  • SQL Server 2000 and JDBC,Registering cursor as OUT param

    hi I am using JDK1.4,SQL Server 2000 and Microsoft's JDBC driver. I am stuck in accessing cursors. The SP i wrote is USE pubs IF EXISTS (SELECT name FROM sysobjects WHERE name = 'spSelectEmployees' and type = 'P') DROP PROCEDURE spSelectEmployees GO

  • Final Cut acting strange after update

    I have a recently purchased Mac pro six-core with Mountain Lion OS. I've installed Final Cut Pro version 6.06 along with a Kona 3 card. All was fine with Final Cut until last week when I added RAM (real apple ram from the apple store) and did a softw