Solved

How do I translate createEmptyMovieClip from AS2 to AS3

Posted on 2008-06-19
5
3,681 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

760 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now