Help!  Need help translating AS3 to AS2!

Good afternoon. I have a very simple roll over animation that
I want to use in Captivate 3. However, all of my experience with
Flash is with AS3 which is not recognized by C3. Attached is my
code snippet for the event that is not being supported. Would
anyone be willing to tell me where to start to make this into AS2
(or 1)?
Thank you in advance for any assistance.

MrFrankZ,
Here's the code from your first post, and I understand you'd
like to
convert it to ActionScript 2.0 (or even 1.0):
>>> gotoAndPlay("notRolled");
>>> rollBox.addEventListener(MouseEvent.MOUSE_OVER,
onRoll);
>>>
>>> function onRoll(event:MouseEvent):void
>>> {
>>> gotoAndPlay("rolled");
>>> }
>>> stop();
To that, someone replied this:
>> It's using AS 2. Can you display all of the code?
... which turns out to be incorrect. The code you're showing
is indeed AS3.
Telltale signs include the MouseEvent class reference, the
MOUSE_OVER event
constant, and the lowercase :void reference.
> The compiler is "The class or interface 'MouseEvent'
could not be
> loaded."
That makes sense for a FLA file configured for AS2, because
AS2 doesn't
have a MouseEvent class. Fortunately, this is a simple
scenario, so let's
break it down.
The first line doesn't change at all:
gotoAndPlay("notRolled");
That does the same thing in either AS2 or AS3; namely, it
invokes the
MovieClip.gotoAndPlay() method on a particular MovieClip
instance (happens
to be the timeline in which this code appears) and sends that
movie clip's
timeline to a frame labeled "notRolled".
Wiring up the event handler is your biggest change. AS2 does
support
the addEventListener() method, but only for components. In
AS2, there are
(bewilderingly) five different ways to assign event handlers,
and the one
that's going to work here -- and feel most this AS3 version
-- looks like
this:
rollBox.onRollOver = onRoll;
In principle, it's doing the same thing. I'm assuming
rollBox is a
movie clip symbol, so to see what functionality has has
available to it,
you'll look up the MovieClip class in the ActionScript 2.0
Language
Reference. When you do, you'll see headings for Properties
(characteristics
of the object), Methods (things the object can do), and
Events (things the
object can react to). A mouse-over is something the movie
clip will react
to, which makes it an event. What I've shown in my sample
suggestion is the
MovieClip.onRollOver event, as associated with your rollBox
instance.
The syntax is different from AS3, but the basic
functionality is the
same: "rollBox, when the mouse rolls over you, perform the
onRoll()
function."
And now for that function:
function onRoll():Void {
gotoAndPlay("rolled");
Only two small changes: a) drop the event:MouseEvent
parameter and b)
change :void to :Void.
Here it is altogether:
// AS2
gotoAndPlay("notRolled");
rollBox.onRollOver = onRoll;
function onRoll():Void {
gotoAndPlay("rolled");
And to make this work in AS2, all you have to do is drop the
strong
typing (in this case, the :Void):
// AS1
gotoAndPlay("notRolled");
rollBox.onRollOver = onRoll;
function onRoll() {
gotoAndPlay("rolled");
David Stiller
Co-author, The ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design."

Similar Messages

  • Need help translating menu from as2 to as3

    Ive been at this for a week now, trying to build a
    straightforward accordian menu, translating an existing as2 menu
    into as3. I desperately need help, I've reach my conceptual ends in
    terms of code knowledge. Could someone please take a look at what
    I've got and what I need to do to get it working? I've included the
    AS3 file I've been working on and well as the AS2 files I've been
    referencing and attempting to translate. Any help really be
    appreciated...also, here is the code I have so far below.

    you have a 4 enterframe loops running continually when they
    only need to run after a menu item has been clicked and can stop
    after all menu items have reached their final positions.
    and you need to compute the final positions for each menu
    item after one of them is clicked.
    you might do better to check for an as3 tutorial for an
    accordian menu. it's a bit more involved than you're thinking.

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

  • Need help on AS3!

    Hello! I need some help on as3. I'm still a noob at this stuff.
    I'm making a simple game. You have to click bugs that randomly moves down the screen. When you click the bugs they will become invisible
    and if any of the bugs pass through the bottom of the screen, you will lose 1 live.
    But right now, im having trouble with the script. When i click the bugs and it dissapear, the lives are still reduced. I don't get it.
    And theres also error coming out. "TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at buh_fla::MainTimeline/tekan()".
    Down 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 bug();
        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")
    ============================================

    stop();
    import flash.events.Event;
    import flash.events.MouseEvent;
    var iscore:int = 0;
    score.text = iscore.toString();
    var health:int;
    health=3;
    trace(health);
    var f:Array = new Array(); // ***********************
    for(var i:int = 0; i<10; i++){
        f[i] = new bug();
        addChild(f[i]);
        var fn = Math.round(Math.random()*2)+1;
        f[i].gotoAndPlay(fn);
        f[i].x = Math.random()*stage.stageWidth;
        f[i].sp = Math.random()*7;
        f[i].addEventListener(Event.ENTER_FRAME, animate); 
        f[i].addEventListener(MouseEvent.CLICK, klik);
    function klik(e:MouseEvent){
    e.target.visible = false;
        iscore += 1;
        score.text = iscore.toString();
        e.target.removeEventListener(Event.ENTER_FRAME, animate);
        e.target.removeEventListener(MouseEvent.CLICK, klik);
        if(iscore == 10) {
            gotoAndPlay("NextLevel"); //******************************
    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){
    for(var i:int = 0; i<10; i++){
        if(f[i].visible) {
        f[i].removeEventListener(Event.ENTER_FRAME, animate);
        f[i].removeEventListener(MouseEvent.CLICK, klik);
        f[i].visible = false;
    gotoAndPlay("gameover")

  • Patch number of the online help translation

    Dears,
    What is the patch number of the online help translation for R12.0.4
    Thanks
    Fadi

    Fadi,
    It is Patch 6400100 - R12.CONSOLIDATED ONLINE HELP 12.0.4
    For more details, please refer to:
    Note: 783410.1 - R12: Online Help / iHelp Patches
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=783410.1
    Note: 462349.1 - How to determine if you are on the latest iHELP patchsets
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=462349.1

  • Help: Translation in FI-Customizing

    Hello
    I have got a task to translate the setting of company code from English to German.  So far I have done it through translation tool available in (Goto) SAP-Customizing. Now I want to translate the taxes sales/purchases in to German. But I cannot use the same translation procedure, which I have used so far, because there is no translation tool in Tax Sales/Purchase-Basic setting in Customizing. Can anybody tell me how can I carry out this job?
    Thanks in advance
    Intisar

    CTA accounts are referred as "Cumulative Translation Adjustments", where difference arising from translation of PnL and BS with difference Exchange rate is posted to, CTA account is added to Retained earning line item in Balance sheet.
    My requirement is that, I need to Translate my PnL and Bal Sheet with two different Exchange rates to meet GAAP requirement and this translation adjustment should be posted to the CTA account as mentioned in original post.

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

  • I have a PDF with a diagram, I need to translate the text so I open it in Illustrator.  The document opnes up vertically oriented  I try to put it horizontal to be able to read and change the text  However everything I have done is not working  The artboa

    I have a PDF with a diagram, I need to translate the text so I open it in Illustrator.  The document opens up vertically oriented  I try to put it horizontal to be able to read and change the text  However everything I have done is not working  The artboard does change, but the diagram stays vertical.....Please help  I need to finish that for today..Please help

    A PDF usually consists of one to an indefinite number of clipping masks inside each other.
    You need to be very carefull with selecting stuff.
    So you need to read the manual on how to select stuff and on the basics of Illustrator.
    On top of that: because of the complex hierarchy of PDF files, it is kind of difficult to help you without seeing anything.

  • Likert Scale Quiz AS3 or AS2

    Hi
    I'm a realtively new user of Flash CS3 Pro and am trying to
    figure out how to create a quiz that uses Likert scale questions
    and answers (quiz-taker can choose from 5 answer choices for each
    question/statement, based on their agreement or disagreent with a
    statement, each choice having a different score from 1 to 5 points:
    strongly disagree=1, disagree=2, neither agree nor disgaree=3,
    agree=4 and strongly agree=5).
    The quiz would have 8 questions/statements, each with their 5
    choices and the total score would be the addition of all 8 choices
    in terms of their point values (1-5).
    As a newbie, this is beyond my AS skills, especially using
    the newer AS3, though AS2 is also a significant challenge.
    I would be grateful for any help, especially a sample script
    that I can adapt to the task.
    Kind Regards,
    saratogacoach

    OK so having had a play around it seems that a simple option is:
    Use transparent buttons with a 3px stroke
    Inside and under each transparent button put a green circle
    Group the circles
    Whenever a button is pressed hide the circle group then make the single green circle corresponding to that button visible
    Clear and assign a variable with a value associated to that button
    This seems quite simple. Provided I can capture the variable values using the captivate to google spreedsheet widget it will work for me.

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

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

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

  • Benefits of AS3 over AS2?

    I would like to accomplish some very basic functionality in
    Flash, such
    as, creating buttons that link to other frames, scenes,
    websites,
    documents, turn on sounds, etc.
    I would ideally like to do this using the built in Behaviors,
    however,
    these will only work with AS2.
    1.) Is there any benefit to using AS2 over AS3?
    2.) Is there a date that Adobe has announced where they will
    no longer
    support AS2?
    Thanks.

    nambo1,
    First of all, the real hero is the Flash Player. The Flash
    Player, the features it has, and the environments it runs in and
    how it runs in those environments (particularly the web browser,
    but as kglad pointed, it's very flexible and is used other places
    as well) is what makes it so popular. ActionScript is simply how
    you programatically use the Flash Player. ActionScript is an
    ECMAScript language of which there are others, but it's the Flash
    Player (and what you can do with it) that attracts people.
    The Flash Player has been popular for awhile now. AS3,
    however, is the latest and completely redone language for the Flash
    Player. Because it's new and because there are significant
    differences between AS3 and its predecessor (AS1 and AS2), there is
    some adoption time required. Many people are still using AS2. You
    can google to find out a lot more detail about the
    advantages/disadvantages to AS3 vs AS2, if that's what you're
    really looking for.

  • I need to translate emails from mandarin to english

    i have found a new friend in china but she does not speak english so i need to translate what she has written & would also like my emails to be sent in mandarin..her native toungue..what is available for this to happen?

    Hello,
    Try use one addon:
    *[https://addons.mozilla.org/thunderbird/search/?q=translate]

  • Loader (Need help to convert from AS3 to AS2)

    Since I know this code works fine and that I use it into one of my AS3 flash, I need it in one of my AS2 flash and I don't know how to adapt it. I've searched in over 100 threads and I can't find something similar... Thanks to help me get it to work in AS2! Since I need it in AS2, I thought it would be the right place to post it.
    I posted all the loading process code, but I would need help mostly with the Loader part. How to do it in AS2? Thanks!
    var img = 0;
    var image_total = 0;
    var myImages_array:Array = new Array();
    var myBitmaps_array:Array = new Array();
    function Init();
    // Images urls are loaded into an array before this call
    LoadImage();
    function LoadImage()
        if (img < myImages_array.length) // img is the current image index and myImages_array is my array of URLs
    // I need help with this part please
            var loader:Loader = new Loader();
    // returns the image full path and load it
            loader.load(new URLRequest(my_site_url + myImages_array[img]));
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
        else
            if (count == 0)
    // When everything's loaded, I'll start loading my Bitmaps into a small slideshow
                count += 1;
                init_slideshow();
    function imageLoaded(e:Event):void
        var image:Bitmap = e.target.content;
    // Bitmap manipulation here (removed)
        image_total = myBitmaps_array.push(image);
        if (img < myImages_array.length)
            img += 1;
    // Call next image
            LoadImage();
    function init_slideshow():void
    // Reserts the current index for the first one
        img = 0;
    // Start the slideshow since everything's loaded
        animate_slideshow();

    If you look at the Flash help documentation for the addListener metod of the MovieClipLoader class, there is an erxample there that you should hopefully be able to work from.  It will be better if you get your stuff coded into AS2 before you pursue more help with it.  IT is difficult to tell you how to fix something if you don't show what you are using.

Maybe you are looking for

  • How to avoid Huge scan with case condition in the select statement.

    Hi , I have the below sql and add condition such that c.ROLE = 18 then tibex_fixrestorestateview needs to be queried else it should not query the tibex_fixrestorestateview. tibex_fixrestorestateview contains 10 to 20 millions records so to avoid scan

  • HP DV5 1110EM DTS sound to av receiver NO GO HELP PLEASE

    Hi I have a Pavilion dv5 1110em it has hdmi and is capable of 7.1 sound from the hdmi port. I'm playing MKV files via laptop hooked up to my lcd, the laptop is connected to my sony strdg 800 receiver via hdmi. My problem is i cannot get normal 5.1 dt

  • Table alignment problem

    I am building a table for a checklist for potential bankruptcy clients for a law firm. The table has two columns. Column one contains a small gif, a black-bordered white check box. The second column contains a list of information and documents the pr

  • I purchased refurbished and it has a apple id that is not mine, how do I change to my account

    I purchased a refurbished ipod touch for my son, it looks great and is working however, when trying to go to app store, the device still has a apple ID that is not mine. HOw can I delete this and add to my account. My son had a touch and it got wet a

  • Ichat won't work

    I updated my messages and when I try to sign in again I get this message "The server encountered an error processing registration. Please try again later" This has happened for the last few days. Help