Results 1 to 15 of 15
-
April 15th, 2012, 11:48 AM #198Alien Rock Star
postsLoad External SWF into MovieClip on timeline?
I have a flash Project, and I have external SWF's that are loading and unloading into my project. However I need the external SWF's to be under certain layers. What I would love to be able to do is load my external SWF's into a MovieClip that is already residing on the layer underneath those items. However I have no idea how to do this.
I have the files here. Pretty straight forward, the main SWF ("mod_loading_2.swf"), loads and unloads the other two SWF's("m-1_intro.swf", and "m-2_WIB.swf"). There is a layer named loader layer, and I would like to load the external SWF's into a movieClip on that layer. The load and upload code are in the main SWF, and that is what I need help with.
How do I load these SWF's into a MovieClip on the timeline?
-
April 15th, 2012, 01:35 PM #21,391Registered User
postsLoader instances are basically DisplayObjects - in other words they are just like MC, Sprite, etc - you can add/remove them from the stage just like other DOs - you can also then control the DisiplayList stack by targeting a particular z-order index using the addChildAt() method specifying the object and the index as in:
addChildAt( theLoaderInstance, 0 ); <- this would place the DO at the bottom-most layer of the z-order
however, if you want to target a preexisting DO use: theObjectInstance.addChild(theLoaderInstance);
-
April 16th, 2012, 02:55 PM #3
-
April 16th, 2012, 06:30 PM #498Alien Rock Star
postsOk, I tried this, and it looks like my first module is loading into the movieClip on the desired layer, however it breaks my other navigation buttons, so I cannot unload and load the next module.
It gives me this error:
So apparently I need to rescript my buttons and dispatch events from the module that is loaded. So I tried to add movieClip(parent) to my buttons and dispatch events, but that didn't seem to work.Code:ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/removeChild() at mod_loading_2_fla::MainTimeline/MM2_Load() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at M_fla::title1_1/frame45() at flash.display::MovieClip/gotoAndStop() at M_fla::title1_1/next_mod()
What do I need to do to get my other listeners to recognize the change?
-
April 16th, 2012, 06:31 PM #598Alien Rock Star
posts
-
April 16th, 2012, 08:07 PM #6
-
April 16th, 2012, 11:09 PM #798Alien Rock Star
postsThanks for the info, but I don't think that is going to work for this particular situation. I will keep it in mind for the future though. Thanks!
Can anyone else help me figure out how to get my buttons to redirect to be able to load and unload. From the loading script in the main FLA, I changed the last function on the first frame to this:
WHere "loader_space" is the instance name of the movieClip on my stage that I wan the SWF to load into. That works, and the SWF loads properly.Code:function done(e:Event):void { removeChildAt(0); percent_txt = null; loader_space.addChild(load_mod); gotoAndPlay("M-1_Intro"); e.target.content.gotoAndPlay(2); }
However after that, the button in the loaded SWF, M-1_intro.swf, no longer works to load and unload the next SWF. The button sends the playhead to a frame with this dispatch event on it:
I tried adding another .parent in there as I figured it is now one more movieClip down, and that didn't work. I also tried removing the MovieClip(parent) altogether, because from what I understand it isn't necessary since dispatch events "bubble up". But that doesn't work either.Code:MovieClip(parent).dispatchEvent(new Event("MM2_Load", true));
What do I need to do to get my button to work again, and unload the current SWF, and load the second. (without breaking the existing preloader)
If anyone can help, I would really appreciate it.
Thanks in advance!
-
April 17th, 2012, 11:18 AM #898Alien Rock Star
postsActually...
Isn't there a way to just tell the var "load_mod" to sit at a certain depth?
Anyone?
-
April 17th, 2012, 11:57 AM #9
-
April 17th, 2012, 12:41 PM #1098Alien Rock Star
postsThat's great!! If I put a number in the depth field, it apparently is setting the external SWF in between layers, however, I can't seem to figure out how it is placing the depth. I have three buttons on the same layer, and two are showing up in front of the external SWF, and the third is behind it. That is with a depth of three. What exactly is the depth referring to?
-
April 17th, 2012, 01:43 PM #11
-
April 17th, 2012, 01:58 PM #1298Alien Rock Star
postsOk, sounds good. So I have some bitmap images on the stage on a certain layer of my project. Some are showing up in front of and some behind the loaded SWF. Clearly they must be on different depths, although they physically exist on the same layer. Can I adjust the depths of these objects?
-
April 17th, 2012, 02:45 PM #13
Every displayobject is at a separate depth, but some objects are not as "separate" as they might appear in the authoring environment.
For example, you have three vector shapes drawn on the stage: circle, rectangle, triangle.
They are all part of the same graphics object.
In order to create 3 separate shapes, you would have to wrap each one in a MovieClip and name it.
The drawn shapes then become properties of their respective MovieClips.
You can then address the MovieClips by name and set their displaylist indexes in AS3.
Generally speaking, most experienced developers tend to group related elements within Sprites in order to simplify and organize the displaylist.
For example, you could have a Sprite called background, a Sprite called content, and Sprite called nav.
- background contains the background elements of the site interface.
(bitmap backgrounds and UI decorations) - content contains the elements that change from page to page.
(for example, loaded SWF files) - nav contains the site navigation system
(buttons)
- background contains the background elements of the site interface.
-
April 17th, 2012, 03:35 PM #1498Alien Rock Star
postsOkay, so how do I tell a specific MovieClip to be a nav item? And a different movieClip to be a background?
-
April 17th, 2012, 03:46 PM #15
Simple:
At this point the document class displaylist has three children and two grandchildren:Code:// create the containers var background:Sprite = new Sprite(); var content:Sprite = new Sprite(); var nav:Sprite = new Sprite(); // add the containers to the displaylist in the order you want them // in this case, nav is on top addChild(background); addChild(content); addChild(nav); // create a new instance of Button var button:MovieClip = new Button(); // add button to the nav container nav.addChild(button); // create a new instance of Background var bg:BackGround = new Background(); // add bg to the background container background.addChild(bg);
index 0 - background > index 0 - bg
index 1 - content
index 2 - nav > index 0 - buttonLast edited by snickelfritz; April 17th, 2012 at 03:51 PM.

Reply With Quote



Bookmarks