AS2 with AS3 integration

Hi.
I have loads of games in AS2 but a freelancer is developping games in AS3. Can I use a container movie in AS3 and load both AS2 and AS3 games in. Otherwise I would have to update all games into AS3. Would all games have to be published to the same flashplayer? ie: FS7 etc...

you can use an as3 swf to load as2 swfs.  if you need to communicate between the two swfs, use the localconnection class.

Similar Messages

  • What is wrong with as3

    this is not a question about 'how i do X'. is rather a 'discussion' (flame or whatever, but to defend or argue about aspects, not people) about 'what is wrong with as3' and what aspects whould be taken into consideration for updates. right now i am using as3, and since i paid for this license, i choose this tool over some alternatives and i am using it to do stuff for other people who pay me to do it, i think it can be helpful for all of us if some actions are started in the right direction. i have already posted about 'all people in adobe are dumbasses that do not know how to make a scripting tool and are messing up my work', but i was pissed at the time (i still am pissed) but i believe this is not the right aproach. instead, if this goes to the right people in adobe, we all may get something in the future, like better and easier todo apps and web presentations.
    pre: not only about the as3 specification, but COMPLY with the specification that you set. for example, some time ago there were problems with matrix transforms. this was corrected later with a patch. but this means it is not even doing what is is supposed to do
    1. scriptable masks and movement, sprites and child sprites: there is a sprite with a mask, the mask is a shape drawn via script, something like
    somemask=new shape();
    somemask.graphics.beginfill();
    (...etc)
    somesprite.mask=somemask;
    just like that. now add some child sprites to 'somesprite', and make 'somesprite' move, scale and rotate. there you will have something like a kaleidoscope, but not what you expected to do with your script. as the child sprites move in the parent mask, you will see that the child sprites appear or dissapear kind of randomly, and if the child sprites are textfields, it may be that the text is rendered outside the mask, or partially rendered outside the mask (as in only part of the text), rendered with the wrongf rotation or in the wrong place. some child sprites are clipped correctly, some dissapear totally when only a part should dissapear (clipped) etc.
    way around: have not tried it yet, but i have the impression that bitmaps have different criteria for clipping, so i am thinking of trying this: appli an empty filter (a filter with params so it does not have any effect on the sprite or in the textfield) so the sprite is rendered as bitmap before doing anything else with it. as i said, i have not done it yet, but it may be a way around this problem, to avoid all this inconsistency with clipping
    1-b. inconsistency between hierarchy and coordinates, specially masks: you apply a mask to a sprite, yet the sprite has a set of coordinates (so 'x' in the sprite means an x relative to its container), yet the mask applied to the very same sprite, as another reference as reference for coordinates (like the stage)
    2. painting via script: in any other languaje, in any other situation, something like:
    beginFill(params);
    (...stuff 1)
    endFill();
    beginFill(params);
    (...stuff 2)
    endFill();
    (...etc)
    means: render region of block 1, then render region of block 2 etc, and no matter what, it should be consistent, since there is noplace for ambiguity. if you read it, you may think what that means, even if you dont run it you may have an idea of the picture you want to draw, but not with as3. as3 somehow manages to screw something that simple, and mixes all the blocks, and somehow uses the boundaries of one block as boundaries for other block. is like all blocks are dumped into whatever, and then uses all lines defined into it as boundaries for a unique block. it changes all boundaries and generates inconsistency between what is shown and redraw regions of the resulting picture, like lines that go to the end of the screen and then dont go away in the next frames, even tough the beginfill endfill block should prevent it
    3. event flow: i dont know what was the policy behind as3 event flow design. it is in no way similar or an extension to previous event flow, neither with any event flow in any other plattform. i dont know how most people start with as3; in my case, i unpacked, installed and when i tried to do something with what i already knew i could not, so i started reading the as3 docs, and since is like 800 pages long, i just read the basics and the rest i would 'wing it'. in the part of the event flow, there was something about bubbling and stuff, it was not clear at all and when i tried to do what is was said in the documentation (like preventing events to 'bubble', as is called in the documentation), i could not see any effect but i could see it was a mess. flash is not the only thing out there to work with pictures or to work with mouse events, but is the only one that deals with things like 'target' and 'currentTarget'. my first experience on needing this was when i was dealing with my own event handlers (so the only thing that had control over mouse was the stage, and i would admin everything via script). there were events generated everywhere, the stage got events that were not genrated directly over the stage, but got there not with stage coordinates but the coordinates relative to the sprite that generated the event. so if i hover the mopuse over the stage, and the stage has some things on it how does it work? i get multiple event calls, like it was hovering multiple times over the stage in a single frame, but in each call with different coordinates? and what if i set all child sprites as mouseenabled=false or compare like 'if (event.target != event.currenttarget)', what if i move the mouse over a child, does it prevent the move mouse event at all? or does it filter only the event call with only stage coordinates? in my case, every time i move over another clip (with mouseenabled = true), the stage gets it as 'mouse up', even tough there was never a mouse release, what the hell? do even the people at adobe know how to handle events with their own tool when they require it? why does an event 'bubble' when i have not specifically tell it to do it? mi thought is that this event flow was very poorly conceived, and tough the intention may have been that there were different cases and it shopuld cover all cases, they actually introduced new problems that were not present in traditional ways to handle it, and it is neither the easier way to handle things, and this way, a very simple problem turns into a very ugly thing because it must handle things that were not neccesary to handle, or were implicit in other situations.
    4. legacy: since as3, all interaction is different, and if you want to do things in the new plattform, using the new features, what you already knew just goes to the garbage can. when a new tool arrives, it should be an extension to previous tools (which is a reason to update instead of just buying a new tool from a different vendor). if everything i had or knew just means nothing from now on, then i can not say 'i know flash script', and my previous knowledge gives me no advantage when aproaching the new version. as3 is a new aproach that requires doc reading and stuff, even if you knew something about previous as specifications or other oo languajes. if you decide to change things from now on, like the things mentioned in this post, instead of just throwing away everything the users alerady knew about the tool, do like in java releases, they mark some things as 'deprecated', they keep working as they should, give a warning, but also a message saying this feature is deprecated, we suggest you use this library instead.
    5. lack of previous functionality: if you 'update' something, it meand all previos functionality is still there (probably improved, but not with bugs if it was working fine), plus something else. now it seems backwards, there are some things that could be done in previous versions but not in this one, like 'duplicatemovieclip'
    6. inconsistency with scripting/programming paradigms: (ok, fancy work, but fits perfectly here): as3 proposed ways to handle things, but the people who designed it got 'too creative', and they did something that is not consistent neither with previous versions of as or with other languajes. the documentations is full of things like 'it looks like x languaje or languaje family, but instead of using XXX word, you must use YYY'. great, what is this? namespaces 'work like', but 'differently' for example from java, .net, .c. its got the idea that a namespace means a grouped functionality but there are rules about where should be placed the file (ok, java has this also, .net takes care of it automatically if all files are registered in the project), but what you got is a mess that 'if you know other languajes you got the general idea, but nonetheless, even if you knew this or previosu versions of as, you still have to read whatever we decided arbitrarily just to be different'. namespaces, event handling, vars definition which is not like previous scripting neither like fully typed languajes.. is just a mess.
    7. lack of scripting and graphics integration: unlike flash and adobe tools that just got on the graphics side leaving all the scripting integratuion apart, most tools from other vendors integrate very well interacton with what is on the screen. the script editor: very poor. autocompletion? a drop down list that does not heklp at all, appears in the wrong places, and when you need it to go, it does not go (so if i want to move away from the uncalled drop down list, i have to click somewhere else, making developement slowewr instead of helping, so the drop down list does not capture all events when i dont want to). in other ides you double click somewhere and it will go to the part of code relevant to that event or whatever. for example microsoft tools, ok i am antimicrosoft, and one of the reasons was that when windows 95 got to market proposing itself as the ONLY pc os you could use if you wanted to keep useing the apps you already had, it was a lousy product full of flaws but you had to keep using it because you had no choice. what is so different from what is happening with flash just now? yet the ide of c# is awesome, works very well and seems reliable.
    adobe people: not all user are designers that just make pretty pictures. if it is not intended for scripting then why is it there. and if there are corrections to be done, they should patch all versions, not only the last one. previous version users also paid for their versions.

    Well, there is no point in arguing.
    I personally believe AS3 does exactly what it promises to do within limits (read: reasonable limits) of ECMA type of language. And sometimes it doesn’t do what we expect it to for it cannot possibly emulate everyone’s thinking process. The task, I guess, is to learn to think in terms of AS3 – not to try to make AS3 think like us. No language covers all the grounds. And no, it is not Java - with no negative or positive connotation. It is what it is. Period. I just hope that AS5 will be more Java like.
    You are right about the fact that it is not necessary to know all the aspects of language in order to perform the majority of tasks. But it is paramount to have a clear idea about such fundamental concepts as display list model and events. For instance, depth swap has no meaning in terms of AS3 because display list object stacking is controlled automatically and there is no need for all these jumping through hoops one has to perform in order to control depth in AS2. There no more gaps in depths and one always know where to find things.
    Similarly, there is no point in having duplicateMovieClip method. More conventional OOP ways of object instantiation accomplishes just that and much more. Just because OOP object instantiation needs to be learned doesn’t mean past hacks have place in modern times. duplicateMovieClip is a horse carriage standing next to SUV. What one should choose to travel?
    Events are implemented to the tee in the context of ECMA specifications. I consider Events model as very solid, it works great (exactly as expected) and never failed me. True, it takes time to get used to it. But what doesn’t?
    By the way, speaking about events, contrary to believe in Adobe’s inconsideration to their following. Events are implemented with weakly reference set to false although it would be better to have it set to true. I think this is because there are smart and considerate people out there who knew how difficult it would be for programming novices to deal with lost listeners.
    I think AS3 is million times better than AS2. And one of the reasons it came out this way is that Adobe made a very brave and wise decision to break totally loose from AS2’s inherent crap. They have created a totally new and very solid language. If they had tried to make it backward compatible – it would be a huge screw up, similar to how our friends at Microsoft are prostituting VB and VBA – extremely irritating approach IMHO.
    Also, Flash legacy issues shouldn’t be overlooked. Flash did not start as a platform for programmers. Entire timeline concept in many ways is not compatible with the best OOP practices and advancements. I think for anyone who is used to writing classes the very fact of coding on timeline sounds awkward. It feels like a hack (and AS2 IS a pile of hacks) – the same things can be nicely packaged into classes and scale indefinitely. As such I wouldn’t expect Adobe to waste time on hacking timeline concept issues by making smarter editor. They have made a new one – FlexBuilder – instead. Serious programmers realize very soon that Flash IDE is not for developing industrial strength applications anyway. So, why bother with channeling great minds into polishing path to the dead end?
    I would like to state that all this is coming form a person who knew Flash when there was no AS at all. And I applaud every new generation of this wonderful tool.
    I believe Adobe does a great job making transition from timeline paradigm to total OOP venue as smooth as possible. And no, they don’t leave their devoted followers behind contrary to many claims. They are working on making developing Flash applications as easy as possible for people of all walks. Welcome Catalyst!
    Of course there is not enough information about AS3 capabilities and features. But, on the other hand, I don’t know any area of human kind activities that does.

  • Parenting and child control with AS3

    Hi,
    I'm new to AS3 and although I can see some good practice and functionality I'm constantly getting stucked and can't yet make things that I would do so easily with AS2 - I almost need to relearn it from scratch!. Still I would appreciate some help and guidance on this...
    I made a class that creates a "kind" of menu with data from a XML file and basically what it does when it is called is create a emptyMC (a container), add a childMC (a square) and add another child (a text label). When I create the container I'm trying to add a MouseEvent that can act on each the container instances but all I can get is a MouseEvent on object containing all the added MCs. The code follows.
    Can anyone enlight me with this issue or explain what am I doing wrong.
    I can't understand well the dynamic parenting with AS3 and the lack of using instance names and dot parenting doesn't help.
    Thanks in advance.
    Note to Adobe: Previous versions of Flash Help Files and AS reference were by far more helpful than in CS4!
    In the timeline:
    import assets.myDynMenu;
    var theMenu:myDynMenu = new myDynMenu("menu.xml");
    stage.addChild(theMenu)
    stop();
    In the class:
    package assets
         import flash.display.*;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.text.TextField;
         import flash.net.*;
         public class myDynMenu extends Sprite {
              // INIT EXTERNAL DATA LOAD
              public function myDynMenu(theData) {
                   // LOADS THE MENU DATA FROM PREFORMATTED XML
                   var loader:URLLoader = new URLLoader();
                   var url:URLRequest = new URLRequest(theData);
                   loader.addEventListener(Event.COMPLETE, buildTheMenu);
                   loader.load(url);
              // XML MENU DATA LOAD CHECK - ON COMPLETE BUILD OBJECT AND CHILDREN
              public function buildTheMenu(event:Event):void {
                   var xml:XML = new XML(event.target.data);
                   for (var i=0; i<xml.menuData.menuItem.length(); i++) {
                        // ADDS A CONTAINER
                        var itemContainer:MovieClip = new MovieClip();
                        itemContainer.name = "menu" + i;
                        // THE NEXT LINE DOESN'T ACT AS I WISHED?!
                        // IN THE FUNCTION CALLED I NEED TO CONTROL THIS ITEM AND ITS CHILDREN
                        itemContainer.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                        itemContainer.x = 100 * i;
                        itemContainer.y = 0;
                        itemContainer.mouseEnabled = true;
                        itemContainer.mouseChildren = false;
                        addChild(itemContainer);
                        // ADDS A CHILD TO CONTAINER (a square)
                        var itemBase:MovieClip = new MovieClip();
                        itemBase.graphics.beginFill(xml.menuData.mConfig.mainItemColor);
                        itemBase.graphics.drawRect(0,0,xml.menuData.mConfig.mainItemW,xml.menuData.mConfig.mainIt emH);
                        itemBase.graphics.endFill();
                        itemBase.name = "base" + i;
                        itemBase.mouseEnabled = false;
                        itemBase.mouseChildren = false;
                        itemContainer.addChild(itemBase);
                        // ADDS ANOTHER CHILD TO CONTAINER (a text label)
                        var theLabel:TextField = new TextField();
                        theLabel.x = 5;
                        theLabel.y = 5;
                        theLabel.selectable = false;
                        theLabel.mouseEnabled = false;
                        theLabel.border = true;
                        theLabel.text = xml.menuData.menuItem[i].mName;
                        itemContainer.addChild(theLabel);
              // THIS IS THE MOUSE OVER THAT I NEED TO ACT ON EACH itemContainer (AND CHILDREN)
              private function onMouseOver(event:MouseEvent):void {
                   event.stopPropagation();
                   trace("You are over " + this.name );

    use:
    package assets
         import flash.display.*;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.text.TextField;
         import flash.net.*;
         public class myDynMenu extends Sprite {
              // INIT EXTERNAL DATA LOAD
              public function myDynMenu(theData) {
                   // LOADS THE MENU DATA FROM PREFORMATTED XML
                   var loader:URLLoader = new URLLoader();
                   var url:URLRequest = new URLRequest(theData);
                   loader.addEventListener(Event.COMPLETE, buildTheMenu);
                   loader.load(url);
              // XML MENU DATA LOAD CHECK - ON COMPLETE BUILD OBJECT AND CHILDREN
              public function buildTheMenu(event:Event):void {
                   var xml:XML = new XML(event.target.data);
                   for (var i=0; i<xml.menuData.menuItem.length(); i++) {
                        // ADDS A CONTAINER
                        var itemContainer:MovieClip = new MovieClip();
                        itemContainer.name = "menu" + i;
                        // THE NEXT LINE DOESN'T ACT AS I WISHED?!
                        // IN THE FUNCTION CALLED I NEED TO CONTROL THIS ITEM AND ITS CHILDREN
                        itemContainer.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                        itemContainer.x = 100 * i;
                        itemContainer.y = 0;
                        itemContainer.mouseEnabled = true;
                        itemContainer.mouseChildren = false;
                        addChild(itemContainer);
                        // ADDS A CHILD TO CONTAINER (a square)
                        var itemBase:MovieClip = new MovieClip();
                        itemBase.graphics.beginFill(xml.menuData.mConfig.mainItemColor);
                        itemBase.graphics.drawRect(0,0,xml.menuData.mConfig.mainItemW,xml.menuData.mCon fig.mainItemH);
                        itemBase.graphics.endFill();
                        itemBase.name = "base" + i;
                        itemBase.mouseEnabled = false;
                        itemBase.mouseChildren = false;
                        itemContainer.addChild(itemBase);
                        // ADDS ANOTHER CHILD TO CONTAINER (a text label)
                        var theLabel:TextField = new TextField();
                        theLabel.x = 5;
                        theLabel.y = 5;
                        theLabel.selectable = false;
                        theLabel.mouseEnabled = false;
                        theLabel.border = true;
                        theLabel.text = xml.menuData.menuItem[i].mName;
                        itemContainer.addChild(theLabel);
              // THIS IS THE MOUSE OVER THAT I NEED TO ACT ON EACH itemContainer (AND CHILDREN)
              private function onMouseOver(event:MouseEvent):void {
                   event.stopPropagation();
                   trace("You are over " + event.currentTarget.name );

  • Building ios Newsstand App with AS3 for iPad?

    Hi,
    How do I build an IOS newsstand App with AS3 for iPad? I will not need any updates for this app. It will be just a pdf magazine inside, same contents forever.
    I cant find any tutorials/introduction on how to build this.
    I get the idea on how to create normal ios App, but creating Newsstand App really confussed me.
    Hope I can get a good start here
    Help is appreciated!

    Sorry I've been busy.
    Have a look at this newsstand app tutorial that's in 2 parts. This is for native iOS however the packaging is the most important.
    http://www.viggiosoft.com/blog/blog/2011/10/17/ios-newsstand-tutorial/
    http://www.viggiosoft.com/blog/blog/2011/10/29/at-newsstand-and-subscriptions/
    The in-app subscription is something you're going to have to tackle. Are you selling this magazine on a subscription basis? If you are selling it, things can get tricky or possible. I'm not fluent on the latest in-app purchase integration or if there is any planned integration. A look on the ANE download page (http://www.adobe.com/devnet/air/native-extensions-for-air.html) doesn't show any ANE support for it. You could google around for an ANE that supports in-app subscriptions of course.
    Hope that helps.
    Please be sure to read the entire 2 articles listed above. I realize they do not strictly have to do with Adobe but they do outline the process of getting an app on newsstand and it's just up to us as developers to translate tutorials like that into our world.

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

  • Print data in Datagrid with AS3

    Dear all,
    I would want to print out all the data inside my Datagrid which were populated in flash AS3. Taking into consideration that my datagrid has horizontalScrollPolicy and verticalScrollPolicy activated, how do I print the whole information?
    This is the closest code I'm looking for, but I had alot of errors when I tried to use it, maybe because it is in AS2 & i convented it wrongly...
    Link: http://www.knowledgesutra.com/forums/topic/29459-print-with-flash-and-datagrids-without-re sizing/
    Do take a look at the code please.
    My convented code from AS2 to AS3:
    import fl.data.DataProvider;
    import fl.controls.DataGrid;
    import fl.controls.ScrollPolicy;
    var dp:DataProvider = new DataProvider();
    var fitPage:Boolean = false;
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitleTestPrizeNameTestPrizeNameTestPrizeName", Prize_Name:"TestPrizeNameTestPrizeNameTestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1TestName1TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeName"});
    dp.addItem({no:"1", Winner_Name:"TestName1", Prize_Title:"TestPrizeTitle", Prize_Name:"TestPrizeNameTestPrizeNameTestPrizeNameTestPrizeNameTestPrizeName"});
    datagrid.columns = ["no","Winner_Name","Prize_Title","Prize_Name"];
    datagrid.getColumnAt(0).width = 50;
    datagrid.getColumnAt(1).width = 150;
    datagrid.getColumnAt(2).width = 100;
    datagrid.getColumnAt(3).width = 350;
    datagrid.dataProvider = dp;
    datagrid.horizontalScrollPolicy = ScrollPolicy.ON;
    datagrid.setSize(600, 250);
    clickme.addEventListener(MouseEvent.CLICK, clickmeFn)
    function clickmeFn(e:MouseEvent){
         fitPage = true;
         doPrint()
    function doPrint(){
          if (fitPage == false) fitPage = true;
            var pj:PrintJob = new PrintJob();
            // position of currently visible rows stored
            var prev_vPosition:Number = datagrid.verticalScrollPosition;
            var prev_width:Number = datagrid.width;
            var prev_height:Number = datagrid.height;
            var prev_vScroll = datagrid.verticalScrollPolicy;
            var prev_selectedIndex = datagrid.selectedIndex;
            var dgPrintWidth:Number = 0;
            var dgPrintHeight:Number = 0;
            if (pj.start() != true) {
                   return;
            // hide scrollbar for print
            datagrid.verticalScrollPolicy = "off";
            // hide the selection
            datagrid.selectedIndex = undefined;
            // datagrid width for printing
            if (fitPage) {
                   dgPrintWidth = pj.pageWidth;
            } else {
                   if (prev_width < pj.pageWidth) {
                        dgPrintWidth = prev_width;
                   } else {
                        dgPrintWidth = pj.pageWidth;
            // number of rows per view, ignoring fractions (floor)
              var rowsPerPage:Number = Math.floor((pj.pageHeight-datagrid.headerHeight)/datagrid.rowHeight);
            // total number of pages to be printed, if there are any fractions, have one page for that (ceil)
            var total_pages:Number = Math.ceil(datagrid.dataProvider.length/rowsPerPage);
            // number of full pages to be printed, ignoring fractions (floor)
            var full_pages:Number = Math.floor(datagrid.dataProvider.length/rowsPerPage);
            // number of rows on last page if partial
            var last_page_rows:Number = 0;
            // height of last page if partial
            var last_page_height:Number = 0;
            // partial last page ?
            if (total_pages != full_pages) {
                   last_page_rows = datagrid.dataProvider.length - (full_pages*rowsPerPage);
                   last_page_height = datagrid.headerHeight + (datagrid.rowHeight * last_page_rows);
            // datagrid height for printing
            dgPrintHeight = datagrid.headerHeight + (datagrid.rowHeight * rowsPerPage);
            datagrid.setSize(dgPrintWidth, dgPrintHeight);
            for (var i = 0; i<total_pages; i++) {
                   // if last page and partial - resize grid
                   if ((i == total_pages - 1) && (last_page_rows > 0)) {
                        datagrid.setSize(dgPrintWidth, last_page_height);
                   // move the visible row position.
                   datagrid.verticalScrollPosition = i*rowsPerPage;
                   // size box relative to the grid
                   var b = {xMin:0, xMax:datagrid.width, yMin:0, yMax:datagrid.height};
                   if (!fitPage && prev_width < pj.pageWidth) {
                        var x0 = (pj.pageWidth - prev_width) / 2;
                        b = {xMin:(-x0), xMax:(datagrid.width+x0), yMin:0, yMax:datagrid.height};
                   pj.addPage(datagrid, b);
            pj.send();
              pj = null;
           // delete pj;
            // previous scrollPolicy
            datagrid.verticalScrollPolicy = prev_vScroll;
            // position of currently visible rows restored
            datagrid.setSize(prev_width, prev_height);
            datagrid.selectedIndex = prev_selectedIndex;
            datagrid.verticalScrollPosition = prev_vPosition;
    The error I get when I tried to print it:
    TypeError: Error #1034: Type Coercion failed: cannot convert Object@26ec1d31 to flash.geom.Rectangle.
         at _fla::MainTimeline/doPrint()
         at _fla::MainTimeline/clickmeFn()
    Advice needed
    -Zainuu

    var columns:Array = ["Flash", "ActionScript", "Republic of Code"];
         trace(columns);
         //Start printing headers 
         var xPos:Number = 0;
         var tbWidth:Number = 0;
         //leave 2 rows margin at top
         var rowY:Number = _rowHeight * 2;
         for (var i = 0; i < columns.length; i++)
              //define xPos by adding the tbWidth of the last loop
              xPos = xPos + tbWidth;
              var column:DataGridColumn = targetDG.getColumnAt(i);
    //get width of this column
              tbWidth = column.width;
              //add textField
              printClip.createTextField("header_" + i , printClip.getNextHighestDepth(), xPos, rowY,tbWidth, _rowHeight);
              var thisTb:TextField = printClip["header_" + i];
              //thisTb.setNewTextFormat(headerFormat);
              thisTb.defaultTextFormat = headerFormat;
              thisTb.border = true;
              thisTb.borderColor = 0xCCCCCC;
              thisTb.background = true;
              thisTb.backgroundColor = 0xD5EAFF;
              thisTb.text = column.headerText;
    I got this AS2 code and I tried to convent it into AS3 but I have this error..
    1046: Type was not found or was not a compile-time constant: DataGridColumn.
    I have bold the line that causes this error. Anyone knows the solution for this error?

  • HTML Link -AS2 fine, AS3 weird behaviour

    Hi Guys, I'm working on a project at the moment, and am
    seeing weird behaviour with the way my swf handles html links
    inside dynamic textboxes. When rendered as a AS2 file, the link
    works on a release as expected. When its inside a AS3 file the link
    will only work if the user right click and chooses 'open in new
    window' was there a change in behaviour how AS3 handles these
    links, or is there now an declaration needed to be made to allow
    these link to have the old behaviour?
    The project calls for xml data and embedded in that is a html
    link. Originally I thought it might have been the way I'd formed
    the xml so I tried with a hardcoded version instead (dynamic
    textbox, add text -> highlight -> add link through properties
    tab). But I still see the same behaviour between the as2 and as3
    versions.
    Any help would be greatly appreciated.
    Cheers.

    Actually, the ''href'' attribute is supposed to direct the browser to a new URL, etc., not run a script. Instead, use the ''onclick'' event attribute:
    ''<a onclick = “$('.div-feedback').fadeIn();”></a>''.
    Happy coding!

  • Issues converting scroll bar components from AS2 to AS3

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

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

  • Major gaming system Migration from AS2 to AS3

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

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

  • As2 and As3 on same Flash Player

    If i set AS2 codes to play in Flash Player 9, is it possible
    that this swf can load an As3 swf at the same Flash Player using
    As2 codes???
    These swfs both play in same virtual machine which is player
    version 9 but the other is coded with As2 and the other is coded
    with As3. How can an AS2 load a swf coded in AS3 on same Flash
    player?
    Is this possible?
    If yes, how? if no, why not?

    AS2 and AS3 swfs cannot exist in the same Flash Player
    virtual machine - each Flash Player instance (version 9 and
    greater) create different address spaces/virtual machines because
    the requirements of AS3 and AS2 are so different.

  • What's wrong with AS3?

    Hi.
    Is it me, or is AS 3 completely different from AS 2? I mean i
    haven't been able to write a single line of code that would work in
    AS 3. I wasn't a master in AS 2 and now i can't create anything in
    AS 3.
    Is there a setting or something for AS 3 to work like AS 2 or
    do i have to learn it all over again, starting from ground zero?
    Can someone help me with some hints?
    Thank you. Any help is much appreciated.

    The best book IMO is "Essential Actionscript 3.0" by Colin
    Moock. It takes you back to the rudimentary basics and guides you
    through them to the more advanced stuff. For me, going from AS2 to
    AS3 was a big leap and Colin's approach of starting back at square
    1 is very helpful.
    Some online resources that are good are:
    1. This forum.
    2. The Adobe Developer Center for Flash -
    http://www.adobe.com/devnet/flash/
    3.
    http://www.gotoandlearn.com/
    - great Flash how-to VIDEOS
    4.
    http://www.kirupa.com/developer/flash/index.htm
    Some good articles on OOP in AS3:
    http://www.awestyproductions.com/tutorials/flash-tutorials/learning-how-to-oop-in-flash/
    http://www.adobe.com/devnet/flash/quickstart/creating_class_as3/
    http://www.communitymx.com/content/article.cfm?page=1&cid=197DE
    http://www.actionscript.org/resources/articles/698/1/Make-your-own-reusable-classes-using- Flash-and-AS3/Page1.html
    http://www.test1labs.com/?p=13

  • AS2 or AS3 + online Tut for beginners ?

    Hi All,
    Anybody can advise what is the easiest to learn for a beginner  : AS2 or AS3 ?
    I am trying to do a "liquid layout " in Flash and have found tuts either with AS2 or AS3. Though I am struggling to understand them and need to learn the basics either on AS2 or AS3.
    If you know aswell a good website teaching the basics step by step.
    Many Thanks

    if you invest the time in AS3 it will probably be pay off the most in the end. AS2 as mentioned earlier is a bit easier to get up and running with and for many years powered many a great flash experience, but its days are numbered.
    here is a very solid overview of AS3 in short easy to understand video tutorials.
    http://tv.adobe.com/show/actionscript-11-with-doug-winnie
    I would urge you not to rush. take it slow. watch the videos and try to apply each concept to your own project.

  • Can C++ Container Determine AS2 vs AS3

    I have a C++ container of Flash Player 11 (I have also tried
    Player 9 and Player 10). How can the container ask the player what
    type of content it is playing (AS2 or AS3)?
    If I create an event handler (ExternalInterface.addCallback)
    in AS3 which returns true (depicting AS3), and call
    m_FlashPlayer.CallFunction in my container, I am able to
    receive/parse the ActionScript response ("<true/>").
    However, if the content is "old" (i.e. AS2 which does not
    have the necessary event handler) ... or if the content is AS3 and
    I deliberately throw an exception (throw new Error("AS3 Error") in
    my event handler) ... the C++ container has no way of
    differentiating between AS2 or AS3. My container catches the
    COleDispatchException, but there is no information within the
    exception. Both scenarios result with an m_scError = 0x80004005
    (E_FAIL).
    Is there a prescribed way for a container to ask the
    Shockwave player if it is playing AS2 or AS3 content?

    You are confusing the Shockwave Player (which runs
    Director-created
    content) with the Flash Player

  • AS2 vs AS3

    Hi,
    I was just wondering in what format do people usually publish in: AS2 or AS3? Since there seems to be more widgets in AS2, do people actually publish in AS3?
    I'm investigating creating Widgets and I was planning to do it in AS3 but ... is it the right choice?
    What are you publishing in?
    Whyves

    Hi there
    While I agree with what Lilybiri is saying, I'll add my own thoughts here.
    Personally, I tend to use the defaults for many things with Captivate. And one of the defaults is that it defaults to AS2 setting. The only time I might consider using AS3 would be if someone were to offer something I needed to use that only was available in AS3. Then I would change. But I haven't encountered that situation so far.
    So sure, I'm keeping an eye to the future as far as AS3 goes, but it doesn't really factor into the things I do daily. AS2 setting is default and seems to work fine. There are some nuances between the two as far as Captivate goes that you might consider.
    For example, one of them is that if settings are AS2 and you are using variables in captions, you see a momentary flash of the variable before the value actually appears. I believe that goes away and is corrected if you switch to AS3.
    Additionally, I presently am awfully Flash and AS ignorant. So if I were to finally begin learning the mysteries of ActionScript, I might be a lot more concerned.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • AS2 or AS3

    Hello, i'm somewhat decent in flash. I know AS2, i started
    learning AS3 today and find it to be more complicated and has so
    many extra steps in coding. Number one thing i hate is having to do
    all the code on the timeline, it will get so full of code if i have
    several buttons/movieclips that need code, no way to do code when
    you click on the button/movieclip in AS3 unlike 2.
    Would it be dumb for me to continue to use AS2 and learn more
    of it, or should i keep trying to learn AS3..... I don't do super
    complex stuff, mostly timeline navigation and animations.
    I also feel like there is way more room to make errors in 3
    because you have to type everything unlike AS2 where i was able to
    use the actions frame (use that plus tool that had the drop down
    menu).

    I'm in the same position, just starting to move from
    intermediate comfort with AS2 to a fresh beginning with AS3...not
    so easy for a guy who has so little logical thinking that I failed
    algebra in high school! I too am a bit annoyed by all the extra
    steps involved, such as having to add EventListeners for mouse
    events, when these really ought to be simplified and there by
    default, like in AS2. For example, why can't onMouseDown remain as
    a built-in behavior rather than having to take up 2 lines of code
    to insert it each and every time now?
    On the other hand, I am delighted at the way a lot of the
    inconsistencies in AS2 have been gotten rid of. No more having to
    remember when to put .x and when ._x, and so on. And now that I'm
    finally starting to learn how to use external classes, I see the
    beauty in it, and AS3 is custom-made for this. It seems that if you
    ever want to really advance in ActionScript programming, you need
    to start working with creating your own classes, and as long as
    you're going to learn those from scratch, may as well learn it in
    AS3.
    Putting AS on buttons was outdated practice years ago. It
    makes much greater sense to place all script on the timeline, with
    comments to separate it. Try programming the simplest game where
    objects are moving around and colliding, all controlled by script,
    and then a couple coded buttons control them. Bugs are inevitable,
    and debugging script when it's partly on the timeline, some is
    attached to main movie buttons, and some attached to movie clips
    inside movie clips, is a nightmare. Once you do scripting on the
    timeline, you'll never want to go back to the crude practice of
    attaching script to objects.
    Overall, it's a steeper climb than I'd have liked, to upgrade
    my knowledge from AS2 to AS3. But ultimately I think it's the best
    idea.

Maybe you are looking for