As 2.0 class objects- how to swap depths of a movie clip

How do you bring an object to the top? if it's just a movie
clip, I could do a swapdepths, but if it's a movieclip that's part
of an AS 2.0 object, how do you swap depths of the whole object?
I create 2 objects (same class) which each have a movieclip
within them. The movie clip is created on a unique level with
getNextHighestDepth().
I have a button which tries to swapDepths of the 2 objects,
but I can't get it to work. Can anyone help?
here's the detail:
1. create a symbol in the library called "someShape_mc" and
put some shape in it - a circle, a square, whatever - this symbol
is exported for action script, and has an AS 2.0 Class of
"ClassObject" ( I also put a dynamic text field in the shape to
display the current depth - it's called "depth_txt")
2. create a button called "swap_btn" on the stage.
Frame 1 has the following actionscript:
var BottomObject:ClassObject = new ClassObject(this,100,150);
var topObject:ClassObject = new ClassObject(this,110,160);
// for the button add this:
Swap_btn.onRelease=function() {
// try it with the full path:
_root.BottomObject.__LocalMovieClip.swapDepths(_root.topObject.__LocalMovieClip);
// try it with with just the objects:
BottomObject.__LocalMovieClip.swapDepths(topObject.__LocalMovieClip);
// try it with the object as a movieclip
BottomObject.swapDepths(topObject);
trace("Did it Swap?");
// try it with a method in the class....
BottomObject.swapIt(topObject.__LocalMovieClip);
BottomObject.swapIt(topObject);
trace("nope... no swapping going on...");
================================
here's the AS file: "ClassObject.as"
class ClassObject extends MovieClip{
var __LocalMovieClip;
var __Depth;
function ClassObject(passedIn_mc:MovieClip,x:Number,y:Number)
__Depth = passedIn_mc.getNextHighestDepth();
__LocalMovieClip =
passedIn_mc.attachMovie("someShape_mc","__LocalMovieClip",__Depth);
trace("made a shape at " + __Depth);
__LocalMovieClip._x = x;
__LocalMovieClip._y = y;
__LocalMovieClip.depth_txt.text = __Depth;
public function swapIt(targetMc) {
__LocalMovieClip.swapDepths(targetMc);
__LocalMovieClip.depth_txt.text =
__LocalMovieClip.getDepth(); // no difference.
trace("Tried to swap from within the class...");
========================
so- the goal is to bring the "bottom" Class object on top of
the "top" object. The button tries various methods of swapping the
depths of the movie clips - but there is not one that works. What
am I missing?
tia
ferd

Thank you for your response - and here I have included the
code I reworked to show how it works, and doesn't work. you're
right about not needing the extra containers, but this example is
part of a bigger thing...
I'm confused - it works ONLY if I attach the movie outside
the class, even though the "attachment" occurs, I'm thinking, at
the same scope level, that is, _root.holder_mc, in both examples.
it seems that the advantage of having a class is defeated
since I have to do the extra coding for each object that will be
created. It's like the class can only have a reference to the
movieclip outside itself, and not have a clip INSIDE that is fully
functioning. am I right about this? Is there someplace good I can
learn more about class objects and movieclip usage?
also, my class object IS a movieclip, but " this.getDepth() "
is meaningless inside the class object. hmmm...
This one works..... attaching the movies at the root level
(to a holder_mc)
// Frame 1
tmp1 =
holder_mc.attachMovie("someShape_mc","tmp1",holder_mc.getNextHighestDepth());
var BottomObject:ClassObject3 = new
ClassObject3(tmp1,100,150);
tmp2 =
holder_mc.attachMovie("someShape_mc","tmp2",holder_mc.getNextHighestDepth());
var topObject:ClassObject3 = new ClassObject3(tmp2,110,160);
// for the button add this:
Swap_btn.onRelease=function() {
BottomObject.swapIt(topObject);
trace("clicked button");
// ClassObject3.as
class ClassObject3 extends MovieClip{
var __LocalMovieClip:MovieClip;
function
ClassObject3(passedInMovieClip:MovieClip,x:Number,y:Number) {
trace(" this class object is at ["+this.getDepth()+"]");
__LocalMovieClip = passedInMovieClip;
__LocalMovieClip._x = x;
__LocalMovieClip._y = y;
public function swapIt(targetMc:MovieClip):Void {
trace("do the swap in the class");
trace("===========================");
trace("target type :" + typeof(targetMc));
trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
__LocalMovieClip.swapDepths(targetMc.__LocalMovieClip);
This one does NOT work..... attaching the movies within the
class object...
// Frame 1
var BottomObject:ClassObject2 = new
ClassObject2(holder_mc,100,150);
var topObject:ClassObject2 = new
ClassObject2(holder_mc,110,160);
// for the button add this:
Swap_btn.onRelease=function() {
BottomObject.swapIt(topObject);
trace("clicked button");
// ClassObject2.as
class ClassObject2 extends MovieClip{
var __LocalMovieClip:MovieClip;
function
ClassObject2(passedInMovieClip:MovieClip,x:Number,y:Number) {
__LocalMovieClip =
passedInMovieClip.attachMovie("someShape_mc","stuff1",passedInMovieClip.getNextHighestDep th());
__LocalMovieClip._x = x;
__LocalMovieClip._y = y;
public function swapIt(targetMc:MovieClip):Void {
trace("do the swap in the class");
trace("===========================");
trace("target type :" + typeof(targetMc));
trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
__LocalMovieClip.swapDepths(targetMc.__LocalMovieClip);

Similar Messages

  • Premier After Effects... How does one places the whole movie clip into AF?

    After years of using Premiere, I’m looking at using After Effects. Premiere does most of what I need (I don’t need moving graphics and titles) but the masking and rotoscoping seems to be better in After Effects. I’ve started a great video by Tom Green at school. This is probably silly question- I don’t understand is how does one places the whole movie clip into AF? I only see 30 seconds or so of the 5 minute clip on the timeline in AF.

    Ahh, thanks. I simply add more minutes (the length of the clip) into the "new composition".
    A new problem: When I try a dynamic link with premiere AE says “Failed to connect to adobe Premiere Pro Dynamic Link”, but PP will link with AE. I just installed AF last week. Do I need to uninstall and reinstall them (along with the rest of the Creative Suite)?

  • I have 3 consecutive movie clips that I am trying to drop into the drop zone but it only recognizes the first one and only produces the firts one in a DVD. How can I drop all three  movie clips into one drop zone

    On IDVD, I have 3 consecutive movie clips that I am trying to drop into the drop zone to create a DVD but it only recognizes the first one I dropped and only produced the first one in a DVD. How can I drop all three  movie clips into one drop zone.

    I have had some luck doing the following: Export each clip from imovie as a quicktime clip. Open iDVD and create a new project. Import a few stills into iDVD and then click on the button that gets created to get into the screen where the individual slides appear. Drag each quicktime into that screen and arrange in the order you want. You can then delete the stills. The button that appeared when you dropped in the stills will launch a complete show.

  • How do I View Guides for Movie Clips in Relation to Entire Scene?

    My boss purchased a flash animation from a company a few months ago that she now needs me to fix. The goal is to resize the animation to different dimensions for a new banner. I took the original file, brought up the document settings, and changed the size to the new one we need, and hit the "scale content" checkbox. The file I have after doing this is shown below; I have highlighted the shape I will be talking about in pink. Nothing is the correct size now so I am trying to resize them to fit the stage area. I am having trouble with the green shape that is highlighted Pink.
    The person who originally made this file made that highlighted shape into a movie clip and then dropped it in to the main timeline. I was wondering if there was a way that I could see where that shape is in relation to the area of the entire stage and the other objects in the main timeline? Meaning if I am inside of the greenblock movie clip all I see is what is below:
    With this view I cannot tell where that shape is in relation to everything else. I am hoping someone can tell me how to view the guides from my main file inside of this movie clip( I already have guides turned on), or any other way of seeing what size and where my shape is in relation to rest of the objects on the stage of my main file. I would take any option that would let me tweak the green shape inside of the movie clip and see in real time how it looks in relation to the rest of the items on the stage as I make changes.
    Any suggestions on how to get perspective on where my movie clip is in relation to the stage and other objects on it would be greatly appreciated.
    Sincerely,
    Tissal

    Somehow double clicking on your system seems to be connected to the command
    fl.getDocumentDOM().enterEditMode('');//the view where you don`t see the rest of your stage
    whereas normally it defaults to
    fl.getDocumentDOM().enterEditMode('inPlace'); //the view where you can see everything els on stge alphablended
    you can either create a shortcut to
    edit>edit in place or alter the standard behaviour of your double click
    or right click(Windows) or ctrl-click(MAc) the mc and choose Edit in Place

  • Flash html5 - How can i make an internal movie clip slow down and stop when it get to a certain frame?

    I am creating an automotive braking system using flash and have a wheel turning. I want the wheel to slow down and stop after the brake pedal is pushed at a certain frame. I know I could do this with frame by frame animation but was hoping there was a short cut - javascript?? If not the slowing down portion then is there code for just making the internal movie clip (wheel turning) to stop when it gets to a frame.? Thanks

    you can use the ticker class to create a loop that you use to control the wheel's rotation or frame, TweenJS v0.6.0 API Documentation : Ticker

  • In actionscript 3.0 how do i make a nested movie clip button go to a frame on the main timeline

    I am making a website based in flash actionscript 3.0 i have a button nested in its own movie clip, because I have the button expanding to be able to read it i have figured out the only way to do this is by creating it as a movie clipa nd inside the movie clip creating it as a button
    I added an event listener to the blog button by saying,
    blog.addEventListener(MouseEvent.ROLL_OVER,gotoblog);
    function gotoblog(evtobj:MouseEvent){
         gotoAndStop(2)
    this part of the code works it goes to the 2nd frame of the timeline it is in and stops wich is a blown up version of the origanal symbol
    i added on frame 2 a second command
    blog.addEventListener(MouseEvent.CLICK.gotoblogpage);
    function gotoblogpage(evtobj:MouseEvent){
    gotoAndStop("blogframe")
    trace("the blog button was clicked")
    i have named the symbol blog and have name the frame of where the blog page is going to be "blogframe" this line of code at the bottom is where i run into trouble the output window in Flash is saying "The blog button was clicked" just like i want it to. no errors are accouring why than is the playhead not going to frame "blogframe"? if the button is working when i click it the code is right i belive the problem here is it does not want the playhead to go to the frame i want it to. So i gues my question is, how can i make a button withing a movie clip interact with the main timeline?

    I have a similar problem if could please help me i'd really apreciate it!!
    So i have a looping animation of some thumbnails, the hierarchy goes like this
    Scene1(main timeline) -> imgBar(MC)->imgBarB(MC within the imgBar MC)
    My buttons symbols are in the last MC "imgBarB" where i have this code:
    ss1.addEventListener(MouseEvent.CLICK, OneButtonClicked);
      function OneButtonClicked(event:MouseEvent):void{
      MovieClip(root).gotoAndStop("ssbox1");
    I want to control the Btns in my "imgBarB" MC to play a labeled frame(named "ssbox1") on another MC on the main timeline,this other MC goes like this:
    Scene1(main timeline)->ssbox_mc(MC where my labeled frame is)

  • How to obtain instance name of Movie Clip?

    Hello!
    Is there a way to get the instance name of a move clip once it's on the stage?  In my dress up game, I need to know which items are on the doll in order to keep them visible.  My drag and drop feature uses an array and currentTarget:
    var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
              for(var i:int = 0; i < dragArray.length; i++)
                        dragArray[i].buttonMode = true;
                        dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
                        dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
    function item_onMouseDown(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.startDrag();
    function item_onMouseUp(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.stopDrag();
                   if(clip.hitTestObject(Doll.Skins))
                                 //Here's where the problem starts!   ----------------------------------------------  //
                                  trace("It's on the doll!");
    It can successfully run this code.  However, instead of tracing "It's on the doll!", I'd like to turn the currentTarget into it's instance name, which should be "Doll.Drawers.Dress1" etc... and then store that name in an array.
    How would I do this?
    I've looked into e.target.name, but I keep getting errors...

    use the name property of clip (if that's the movieclip whose name you want):
    var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
              for(var i:int = 0; i < dragArray.length; i++)
                        dragArray[i].buttonMode = true;
                        dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
                        dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
    function item_onMouseDown(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.startDrag();
    function item_onMouseUp(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.stopDrag();
                   if(clip.hitTestObject(Doll.Skins))
                                 //Here's where the problem starts!   ----------------------------------------------  //
                                  trace(clip.name);  // but that won't be Doll.Drawers.Dress1.  it might be Dress1.

  • How do I inactivate all other movie clips except the running one.

    Hello guys
    I would need help to inactivate all other actions on movie clips while the active movie clip is running. So in my flash scen when the user makes a roll over on a movie clip I would like that movie clip to play all frames in that movie clip before the user can roll over on an other movie clip. So the active movie clip don't gets interupted. What actionscript 2.0 should I look for?
    Thanks!
    /Klas

    You could use a boolean variable in a conditional that wraps whetever functionality the objects have to prevent them from taking those actions.  So when you rollover an object it starts to activate its animation or whatever and sets that boolean to prevent any others from doing the same.  And when it completes its actions it rets the boolean.
    If you show your rollover code it might be easier to show an example, but it might be something like...
    var allowPlay = true;
    mc1.onRollOver = rolloverFunction;
    mc2.onRollOver = rolloverFunction;
    mc3.onRollOver = rolloverFunction;
    function rolloverFunction(){
       if(allowPlay){
           allowPlay = false;
           this.play(); // or whatever action your rollover executes
    and when that animation completes the movieclip resets the allowPlay to true.
    _root.allowPlay = true;

  • How do you horizontal scroll a movie clip?

    Can anyone suggest any resources for horizontal (left to right) scrolling a movieClip? I want to be able to scroll through a movie clip that has pictures in it. I can't find any good ones that explain the code. FYI, I do not want the user to use a scroll bar to scroll through. They should be able to touch the screen (on the movieClip) and scroll left or right. I looked at the ThrowPops plugin example on Greensock's website but the code is not explained very well.  So I need a basic description of how to scroll a movie clip.

    google: as3 beginner tutorial flash ios movieclip scroll

  • Help! Need to know how to swap depths with Action Script 3

    So i have several movie clips all on one layer.  Its an interactive gallery where when a photo is selected it plays the movie clip and the photo grows to fill the screne.  The problem is, since the animations take part within the movie clips and all the movie clips exist on the same layer when they are selected and grow to fill the screne they are being hidden behind all the movieclips infront of it in that layer.  I know that there is an action to bring movieclips to the highestdepth or to front on click/release but i do not have a clue where to start. But I am working in actionscript 3.0
    If it will help we can post a link to the flash file.
    Thanks!

    I would probably use setChildIndex like
    container.setChildIndex(clickedOnClip, container.numChildren - 1);
    you could make a more general bring to front as well:
    function bringToFront(obj:DisplayObject):void
        obj.parent.setChildIndex(obj, obj.parent.numChildren - 1);

  • How to stop Timer event inside movie clip that does not exist?

    Hello. I am using Adobe Flash CS6.
    As this topic title says. how to stop Timer event nside movieclip that does not exist?
    I mean my fla stracture is  there are 2 frames on main timeline, and I put mcA on frame 2.
    And I put a button on root that does
    if(currentFrame ==1)
    gotoAndStop(2);
    else if (currentFrame ==2)
    gotoAndStop(1);
    And mcA has AS inside and it is
    var T_Timer:Timer = new Timer(1000,0)
    T_Timer.addEventListener(TimerEvent.TIMER, test)
    function test(e:TimerEvent):void{
    trace("Timer active")
    T_Timer.start();
    I need to stop T_TImer from root on frame 1, not on frame 2.
    but, "mcA.T_Timer.stop();" won't work.
    I get TypeError: Error #1010 error.
    I don't know how to stop this timer event. I have to stop it from root, and I can't use EVENT_REMOVED in this case.

    If the object doesn't exist you cannot do anything relative to targeting it.  Maybe you should move the timer to the main timeline where you can access it any time.

  • Instantiating Objects from the library from within the movie clip

    Ive been Instantiating Library object from linked external
    action script files and it works fine.
    var PPEbtn1 = new btnPPE;
    but when i try to do it from within the main swfs timeline it
    fails to work and i recieve an error if anyone could please help it
    would be most apreciated. thanks

    You need to get the application domain of the external swf
    and use its getDefinition method. Cast the result to a Class and
    then you can instantiate the symbol.
    Here's some example code where "library" is an externally
    loaded swf:

  • How to remove EventListener inside a movie clip

    I have a movie placed on stage (on first frame of Timeline) and an Event.ENTER_FRAME EventListener inside the movie , when I click a button on stage that takes me to 2nd frame, I want to remove the Event Listener inside the movie. How can that be done.
    I think it might help improve performance, or is it automatically removed or shut

    Circle1.removeEventListener(Event.ENTER_FRAME,moveCircle);
    Circle2.removeEventListener(Event.ENTER_FRAME,moveCircle);
    Circle3.removeEventListener(Event.ENTER_FRAME,moveCircle);
    are correct. But it seems that u use them at  a wrong place.
    Cant help more without seeing all codes.
    Circle.removeEventListener(Event.ENTER_FRAME,moveCircle);   doesnt work as I know.

  • How to limit the number of movie clips on stage?

    I am making a game where tempEnemy in an array of enemies gets made on random. Every time the player advances a level, more insects appear. This is how I want it to be, but when the user is high on a level, too many enemies get made that are impossible for the user to kill. How can I limit the number of enemies being displayed on stage, but not hinder the randomness of the enemy production?
    function makeEnemies():void
        var chance:Number = Math.floor(Math.random() * 150);
        if (chance <=  + level)
            tempEnemy = new Enemy();
            //Math.random(); gets a random number from 0.0-1.0
            tempEnemy.x = Math.round(Math.random() * 550);
            addChild(tempEnemy);
            enemies.push(tempEnemy);
            tempEnemy.speed = enemyBaseSpeed + ((level - 1) * speedLevelInc);
             if (tempEnemy.speed > MAX_SPEED)
            tempEnemy.speed = MAX_SPEED;

    Keep a total count of the enemies that are present versus whatever maximum is currently allowed for a level and do not produce any more than the difference between the maximum and the current number of them.

  • How do I precisely select a movie clip in event browser?

    I've got a movie in event browser
    I'm having trouble putting the mouse on half a second before the end
    I know I can take off snapping which will solve my problem (I assume)
    Just wanted to know if there was a keyboard method?
    Use J, K or L? Just done this. Works OK
    Or maybe click in the time field and put the exact time?
    How do I get into the time box using just the keyboard?
    Thanks
    Omar

    Using the numeric keypad (only on extended Apple keyboards, not on MacBook's etc) you can use the minus [-] key to set backwards or [+] key to set forwards, then type on the adjacent numeric keys how many frames to move backwards/forwards (using the numpads' enter/return key at the bottom right to commit).
    For example: if moving the playhead back 15 frames, I would press they keypad's [-] key then type [1] then [5] on the keypad, pressing the return key at the bottom right to finish. Also, using the keypad's [.] after the numbers, tells FCP to use seconds and not frames. So moving forward by 12 seconds can be done by pressing [+] then [1] then [2] and finally [.] - completing with the return.
    With the event browsers clip, I would use the right cursor key to ensure it's the final frame - then using the [-] on the keypad, type in the frames per second used divided by 2; hitting return to move the selection point to the correct position.

Maybe you are looking for

  • Can I use an Airport Extreme Base Station from the USA in Europe ?

    A friend of mine gave me an Airport Extreme Base Station from the USA to Germany. When I hook it up to my PB by ethernet cable the Computer can't find the Base Station at all. If I use my Sonnett Aria Extreme PCI card it finds the station but in the

  • Sizing Save as PDF Output

    One of the volunteer activities I do is to help manage the photograph archive of the family data pages in historic and fragile family Bibles. I like to first produce the data pages in a PDF so that nearly anyone transcribing can use a PDF reader to z

  • Essbase Gurus this is the time to help for this scenario in securityfilters

    Hi Gurus, I have one scenario in ASO(11v) ,I have to create security filters for two users for eg: GEO Account  30000 wen we drill down india turnover 10000 paris turnover 100000 UK turnover noacess I created "GEO","india","paris" this security filte

  • Knowledge articles full compilation failed

    Hi, We have CRM 7.0 Interaction center. I executed the knowledge article full compilation by getting in to the IC_MANAGER business role. In the middle of the full compilation, the job failed with the reason MEMORY_NO_MORE_PAGING. Now basis corrected

  • Can't seem to install Mountain Lion.

    Download took FOREVER and now in fourth auto attempt to Install. It gets to 5 minutes or less left and stops due to "error" and restarts trying the install automatically. Can I stop the process of the install safely and get back to Snow Leopard? And