Solved

How do I translate createEmptyMovieClip from AS2 to AS3

Posted on 2008-06-19
5
3,710 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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.

691 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