AS2 to AS3 conversion... external array files

I'm at the tail end of writing an app in ActionScript2 for a
client and was just told that it needs to be rewritten in
ActionScript3. ((8-0
I'm pretty good at AS2, very new to AS3. So here's a question
(the first of many, I'm afraid): I currently have a series of
external data files... really just .as files each of which
instantiates and populates an array... that I've been bringing in
at compile time using
#include. The question is, what do I need to do to get those
same files into an AS3 version... do they need to be set up as
packages? Do I leave them as they are, stick 'em in the folder and
they'll show up?
Any guidance would be deeply appreciated.

move the instantiation to a class...perhaps your document
class if you are writing in Flash (as opposed to
FlexBuilder).

Similar Messages

  • JavaScript alert in AS3 or AS2 to debug the external actionscript file

    Hi,
    Is there any way to debug the external AS file as i dont want to use "trace".
    I have an idea to use the input text field the check the variable/function is working right but this is not enough so is there any process in AS2 or AS3.
    Thanks in advance..

    my mistake ..i have used there dynamic textfiled.
    but i got a easy solution by using
    getURL ("javascript:alert('Testing');");
    but this is not the good solution
    is there any way to import the alert contolls in AS2
    like i have read somewhere
    import mx.controls.Alert;
    Please reply..

  • AS3 loading external swf files with buttons from inside a movieclip

    In my main .swf I have labels on the timeline, navs for those btns are on the first frame of the AS layer and each button sends the playhead to a different frame.
    On one frame called fr1 there is an mc called mc_1 that appears on stage when the playhead stops there. Inside mc_1 are a set of navigation buttons that need to call external .swfs.
    Do I add event listeners on the last frame of mc_1 for each button?
    how do I call the loaders for the swfs on the buttons since the swfs will load on the main timeline NOT the mc_1 timeline?
    So label on main timeline called fr1 will load external1 swf , on fr10 external 2.swf will load and so on.
    any help?

    The code for that button's event listener needs to be placed wherever it has direct access to the button.  Not necessarily on the same timeline, but in a place where both the button and the code are present at the same time.
    The code could be placed at the frame in the main timeline where the movieclip with the button(s) is, targeting the buttons via the movieclip (mc.button.addEvemtListener...) , unless the buttons are somewhere down the timeline of that movieclip.
    If they are down the timeline of that movieclip, then you would need to have the event listener also inside the movieclip, down its timeline where the buttons are finally settled in... being sure to assign instance names to the buttons at every keyframe.

  • Load external audio file in array?

    Hello.
    I have figured out how to load an external video file - and I can play an imported audio file, but I can't seem to use either method to load an external audio file into an array. (doh)
    Here is my audio code:
    var tour_audio:Array = [tour1, tour2]; 
    var my_num:Number= Math.floor(Math.random()*2);
    var ChosenSound = tour_audio[my_num];
    var playing:Sound = new ChosenSound();
    playing.play();
    Here is my video code:
    var my_videos:Array=new Array ("link1.mp4", " link2.mp4", " link3.mp4", " link4.mp4");
    var randomIndex = Math.floor(Math.random()*my_videos.length);
    my_player.source = my_videos[randomIndex];
    I tried "var tour_audio:Array = ["link1.mp3", "link2.np3"];  - but that did not work.
    ty

    // the array is from your code, the array will hold the references to the two sound files
    var tour_audio:Array = new Array();
    // then you need to create two instances of the sound class to hold the sound files that you load in
    var soundClip1:Sound=new Sound();
    var soundClip2:Sound=new Sound();
    // then you need a sound channel to play the sound files
    var sndChannel:SoundChannel=new SoundChannel();
    // this is your randomizer code
    var my_num:Number= Math.floor(Math.random()*2);
    // now you load each of the sound files into your sound class instances using URLRequest
    soundClip1.load(new URLRequest("tour1.mp3"));
    soundClip2.load(new URLRequest("tour2.mp3"));
    // to find out when the files have finished loading, you need to add an event listener to each of the sound classes
    // these event listeners will fire the functions onComplete1 and onComplete2 when each sound file has finished loading
    soundClip1.addEventListener(Event.COMPLETE,onComplete1,false,0,true);
    soundClip2.addEventListener(Event.COMPLETE,onComplete2,false,0,true);
    // this is the function for the first sound loader listener, it will add the sound class instance to your array once the sound has loaded
    function onComplete1(evt:Event):void {
        tour_audio.push(soundClip1);
    // this function does the same job for the second sound file
    function onComplete2(evt:Event):void {
        tour_audio.push(soundClip2);
      // call this function to play the chosen sound file
      // it could be called from the onComplete2 function above
    function playRandomSound():void {
              var ChosenSound = tour_audio[my_num];
              sndChannel = ChosenSound.play();
    I've added comments to the code itself that should help to explain what's going on. Yes, AS3 is just jam packed with intimidating stuff. As you use it, it will start to make some sense.

  • How Do I Use an External MP3 file Without Embedding it? (AS2)

    I am using Adobe Flash CS6 with ActionScript 2.0.
    I have compiled my project, and due the collection of embedded mp3 files (background music) I am using on various locations, my published swf file is over 12MB.
    To reduce the size, I placed all the mp3 fiels in the same folder as the swf file and removed all reference to them from the project.
    I then added this code to frame #1
    import flash.events.Event;
    import flash.media.Sound;
    import flash.net.URLRequest;
    var CreditsMusic:URLRequest = new URLRequest("NineWalkers.mp3");
    var s:Sound = new Sound(CreditsMusic);
    CreditsMusic.setVolume(50);
    CreditsMusic.start(0,1);
    Obviously, this is not working (I would not be posting here if it was).
    What am I doing wrong?

    I haven't look into the help documents (you can), but I see you mixing up AS2 and AS3 code, along with treating a URLRequest (AS3) as if it is a Sound object....
         CreditsMusic.setVolume(50);
         CreditsMusic.start(0,1);
    If you want to work with the Sound class in AS2 open the help documents and see what properties and methods are available for the Sound class and work things out from there.  If you search Google using "AS2 Sound loadSound" you might get some good info as well.

  • Trouble loading an external swf file implemented with AS3

    I am using Adobe Flash CS3
    At first, I tried
    swf_mc.loadMovie("//swf file
    location");
    It gave me
    quote:
    Warning: 1060: Migration issue: The method loadMovie is no
    longer supported.
    USE: var l = new Loader(); addChild(l); l.load(new
    URLRequest("your url"));.
    Well, the given code isn't working at all.
    But since it is a migration error, I thought maybe I can just
    save it into Flash5 format with AS1. Then it worked with most
    external swf files. However, the one I am trying to load is a swf
    file with AS3, so my older version swf can't load it at all.
    Anyone has any ideas about how to load an external AS3 swf
    file?

    AS3 is a completely different beast than AS1 or 2. loadMovie
    was removed from the language.
    The answer to your question is two fold. First, Adobe was
    kind enough to give us the code when it finds a migration issue.
    var _ldr:Loader = new Loader();
    addChild( _ldr );
    _ldr.load( new URLRequest( "your url") );
    Handling progress has also changed. I have a ContentLoader
    package on my site that you're free to use that should familiarize
    you with the new way that things are done in AS3.
    http://sd-dezign.com/blog/?page_id=10

  • Load array variable from external xls file

    I want to initialize an array variable using an external xls file.
    I am trying with property loader step but I have to insert manuallly all the elements of the array.
    Is there any other way to do this?
    Thanks
    Valter

    Hi FiloP
    When i open and close your example in my Teststand (Engine and Editor 4.0.0.326) Teststand asked me to save
    some NI-Tpyes.ini !!!
    That means my TS NI Types from release date: 2007-April-05 differes from yours.
    There could be to two reasons: your files are conterminated or NI have relased a new update with newer step-types.
    So until this not clear everbody should be carefully. Never acept savings to NI-Types when closing.
    To get more information about this please visit this thread:
    http://forums.ni.com/ni/board/message?board.id=330&message.id=17427#M17427
    greetings from the lake of Constance, Germany
    and get never affected by a type virus
    juergen
    HI Valter1,
    tomorrow evening i will post a C# example.
    greetings
    juergen
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=

  • Load and unload the external swf file using AS3(for window, IOS and android)

    For the external swf file loading, I use this code
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
    its working great but I don’t know how to unload the loaded swf files (looking: unload one by one and unload all)
    in AS2 we have
    on (release) {
              loadMovieNum("scene2.swf", 1);
              unloadMovieNum(2);
              unloadMovieNum(3);
    but i need in AS3

    Now I use this code and this time I got these compiler errors
    package {
                    import flash.display.SimpleButton;
                    import flash.display.MovieClip;
                    import flash.events.MouseEvent;
                    //import flash.display.URLRequest;
                    //import flash.display.Loader;
                    import flash.events.Event;
                    import flash.system.ApplicationDomain;
                    import flash.net.URLRequest;
                    import flash.system.LoaderContext;            
                                    public class load1 extends SimpleButton {
                                                    var loadit:Loader;              
                                                    public function load1() {
                                                                    this.addEventListener(MouseEvent.MOUSE_DOWN, loadfile);
                                                    private function loadfile(event:MouseEvent):void {
                                                                    trace("you clicked me");
                                                                    loadit = new Loader();
                                                                    this.parent.addChild(loadit);
                                                                    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                                                                    loadit.load(new URLRequest("s01.swf"), _lc);
                                                    private function unloadfile(event:MouseEvent):void {
                                                                    loadit.unloadAndStop();

  • AS3: Loading External Text into a Master File

    I have a master file that I want to load an external text
    file into. This external text file will also have an external style
    sheet applied to it.
    In your opinion, which way is best to load the external text
    file?
    1) Generate a text field dynamically in the master file using
    the TextField class and then loading the external text in.
    2) Placing (at authoring time) a dynamic text box on the
    master file's stage and loading the text in.
    3) Placing a dynamic text box in a separate .swf file and
    then loading that external swf in to the master file, then loading
    the external text into the text box.
    Any opinions?
    Thanks...
    Brenda

    On my project im going with the third choise, dont ask why,
    cause i just do.
    only difference is that i also lad my data into this external
    swf file.
    in other words i use mainly second as well as im going with
    the third one.
    In my opinion, no idea if thats the best way, but i certanly
    know that its (for me) most confortable way.

  • Including AS3 external class file

    How do I include 2 or more external action script files in my FLA document.The first one is easy and taken care by setting the class property of the FLA document to the class file name. But if I have several external class files? I have tried the 'include' directive but the compiler complains - any suggestions?
    Thanks
    Joseph Karov

    To import the other Class, just start typing its name in an expression, and hold down the control key while hitting the space bar. Both the Flash IDE and Flash Builder will bring up a code completion dropdown. When you select the Class, the import statement will be generated.
    For example, if you are in Foo and you type:
    protected var bar:Bar;
    Then when you have typed in the "Ba" part of the word Bar after the colon, if you use the Ctrl-Space keyboard shortcut, it should show you your Bar Class, possibly among other Classes starting with "Ba." Select "Bar" with either your mouse or your cursor, and Flash will finish the word for you and generate the import statement. Note that you can now create and use instances of Bar, but Bar won't be "merged" into Foo, which it sounds like is what you want. To do that, you'll need to do what I suggested, which is to have one Class extend another Class.
    To have one Class extend the other, change the line that says "public class Foo" to "public class Foo extends Bar". Note that the two Classes must have compatible functionality and have the same base Class. I'm assuming they do, or else trying to "include" the code wouldn't work either.
    Another possible solution, depending on exactly what you're trying to acheive, is to apply the second Class to a symbol in the library and use that by placing it on the stage or accessing it through code. However, you haven't given us very much to go on, so it's really difficult to help you.

  • AS3: outputting trace() content to external txt file

    the question's in the title. ive got a swf but i've gotta run
    it on a nokia n800, which means trace() content will be lost and -
    boy! - do i need it!
    so how can i set my swf up to output its trace content to an
    external txt file?

    hello kglad
    well, not 'lost' thats misleading, sorry. i mean: the swf
    will be running on a browser outside the flash authorising
    environment so the output window won't be accessible, therefore i
    need a way of printing out the trace() output to another source.
    the help files say that trace() can output to the output window OR
    to an external txt file. only it doesnt actually go on to say quite
    HOW you can output to said external txt file, rather
    irritatingly..

  • Help creating an external array for a scoreboard

    I'm trying to create an array in an external file that will recieve and arrange scores sent from Quiz.fla upon clicking the submit score button.  I also want another fla file to be able to reference this external array and pull the top 15 scores from it, and then display those scores on a scrolling banner.  I want the banner to be able to update dynamically (I assume reloading the banner fla each time it reaches the end of its cycle, having the first frame load the external array on an onClipEvent action would accomplish this), that way it will update while remaining open.  The main reason I need two separate files for the quiz and the score banner is they will be displayed on two different monitors.  What would be the most efficient way of accomplishing this?  I know a little about actionscript but I don't have much experience with calling data and functions from external fla or as files (the array and the function designating how the data will be arranged within said array are going to be in a separate .as file).
    I'm currently working in AS2, since I've had almost no experience with AS3.

    So if I wanted to avoid using a server, I'd basically have to set up the
    array storing the high scores in an external .as or .swf file which would
    then be called into the quiz game to store the scores, and then called by
    the banner each time it hits frame 1 to refresh the numbers?  But then that
    would run into the problem of a shared object being used by two different
    clients I guess?  Servers setup and accessing confuses the hell out of me
    right now, so I'm trying not to make things to hellish for myself...
    Would there be a way to create 2 external database files within the folder
    holding the .swf files to somehow get around the issue of one sharedobject
    being accessed by two clients?

  • AS3.0 External Interface: Pass variables to flash using javascript

    Hello all,
    I am looking for a simple and straightfoward example of how I can pass the value of a variable into flash using javascript.
    Specifically, I'd like to use javascript to pass the filename of an external video file that I would like to load into my flash movie.
    I'd also like to call a function in the SWF that plays the movie once the filename as been passed to the flash movie.
    External Inferface looks like the way to go.
    I've found a few decent AS2.0 examples, but converting them to AS3.0 has proven difficult and many of the examples are much too complex for what I am trying to do.
    If you have any code samples or tutorials showing the HTML/Javascript and the associated actionscript I'd really appreciate it!
    Thanks!
    Tim

    if you create a swf (eiTest.swf) and html:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
        <head>
            <title>eiTest</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <script language="JavaScript">
             function thisMovie(movieName) {
             if (navigator.appName.indexOf("Microsoft") != -1) {
                 return window[movieName];
             } else {
                 return document[movieName];
         function f1(value) {
             thisMovie("eiTest").jsF(value);
    </script>
        </head>
             <body onload="f1('yourfilename.ext');">
         <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                 id="eiTest" width="550" height="400"
                 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
             <param name="movie" value="eiTest.swf" />
             <param name="quality" value="high" />
             <param name="bgcolor" value="#869ca7" />
             <param name="allowScriptAccess" value="sameDomain" />
             <embed src="eiTest.swf" quality="high" bgcolor="#869ca7"
                 width="550" height="400" name="eiTest" align="middle"
                 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
                 type="application/x-shockwave-flash"
                 pluginspage="http://www.macromedia.com/go/getflashplayer">
             </embed>
         </object>
        </body>
    </html>
    you can use:
    import flash.external.ExternalInterface;
    ExternalInterface.addCallback("jsF", asF);
    function asF(fileS:String):void{
    trace(fileS);

  • AS3 load external swf problem, please help...

    Hey guys, I am really in need of an answer here. I would tremendously grateful if someone has the answer. I'll keep it simple and right to the point:
    1. I have created "index.swf" in AS3. Has it's own "MainClass" class.
    2. I created "holder.swf" which is the main landing page. Has 2 buttons, for the viewer to load the site in fullscreen or standard.
    3. In the timeline of "holder.swf" I have created 2 frames, 1st frame containing the buttons, second frame containing the AS3 external swf loader script.
    It does not seem to want to load my "index.swf".
    I have tested a million different ways, it load other swf's just fine, AS2 and AS3, but for some strange reason it just will NOT load "index.swf".
    This is driving me crazy, I have a feeling it has something to do with a class conflict. I have tried (import MainClass;) in the first frame of "holder.swf" and no luck.
    PLEASE GUYS, LET ME KNOW IF YOU KNOW THE ANSWER!
    THANK YOU SO MUCHO.
    Michael

    Hey kglad,
    Thanks for the quick reply!
    Well here is the problem... With the exception of a few things I need to update, as well as implementing some better preloaders etc... the site is running alright...
    About a week ago I decided that I wanted to site to start with the above landing page. A simple "holder.swf" which would give the viewer something to look at before entering the site... (ideally I want to find a script that will begin loading "index.swf" while the viewer is still on "holder.swf", but I'll figure that out later).
    Anyhow, I created "holder.swf" as I have many times before, and for some reason it does not seem to want to load "index.swf" into the second frame when instructed to do so... does that make sense?
    So... ideally I would like the site to start on the above graphic, then once the button is clicked, "index.swf" opens up...
    It's driving me crazy, because my code works on other swf's I've tested it with, just not with index.swf, which leads me to believe there is something in the MainClass.as file which is causing it not to load...
    What are your thoughts?
    Oh, and many thanks again!!!
    M

  • Convert AS2 To AS3

    So I made this basic game a few years ago which was in AS2 and Flash 6.  Now I want to convert this game from AS2 to AS3 but I have no idea where to start.  The code is approximalty 4k lines long and I don't know what to change to make it work in AS3.  What do you guys suggest?

    Are you using external .as files and classes or are you using frame scripts directly in the timeline? Are you used to any other object oriented programming languages? Knowing more about other languages you might know would help a lot.
    AS2 very informal and specialized to Flash. It relates to pretty much no other language out there, like JavaScript seldom relates. They're c-esque but only in a very distant 3rd cousin style.
    AS3 is much more OOP oriented and typed versus the less formal, error-prone loose dynamic nature of AS2. While your game would benefit greatly from the speed increases and error reduction, I think you're really swinging for the fence on this one. While some classes may resemble their AS2 counterpart and the core global functions work the same, everything else is different. Starting off trying to convert 4,000 lines of code is a little steep.
    As mentioned, the resources to learn AS3 are excessive and plentiful from video training to tutorials to the API reference itself. Google has it all.
    I think you really should lower your target and just try some really simple, basic things. Draw a shape, add a listener, do something basic when clicked, etc. You'll get a good idea of how different things are with the new display list rather than tearing your hair out converting your as2 game.

Maybe you are looking for

  • Item Category determination while copying

    Hello Guys, What is the difference between Normal Item Category determination and Item category determination while copying? What could be the business logic behind this? Thanks in advance. Ravi

  • OS X Mavericks won't let me make a new tag in Finder!

    It is grayed out! I am on the Admin user of my Mavericks partition (could being on a partition have to do with this?). Also, how do I get my HD on my desktop?

  • New iOS 8.0.2 and internet

    After installing iOS 8.0.2. my iPad jumps off the internet connection - wi-fi - at least once a day, so I have to reset it to get it working again. I've never had that problem and the other devices I have run fine. Have any of you had the same proble

  • Duplicate message id's in IE

    HI I have a jms-xi-idoc scenario. XI is picking one message from the queue. AE is confirming the same. But in IE, two message id's are creating and ultimately XI is posting 2 idocs to ECC ?? why XI is behaving like this ?? Any solution for this ?? th

  • Can't compile the HTML-Java Wizard generated file.

    I have created a java file using HTML-Java Wizard. when compiling the java file it gives an error method getDeclaredMethod(java.lang.String,null) not found in class in java.lang.class can anyone tell me how can I remove the error ? waiting for your e