|
-
[RESOLVED] Creating a Menu, Problems.. Solutions?
I have a series of swfs that make up a slideshow at the end they have quizes that use _global.correct = Correct_Answer; sort of commands, they all work perfectly.
I want to add a menu with buttons to call to these externals individually (slideshow too long for one sitting, want to break it up).
I made the menu with buttons and currently it throws the externals overtop of the menu, cant figure out how to hide background.
It also messes up the quiz questions, i believe its due to the _global calling.
I could really use some ideas on a better way to go about this menu idea.
Thanks, any input would be greatly appreciated.
-
-
I have a mc with 7 buttons, this is in the mc
Actionscript Code:
function buttonClick(event:MouseEvent):void { var myLoader:Loader = new Loader(); myLoader.x = -187 myLoader.y = -375 myLoader.load(new URLRequest(event.target.name + ".swf")); addChild(myLoader); }
Clip1.addEventListener(MouseEvent.CLICK, buttonClick); Clip2.addEventListener(MouseEvent.CLICK, buttonClick); Clip3.addEventListener(MouseEvent.CLICK, buttonClick); Clip4.addEventListener(MouseEvent.CLICK, buttonClick); Clip5.addEventListener(MouseEvent.CLICK, buttonClick); Clip6.addEventListener(MouseEvent.CLICK, buttonClick); Clip7.addEventListener(MouseEvent.CLICK, buttonClick);
probably a poor use of AS but very eager to learn better ways
-
OK, let me make sure I understand what you are trying to accomplish.
You have a bunch of slidershows in swf format.
Each of these slideshows end with a quiz.
Now, it's too long to go through all the slide shows back to back, so you created a menu to navigate through them so the person can get to the slideshow they need to get to when the time comes.
Your problem is the slideshows cover the menu when they show up, correct?
If that's the case, just create a container_mc movieclip on the stage.
First add container_mc to stage.
Then add menu on top.
Then just use container_mc.addChild(myLoader) to add the swf to the container_mc therefore loading it under the menu bar.
Does that answer your question?
-
Yes thats correct.
I'll try that, just its a menu page, about the same size as the slideshow pages.
What i'd like to accomplish is having the slideshows replace the menu and dissapear when they are done,
or have the slideshows appear over top and have the menu hidden, then unload the slideshows and unhide the menu.
Does this make any sense?
-
Actually no, I thought you were problem was the total opposite.
Can you explain again what you are trying to accomplish and what problem behavior you are running into?
-
I have seven external swf, they are slide shows. I have a main "menu" style swf with 7 buttons. The buttons currently work and load the externals over top of the "menu", but when the externals are done, they stay there.
I am having problems getting them to unload, or maybe there is a better way to have these externals appear on stage.
I tried just calling them to stage and i've tried using a container, I cant seem to resolve this.
Thanks so much for trying to help.
-
OK I'm assuming your loading your swfs like this:
var loader:Loader = new Loader();
loader.load(new URLRequest("myswf.swf");
addChild(loader);
Now here's the trick, in the main swf:
loader.addEventListener("removeIt", removeSWF);
function removeSWF(e:Event):void
{
removeChild(loader);
}
And then in the swf you loaded, when you wanna unload it:
dispatchEvent(new Event("removeIt", true));
-
That makes so much sense, thanks.
I put it like you wrote it and i keep getter access of undefined property loader on line 12, which is the remove child
Here is my code
Actionscript Code:
function buttonClick(event:MouseEvent):void { var loader:Loader = new Loader(); loader.x = -187 loader.y = -375 loader.load(new URLRequest(event.target.name + ".swf")); addChild(loader); loader.addEventListener("removeIt", removeSWF); } function removeSWF(e:Event):void { removeChild(loader); }
Clip1.addEventListener(MouseEvent.CLICK, buttonClick); Clip2.addEventListener(MouseEvent.CLICK, buttonClick); Clip3.addEventListener(MouseEvent.CLICK, buttonClick); Clip4.addEventListener(MouseEvent.CLICK, buttonClick); Clip5.addEventListener(MouseEvent.CLICK, buttonClick); Clip6.addEventListener(MouseEvent.CLICK, buttonClick); Clip7.addEventListener(MouseEvent.CLICK, buttonClick);
Last edited by CoreyC; 09-02-2010 at 02:50 PM.
-
Flash/Flex Developer
Because loader is local to the buttonClick method. You need to change the object in your removeSWF to read: removeChild(e.currentTarget);
Last edited by samac1068; 08-26-2010 at 12:41 PM.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
So because the buttonclick is implied on the loader, removing the child wont work, did i get that right?
I changed it to your suggestion and now I get this on the remove child line
1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display isplayObject.
-
Change it a bit:
declare loader outside of buttonClick function this way:
var loader:Loader;
And then in button click function:
loader = new Loader();
Try that see if it works.
-
Flash/Flex Developer
Sorry about that. Beathoven's suggest is a much easier choice, but if you wanted to keep with what you have, you would change the line to:
Actionscript Code:
removeChild(MoveiClip(e.currentTarget))
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
I get the same 1118 Error
-
removeChild(loader as DisplayObject);
-
The script works good now but for some reason when I test it, it doesnt remove the swf still.
The loaded one is simple and has only stop(); then the dispatch event on the last frame. The slide stops and stays there
I tried taking out the stop(); and it just loops again.
-
In the removeLink function, put this line:
trace("test");
Run the movie, let me know if it outputs "test" after the swf attempts to close.
-
It is in the function right after the removechild line and it does output test.
-
Try:
removeChild(MovieClip(e.currentTarget));
-
Still nothing, test still outputs.
I really appreciate all your help, thanks alot.
Is there anything else I can send you that may help?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|