0
votes

I have made a MovieClip and attached it to the below code.When i test the movie and i have already placed an instance on stage it works fine.When i instantiate the object through code and add it to stage it disappears when i click it.I work in flash.

package {

import flash.display.MovieClip;
import flash.events.MouseEvent;
import fl.transitions.easing.*;

import com.greensock.*; 

public class Card6 extends MovieClip {

    public function Card6( )        {
        addEventListener(MouseEvent.CLICK, Enter);
    }
    private function Enter( ev : MouseEvent ) {
        TweenMax.to(this, 0.25,  { rotationY: 180 }  );
    }
  }
}

This is the code where i instantiate the MovieClip from the library,Card6 is the base Class.

var photo: MovieClip = new PhotoB( );
photo.x = 100;
photo.y = 300;
stage.addChild(photo);

UPDATE : I succeed to make it work i don't know how since i didn't changed the code a bit.The problem is i don't know what is the solution and i encounter the same problem in other examples. This is the code i used in the first frame and worked.

var sp : DisplayObject = new border( ); //<-- Different name,same Object
addChild(sp);
sp.x = 400;
sp.y = 300;

And this is the code i used for the Main Class

package {

import flash.display.MovieClip;

public class DocumentH extends MovieClip {

    public function DocumentH( )    {
    var sp : MovieClip = new border( );
    addChild(sp);
    sp.x = 400;
    sp.y = 300;
    }
  }
}

I can't tell what made the diferrence and worked.I try to do the exactly same thing in another fla and failed.In library i have only one square which a have convert it to MovieClip. (Here is a link with the fla http://www65.zippyshare.com/v/65975812/file.html). I use Flash CS4 Pro

2

2 Answers

0
votes

I would guess it has something to do with the 3d transformation center point - when you add it to the stage these are set to the center of the object in question. Try setting z = 0 before you do addChild(), to initialize the 3d matrix, and see if it disappears instantly then as well.

If it does, you might need to look at where the 0-point in the movieclip is, or maybe even do 3d transforms on it instead of regular x,y ones.

EDIT: It's hard to figure out exactly what needs to be done without more information on how your library item looks, but try translating the 3d matrix opposite the way you are moving it, eg photo.transform.matrix3D.appendTranslation(-100, -300, 0); after your movement. Also try setting all your positions to 0, and make the flash player window larger, so you can see your object. This should give you some hint of what is going on :)

0
votes

Try changing your duration to something like 5 seconds so you can see it tweening.