Stoping a loaded swf on its first frame?

  • CStrauss
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: St. Louis MO. USA

Post 3+ Months Ago

I'm back with another question about stopping a swf file that I loaded in from outside the main swf file and having trouble to figure out how to make it stop so it doesnt play until I write code to do so later.

Code: [ Select ]
        var mainLoader:Loader = new Loader();
        var mainRequest:URLRequest = new URLRequest("swf/"+ swf_file[0]);
        mainLoader.load(mainRequest);
        mainLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,mainLoad);
        
        function mainLoad(event:Event):void{
            // place postion on stage
            main_area.x = mainPlacementX;
            main_area.y = mainPlacementY;
            //add first file to stage
            main_area.addChild(mainLoader);
            
            main_area.mainLoader.gotoAndStop(1);
            
            // Resize
            main_area.width = main_area.width / 2;
            main_area.height = main_area.height / 2;
        }// End mainLoad function
  1.         var mainLoader:Loader = new Loader();
  2.         var mainRequest:URLRequest = new URLRequest("swf/"+ swf_file[0]);
  3.         mainLoader.load(mainRequest);
  4.         mainLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,mainLoad);
  5.         
  6.         function mainLoad(event:Event):void{
  7.             // place postion on stage
  8.             main_area.x = mainPlacementX;
  9.             main_area.y = mainPlacementY;
  10.             //add first file to stage
  11.             main_area.addChild(mainLoader);
  12.             
  13.             main_area.mainLoader.gotoAndStop(1);
  14.             
  15.             // Resize
  16.             main_area.width = main_area.width / 2;
  17.             main_area.height = main_area.height / 2;
  18.         }// End mainLoad function


thats basically my code that loads the swf into a movieclip called main_area and I figured after I add it to the main_area i could use code like this to stop it.

Code: [ Select ]
main_area.mainLoader.gotoAndStop(1);


but it gives me a funny error about that is something else I need to do to stop it soon as it loads cause I want to make later so you click it and then it will start to play but only after its clicked.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23460
  • Loc: Woodbridge VA

Post 3+ Months Ago

Maybe I'm missing something here, but why not just add a stop action to frame 1 of the swf you are loading?
  • CStrauss
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: St. Louis MO. USA

Post 3+ Months Ago

well that would work but I'm thinking outside the box right now testing and learning basically the paths of the swf files are being pulled from a data base so I'm assuming the swf file that was say uploaded didnt have a stop action in it so I want to find away to control it in case it didn't have stop action and allow the user to click a button to stop and play it etc.

Does that make sense?
  • CStrauss
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: St. Louis MO. USA

Post 3+ Months Ago

I found away to do it so far it works like I want but uncertain of any unforeseen problems it might cause down the road, but thats what fun about programming right? :P I still like to see any examples posted by others to compare and what not if its better then what I did.

But what I did I changed some code around. but my main_area movieclip is defined long before this part of the script runs and I also had to move the placement of it when it is added to stage after but basically I changed this line of code:

Code: [ Select ]
main_area.addChild(mainLoader);


to this and then added a go to and stop to it.
Code: [ Select ]
main_area = MovieClip(mainLoader.content);
addChild(main_area);
main_area.gotoAndStop(1);
  1. main_area = MovieClip(mainLoader.content);
  2. addChild(main_area);
  3. main_area.gotoAndStop(1);


i found a snippet of code on the net some where not sure really what the main_area = MovieClip(mainLoader.content); is really doing cause as I stated before I already declared main_area as a new movie clip earlier and that line of code looks like to me its creating another movieclip or soemthing. but none the less I'm good for now :D
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1827
  • Loc: In the Great White North

Post 3+ Months Ago

you did it correctly. Your problem before is that you weren't trying to stop main_area. What happens in Flash is that loaded content "replaces" the target (in your case the new clip called main_area) instead of loading inside the target as the name would suggest.

What that means is you need to call commands against the target name as if it was the actual clip you where trying to change.
  • CStrauss
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: St. Louis MO. USA

Post 3+ Months Ago

hmmm so to get my original code to work it would be something like:

Code: [ Select ]
mainLoader.gotoAndStop(1);


since the content stored in my loader is replacing as you say my main_area object. correct or am I still off.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1827
  • Loc: In the Great White North

Post 3+ Months Ago

I think your still off a little bit. From your code I believe that "mainLoader" is actually the load constructor object. IE the thing that flash uses to actually process the data transfer of the load.

The whole replacement thing is a little strange because the loaded content replaces the target but it retains the targets name. So I assume in your original code
Code: [ Select ]
main_area.gotoAndStop(1);
would have been correct.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 5 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
 
 

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