Level of MovieClip - actionscript-3

When creating some extended MovieClip to the stage using AS on Actions of some frame, on which layer this MovieClip is created? On layer where Actions were? If I wanna move it down, for example, can I simply move the Actions layer? And by the way, one more question, what if I would not create Actions layer and write all the code on some used one? :SS

whenever you add objects through ActionScript it will not consider your layers it will add on the top of the display list. and for traversing into movieclips u can use MoveiClip(root) or MovieClip(parent). check out addChildAt() and addChild() methods of ActionScript for more info.

Hope u mean nested MovieClips
http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip

Related

ActionScript 3 - Possible to access MovieClips which are an instance of another MovieClip?

I drew an image on the stage and converted it to a movieclip whose name is
originalMovieClip
. The movieclip is now in my library. I dragged the movieclip in my library onto the stage. I did this twice, so now I have two movieclips which are both an instance of
originalMovieClip
which was the original movieclip which I created.
Through actionscript 3, is there a way for me to target all movieclips which are an instance of
originalMovieClip
? I want to basically do
all Movieclips Which Are An Instance Of originalMovieClip.gotoAndStop(2);
In such a basic manner, the short answer is - NO.
Short story long - you need to put them into array and loop through it, and stop every movie clip inside.
Other technique (not appropriate) is to loop through all children of stage, and check if the MovieClip is specific type (again you should at least set linkage class to originalMovieClip).
I suggest using the first one :)

Instantiate MovieClip with its layers?

I have searched a lot lately, I found that I can load an external swf file to my haxe project at compile time, and use the movieClips via their IDs as Classes types ..
That's cool& nice, but how it would work when I instantiate a MovieClip that has layers?
What I have is MovieClips with layers, layer of image, and a layer of text over the image layer.
So, is this achievable? will I be seeing instances of movieClips (images& texts over them) ?
Let's first dissect the flash terms in terms of code,
Layers :
Consider the layers as grouped z indexes. A single layer with multiple objects will also assign sub z indexes to each clip (see the send to back option in context menu)
The flash IDE provides you a nice interface to group & lock a few instances of objects, while working on the other. Each such group is a layer.
At runtime, every layer (with it's objects) will be concatenated into one single list (the display list) and the objects placed onto the stage in order of their position in the list.
Frames :
Frames are slices of time controlled by the fps property of the flash player. So if you have 12 fps, it means that whatever code you put in that frame of time will receive attention for 1/12th of a second.
Of course there is code being written for anything you do inside a frame or layer. The code, for example that you put in manually in IDE is added in by calling the addframescript internally.
MovieClip
The MovieClip class itself is actually an IDE related thing. The split being Sprite Class plus a timeline (collection of frames) plus associated properties & methods.
The Movieclip class thus provides you with properties like currentFrame, totalFrames, etc & methods like gotoAndPlay(), stop(), etc to interact with the flash controlled class.
Considering all of the above together, you should expect to see different images/text/objects at different intervals of time as defined in the frames when you access the movieclip.
I haven't spent a lot of time in flash, but the answer to your question comes from having a better understanding of how Flash/AS3 works, and not so much to do with Haxe.
Quoting this answer:
Layers only exist in the Flash IDE. They are not part of Flash Player's display list system. So you can't specify what layer a child goes into. Use addChild() or addChildAt() to add children to containers.
So that means Haxe will not have any concept which object is in which layer, nor would AS3 for that matter. The correct approach seems to be to use containers with IDs, which are recognised by AS3 or Haxe, and then add children to the containers.
TLDR: use containers movie clips, not layers.

How to access/hide/show Layers from ActionScript [Flash CS5]

I have 2-3 layers in my movie clip and i wanto access them using ActionScript code.
I want to show hide and access Elemts(buttons, text box) in that layer.
So how can i do that using ActionScript-3
Thanks.
You can't access the IDE layers programmatically. The best approach would be to group your layer contents into MovieClips with instance names that you can then call though code.
This is how I did it,
You cannot hide layers in actionscript.
You can put what you want to hide or show as a movieclip object.
Just go to insert and insert a movieclip object.
After this, put the movieclip object on the layer, just the same way you put images onto a layer.
However you must name this instance inorder to access it.
So if its called Movie1
this is how you access it,
_root.Movie1:MovieClip;
trace(""+_root.Movie1); //Just to be sure its defined
//To hide it just do this
_root.Movie1_visible = false;
//To show it just do this
_root.Movie1_visible = true;

How to copy Movieclip display properties as a vector into another movieclip

For my project I need to copy the graphics of a Movieclip with all of its children without copying anything else into a second Movieclip. I cannot use the Bitmap classes because I need the graphics to be displayed as a vector and I cannot use a method that simply copies the clip by calling the instructor ie:
var copy:MovieClip = clip.constructor
Is there any way to copy only the display portions of a clip into another Movieclip without turning it into a bitmap?
Thanks
Cloning display objects out of the box in as3 is no easy task. Here is a tutorial explaining the several approaches that have been attempted over the years and what works and what does not:
http://www.dannyburbol.com/2009/01/movieclip-clone-flash-as3/

How do I apply different classes to different frames in flash CS5?

I am coding in actionscript 3 and need some help with classes. I want the first frame to have its own class/package and I want the other frames to share another class/package. How do I do this?
Don't. It is neither a clean nor a recommendable way to organize ActionScript code in your project. Use classes and packages the way they were intended: for object-oriented programming. In fact, you should use frame actions only if you have minor tasks to do, especially controlling the timeline (stop(); and such), or to create or remove objects at a point in time.
If you want your frames to spawn new behavior, create and/or remove class instances on the stage instead - they can be transparent or fill the entire stage, so they will not be noticed by users, but your program will have proper encapsulation. You can attach a Class to each MovieClip in your library, so you can put one in each frame of your timeline, and you can even edit the timeline of that MovieClip, if you want to.
Whichever you decide, you should read up on object-oriented programming in ActionScript here.
The timeline is, at the end of the day, a sub-class of a MovieClip. Each frame is a frame of that MovieClip, so you cannot associated a class with each frame. You could use a single class and use the "undocumented" addFrameScript to associate a method with each frame. Better yet, I'd probably just add a new MovieClip to each frame with its own unique subclass. So frame1's BaseClass would be Frame1MovieClip.as and frame2's BaseClass would be Frame2MovieClip.as. If you want the frames to share a class, just extend that frame across the number of frames you want.
1 2 3 4 5
layer2 [o]
layer1 [o ]
So "layer2" would contain a MovieClip with Frame1MovieClip.as as the BaseClass and layer 1 would have a different BaseClass.