Solved

How do I translate createEmptyMovieClip from AS2 to AS3

Posted on 2008-06-19
5
3,695 Views
Last Modified: 2012-06-27
What would I do to get the same result as this AS2 creation of a box, if I should do it in AS3:

function container(target:MovieClip, boxWidth:Number, boxHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number):Void {
      with (target) {
            beginFill(fillColor,fillAlpha);
            moveTo(cornerRadius,0);
            lineTo(boxWidth-cornerRadius,0);
            curveTo(boxWidth,0,boxWidth,cornerRadius);
            lineTo(boxWidth,cornerRadius);
            lineTo(boxWidth,boxHeight-cornerRadius);
            curveTo(boxWidth,boxHeight,boxWidth-cornerRadius,boxHeight);
            lineTo(cornerRadius,boxHeight);
            curveTo(0,boxHeight,0,boxHeight-cornerRadius);
            lineTo(0,boxHeight-cornerRadius);
            lineTo(0,cornerRadius);
            curveTo(0,0,cornerRadius,0);
            lineTo(cornerRadius,0);
            endFill();
      }
}
_root.createEmptyMovieClip("factbox", 4);
        factbox._x = zfbX;
        factbox._y = zfbY;

_root.container(factbox, 120, 200, 8, 0xffffff, 100);
0
Comment
Question by:SimonAdrian
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:cwickens
ID: 21824166
I haven't used AS3 very much so I can't re-write it for you.  The approach I would take is going through the help section of Flash.

It is pretty extensive; for example I found one issue you will have is the call to "_root" this reference, according to the Flash 9 docs was "Removed. The closest equivalent is the Stage, which serves as the root of the ActionScript 3.0 display list."
0
 

Author Comment

by:SimonAdrian
ID: 21824840
I have tried to go through the help section and its not worth much, thats why I am asking for help.
I  have to see working examples to understand code, but the help-section practically gives no examples.
0
 
LVL 5

Accepted Solution

by:
cwickens earned 500 total points
ID: 21825101
here is one example I found, same thing is produced. with each.  It appears that the only 'real' difference is the initiating of the movieclip and the addition of 'addChild(mc)'

////////  AS2:

this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.beginFill(0xFF0000);
mc.moveTo(0, 0);
mc.lineTo(100, 0);
mc.lineTo(100, 80);
mc.lineTo(0, 80);
mc.lineTo(0, 0);
mc.endFill();
mc._x = 80;
mc._y = 60;



/////////  AS3:

var mc:MovieClip = new MovieClip();
mc.graphics.beginFill(0xFF0000);
mc.graphics.drawRect(0, 0, 100, 80);
mc.graphics.endFill();
mc.x = 80;
mc.y = 60;
addChild(mc);
0
 

Author Comment

by:SimonAdrian
ID: 21825169
Here is a good link I found.

http://blogs.adobe.com/pdehaan/2006/07/creating_new_movieclips_in_act.html

And I was wrong, you were right, there is actually much more examples than Id experienced previously.
0
 
LVL 5

Expert Comment

by:cwickens
ID: 21825355
hey, no worries there...I wish it was that easy to get my wife to admit a mistake...lol

That link is where I found the example I posted above.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question