[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I translate createEmptyMovieClip from AS2 to AS3

Posted on 2008-06-19
5
Medium Priority
?
3,744 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

873 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