startDrag(container) after using container.loadMovie()

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

I'm stumped, plain & simple.

I have a container that loads SWFs and I want to be able to startDrag on that container after a SWF has been loaded. onRelease it will stopDrag, duplicate the MC, set the _x & _y of new MC to _x & _y of container at point of stopDrag, and place the container in it's original _x & _y.

here's what i'm using,
Code: [ Select ]
piecePreview.onPress = function(){
    startDrag(piecePreview,false);
}
piecePreview.onRelease = function(){
    stopDrag();
    name = ["_" + totalPieces];
    duplicateMovieClip(piecePreview,name,totalPieces);
    name._x = piecePreview._x;
    name._y = piecePreview._y;
    piecePreview._x = 692;
    piecePreview._y = 10;
    totalPieces++;
}
  1. piecePreview.onPress = function(){
  2.     startDrag(piecePreview,false);
  3. }
  4. piecePreview.onRelease = function(){
  5.     stopDrag();
  6.     name = ["_" + totalPieces];
  7.     duplicateMovieClip(piecePreview,name,totalPieces);
  8.     name._x = piecePreview._x;
  9.     name._y = piecePreview._y;
  10.     piecePreview._x = 692;
  11.     piecePreview._y = 10;
  12.     totalPieces++;
  13. }


Everything works great untill an SWF has been loaded into the container. I've tested setting _alpha & some other things to the container after the loadMovie() has taken place and they all work yet startDrag() just takes a crap on me :?

Just for peetsake here's how i'm loading into the container,
Code: [ Select ]
function previewPiece(){
    _root.piecePreview.loadMovie(dataList[pieceList.getSelectedIndex()]);
}
  1. function previewPiece(){
  2.     _root.piecePreview.loadMovie(dataList[pieceList.getSelectedIndex()]);
  3. }

This function is the change handler for a listbox.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

The situation occurs because once the movie gets fully loaded, all actions on the clip being loaded to get overwritten.

You will either have to create a dynamic preloader to check when the movie is fully loaded AND THEN assign the onPress/onRelease actions (basically use an onEnterFrame handler to check if movie is loaded, if movie is fully loaded assign onPress and onRelease handlers)

Or... [now this is just a theory, i haven't tested it] you can code the actions in frame 1 of the external movie but assign the actions to _parent instead of piecePreview.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Yep that's pretty much what i've been getting everywhere :P

your theroy came to mind for a breif second but I discarded it when I thought about having to add queryString information telling the external swfs if they should be in build or presentation mode (trying to use the same piece.SWF's for this construction interface & a presentation deal) but now that i think about it, with some of the stuff i have planned for the externals i just might HAVE to do it this way :?

Thanks lostinbeta :D you answered my question & unknowingly helped me with a problem i think i might run into later :lol:
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Well I have to go in a minute, but I can give you the basic-rundown of how I usually accomplish this with a dynamic preloader (I build a lot of XML generated galleries in Flash...lol).

Code: [ Select ]
//create clip that will house the onEnterFrame handler to check clip loading external movie
this.createEmptyMovieClip("checkLoad", 1000);
//create function to load and preload movie...
function preLoad(external){
  clipYouAreLoadingTo.loadMovie(external);
  checkLoad.onEnterFrame = function(){
  //getBytesLoaded and getBytesTotal code for clipYouAreLoadingTo here
  //basic if statement to check
  if (bytesloaded == bytestotal && clipYouAreLoadingTo._width > 0){
    //assign actions to clip
    delete this.onEnterFrame;
  }
}
  1. //create clip that will house the onEnterFrame handler to check clip loading external movie
  2. this.createEmptyMovieClip("checkLoad", 1000);
  3. //create function to load and preload movie...
  4. function preLoad(external){
  5.   clipYouAreLoadingTo.loadMovie(external);
  6.   checkLoad.onEnterFrame = function(){
  7.   //getBytesLoaded and getBytesTotal code for clipYouAreLoadingTo here
  8.   //basic if statement to check
  9.   if (bytesloaded == bytestotal && clipYouAreLoadingTo._width > 0){
  10.     //assign actions to clip
  11.     delete this.onEnterFrame;
  12.   }
  13. }


If that makes any sense. It's 1:20am, i'm tired....lol.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.