-
I think the problem may be that those functions are only defined on certain frames in the root. Ideally, you want them to be methods of the Document Class itself. So if you have a document class already, put the functions there. If you don't, create one and put the functions there as public functions.
-
It doesn't seem to be removing the movieclip..It's not throwing any errors or anything. It' s just not functioning.
-
The only way it would not remove the clip is if the clip got put on the display without going through showModalContent. Like for instance if it were placed through the IDE. If there is an initial state with a modal content clip showing, you'll have to set currentlyShowing to that clip at the beginning.
Also the thing about the Document Class. These functions need to be part of the root itself, not only some frames in the root timeline.
-
I don't have a document class, I guess I should learn how to do it all through a document class. Seems like I would run into less problems..I'll make that and get right back to you.
Thanks!
-
okay, I think this is just confusing me more and more..So once I have those functions in the document class I need to move EVERYTHING to the root?
-
No, actually. As long as the other stuff calls the right functions in the root/document you should not need to move where that code is actually located. You SHOULD however remove all the unnecessary duplicate functions and tests for null and removeChilds, etc.
-
Alright, this is really my first real time using the document class..
In there I have this..
Code:
package {
import flash.display.*;
import FluidLayout.*;
public class Website extends MovieClip {
public function Website() {
/* Set the Scale Mode of the Stage */
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
/* Add the symbols to stage
var bg = new Background();
addChild(bg);
*/
var top = new top();
addChild(top);
var toprightoption = new toprightoption();
addChild(toprightoption);
//var middle = new Middle();
//addChild(middle);
var btmrightfooter = new btmrightfooter();
addChild(btmrightfooter);
/* Apply the alignment to the background
var bgParam = {
x:0,
y:0,
offsetX: 0,
offsetY: 0
}
new FluidObject(bg,bgParam);
*/
/* Apply the alignment to the top */
var topParam = {
x:0,
y:0,
offsetX:0,
offsetY:0
};
new FluidObject(top,topParam);
/* Apply the alignment to the toprightoption */
var toprightoptionParam = {
x:1,
y:0,
offsetX: -toprightoption.width - 20,
offsetY: 20
};
new FluidObject(toprightoption,toprightoptionParam);
/* Apply the alignment to the content
var middleParam = {
x:0.5,
y:0.5,
offsetX: -middle.width/2,
offsetY: -middle.height/2
}
new FluidObject(middle,middleParam);
*/
/* Apply the alignment to the btmrightfooter */
var btmrightfooterParam = {
x:1,
y:1,
offsetX: -btmrightfooter.width - 10,
offsetY: -btmrightfooter.height -10
};
new FluidObject(btmrightfooter,btmrightfooterParam);
}
}
import flash.display.MovieClip;
var currentlyShowing:MovieClip=null;
public function showModalContent(clip:MovieClip):void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
}
currentlyShowing=clip;
addChild(currentlyShowing);
}
public function removeModalContent():void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
currentlyShowing=null;
}
}
}
In the subnav movieclip I have this:
Code:
workcatagorydropdown_mc.catagoryinteractive_mc.addEventListener(MouseEvent.CLICK, interactiveHandler);
function interactiveHandler(event:MouseEvent):void {
//newParent.gotoAndStop("two")
newRoot.gotoAndStop("web");
removeModalContent();
}
I get this:
1180: Call to a possibly undefined method removeModalContent.
-
A couple of small things. That's a lot of initialization code in your document class constructor. All of that could go in an initialization function. The only real reason to do so is that constructor functions are not run in an optimized fashion, so moving it to another function would be a little faster. Don't worry about that now.
It is traditional for all imports to go at the top.
You should make the currentlyShowing property private.
The reason that removeModalContent() does not work like that in the subnav clip is that within that clip the "this" variable refers to subnav, not the document. Make that newRoot.removeModalContent(); And newRoot can be set to type Website rather than just MovieClip.
-
What do you mean by newRoot can be set to type website rather than just Movieclip? Could you elaborate on that?
Here as an update:
Code:
package {
import flash.display.*;
import FluidLayout.*;
public class Website extends MovieClip {
public function Website() {
/* Set the Scale Mode of the Stage */
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
/* Add the symbols to stage
var bg = new Background();
addChild(bg);
*/
var top = new top();
addChild(top);
var toprightoption = new toprightoption();
addChild(toprightoption);
//var middle = new Middle();
//addChild(middle);
var btmrightfooter = new btmrightfooter();
addChild(btmrightfooter);
/* Apply the alignment to the background
var bgParam = {
x:0,
y:0,
offsetX: 0,
offsetY: 0
}
new FluidObject(bg,bgParam);
*/
/* Apply the alignment to the top */
var topParam = {
x:0,
y:0,
offsetX:0,
offsetY:0
};
new FluidObject(top,topParam);
/* Apply the alignment to the toprightoption */
var toprightoptionParam = {
x:1,
y:0,
offsetX: -toprightoption.width - 20,
offsetY: 20
};
new FluidObject(toprightoption,toprightoptionParam);
/* Apply the alignment to the content
var middleParam = {
x:0.5,
y:0.5,
offsetX: -middle.width/2,
offsetY: -middle.height/2
}
new FluidObject(middle,middleParam);
*/
/* Apply the alignment to the btmrightfooter */
var btmrightfooterParam = {
x:1,
y:1,
offsetX: -btmrightfooter.width - 10,
offsetY: -btmrightfooter.height -10
};
new FluidObject(btmrightfooter,btmrightfooterParam);
}
}
private var currentlyShowing:MovieClip=null;
public function showModalContent(clip:MovieClip):void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
}
currentlyShowing=clip;
addChild(currentlyShowing);
}
public function removeModalContent():void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
currentlyShowing=null;
}
}
}
Code:
workcatagorydropdown_mc.catagoryinteractive_mc.addEventListener(MouseEvent.CLICK, interactiveHandler);
function interactiveHandler(event:MouseEvent):void {
newRoot.gotoAndStop("web");
newRoot.removeModalContent();
}
-
I mean that this line:
could give newRoot an explicit type of Website
Code:
var newRoot:Website = Website(root);
Then the compiler knows what methods newRoot has, because it knows what type of thing it is.
-
OH! Alright. I see, so we are defining where the root will be coming from...
Code:
private var currentlyShowing:MovieClip=null;
1013: The private attribute may be used only on class property definitions.
What is this referring to?
-
You need to put currentlyShowing, showModalContent, and removeModalContent inside the class. Right now, you have them in the package, but outside the class.
-
That's what I was thinking..I was searching it.
After fixing that it is giving me this error:
TypeError: Error #1034: Type Coercion failed: cannot convert SILVERCOLLECTIVEv16cs4_fla::MainTimeline@408bf2e1 to Website.
-
Does this have to do with changing the function to a public function?
Code:
var newClassRoot:Website = Website(root);
workcatagorydropdown_mc.catagoryinteractive_mc.addEventListener(MouseEvent.CLICK, interactiveHandler);
function interactiveHandler(event:MouseEvent):void {
//newParent.gotoAndStop("two")
newClassRoot.removeModalContent();
newRoot.gotoAndStop("web");
}
-
The type error you posted indicates that your document class (root) is not actually Website. Did you set the document class?
-
wow. Just go ahead and slap me. Since I did that it's throwing a ton of errors dealing with tweenlite and tweenmax, do I need to consolidate all these different classes into the main document class?
-
No, you shouldn't have to. What are the errors?
You might have to import the TweenLite and TweenMax classes into the other classes so that the compiler knows what's up.
-
I fixed a few of the errors..
These are the errors:
1046: Type was not found or was not a compile-time constant: FullScreenEvent.
Warning: 3594: getStackTrace is not a recognized method of the dynamic class Error.
Warning: 3590: void used where a Boolean value was expected. The expression will be type coerced to Boolean.
I didn't copy of the errors, but those are the 3 different unique instances of the errors. 3590 appears multiple times...
Code:
package {
import flash.display.*;
import FluidLayout.*;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import gs.*;
import gs.easing.*;
import fl.motion.easing.*;
import com.greensock.*;
import flash.events.MouseEvent;
public class Website extends MovieClip {
public function Website() {
/* Set the Scale Mode of the Stage */
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
/* Add the symbols to stage
var bg = new Background();
addChild(bg);
*/
var top = new top();
addChild(top);
var toprightoption = new toprightoption();
addChild(toprightoption);
//var middle = new Middle();
//addChild(middle);
var btmrightfooter = new btmrightfooter();
addChild(btmrightfooter);
/* Apply the alignment to the background
var bgParam = {
x:0,
y:0,
offsetX: 0,
offsetY: 0
}
new FluidObject(bg,bgParam);
*/
/* Apply the alignment to the top */
var topParam = {
x:0,
y:0,
offsetX:0,
offsetY:0
};
new FluidObject(top,topParam);
/* Apply the alignment to the toprightoption */
var toprightoptionParam = {
x:1,
y:0,
offsetX: -toprightoption.width - 20,
offsetY: 20
};
new FluidObject(toprightoption,toprightoptionParam);
/* Apply the alignment to the content
var middleParam = {
x:0.5,
y:0.5,
offsetX: -middle.width/2,
offsetY: -middle.height/2
}
new FluidObject(middle,middleParam);
*/
/* Apply the alignment to the btmrightfooter */
var btmrightfooterParam = {
x:1,
y:1,
offsetX: -btmrightfooter.width - 10,
offsetY: -btmrightfooter.height -10
};
new FluidObject(btmrightfooter,btmrightfooterParam);
}
private var currentlyShowing:MovieClip=null;
public function showModalContent(clip:MovieClip):void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
}
currentlyShowing=clip;
addChild(currentlyShowing);
}
public function removeModalContent():void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
currentlyShowing=null;
}
}
}
}
-
You need to import FullScreenEvent to wherever it is used.
I don't know what's up with the getStackTrace line, since Error actually does declare that function.
Can you post the lines associated with the latter two errors after fixing the first one?
-
I fixed the other errors, the only one I have left is this:
1119: Access of possibly undefined property textField through a reference with static type Website.
Code:
this.textField.text=this.stage.displayState;
-
Your Website class does not define a field called textField. If you're trying to get to a named instance on the displaylist, you can use getChildByName. Otherwise, you need to declare, instantiate, and put textField on the displayList.
-
Okay cool. For now I just commented that code out b/c I realized I'm not even using that right now. So now that I can get back into what we were previously doing after setting the document class and working out those errors. It's not giving any type of result from the removeModalContent..
Code:
var newClassRoot:Website = Website(root);
workcatagorydropdown_mc.catagoryinteractive_mc.addEventListener(MouseEvent.CLICK, interactiveHandler);
function interactiveHandler(event:MouseEvent):void {
//newParent.gotoAndStop("two")
newClassRoot.removeModalContent();
newRoot.gotoAndStop("web");
}
workcatagorydropdown_mc.catagoryprint_mc.addEventListener(MouseEvent.CLICK, printHandler);
function printHandler(event:MouseEvent):void {
newRoot.gotoAndStop("print");
}
workcatagorydropdown_mc.catagorymograph_mc.addEventListener(MouseEvent.CLICK, mographHandler);
function mographHandler(event:MouseEvent):void {
newClassRoot.removeModalContent();
newRoot.gotoAndStop("motion");
}
Code:
package {
import flash.display.*;
import FluidLayout.*;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import gs.*;
import gs.easing.*;
import fl.motion.easing.*;
import com.greensock.*;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
//import greensock.*;
import flash.events.MouseEvent;
import flash.events.FullScreenEvent;
public class Website extends MovieClip {
public function Website() {
/* Set the Scale Mode of the Stage */
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
/* Add the symbols to stage
var bg = new Background();
addChild(bg);
*/
var top = new top();
addChild(top);
var toprightoption = new toprightoption();
addChild(toprightoption);
//var middle = new Middle();
//addChild(middle);
var btmrightfooter = new btmrightfooter();
addChild(btmrightfooter);
/* Apply the alignment to the background
var bgParam = {
x:0,
y:0,
offsetX: 0,
offsetY: 0
}
new FluidObject(bg,bgParam);
*/
/* Apply the alignment to the top */
var topParam = {
x:0,
y:0,
offsetX:0,
offsetY:0
};
new FluidObject(top,topParam);
/* Apply the alignment to the toprightoption */
var toprightoptionParam = {
x:1,
y:0,
offsetX: -toprightoption.width - 20,
offsetY: 20
};
new FluidObject(toprightoption,toprightoptionParam);
/* Apply the alignment to the content
var middleParam = {
x:0.5,
y:0.5,
offsetX: -middle.width/2,
offsetY: -middle.height/2
}
new FluidObject(middle,middleParam);
*/
/* Apply the alignment to the btmrightfooter */
var btmrightfooterParam = {
x:1,
y:1,
offsetX: -btmrightfooter.width - 10,
offsetY: -btmrightfooter.height -10
};
new FluidObject(btmrightfooter,btmrightfooterParam);
}
private var currentlyShowing:MovieClip=null;
public function showModalContent(clip:MovieClip):void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
}
currentlyShowing=clip;
addChild(currentlyShowing);
}
public function removeModalContent():void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
currentlyShowing=null;
}
}
}
}
-
Doing absolutely nothing is exactly what I'd expect, if there had not been content previously shown via showModalContent. Was there such content?
-
No, there was(is) not.
So okay, I have to add something with showModalContent to remove it with removalModal..
How would i declare what it is that I need to add with showModalContent?
What I would be doing is going to a frame label..Or that's how I am doing it now..
-
You were adding and removing stuff all over originally. I thought that all your main things were MovieClips unto themselves?
Anyway, if they are not, you can make them so, and add each with showModalContent when appropriate.
-
Well, when needed I am using addChild and removeChild.. Otherwise, if I didn't need to some are placed on the time line. Such as with my main navigation I am going to a frame label then checking if certain movieclips exist I am removing them.
See example:
Code:
nav_mc.workbtn_mc.addEventListener(MouseEvent.CLICK, buttonClick1);
function buttonClick1(event:MouseEvent):void {
gotoAndStop("work");
stage.invalidate();
stage.addEventListener(Event.RENDER,renderedF);
}
function renderedF(e:Event) {
unimetal_homeref_mcExists();
motionss_mcExists();
home_mcExists();
//work_mcExists();
//workss_mcExists();
motion_mcExists();
workpersonalssExists();
workpersonalExists();
printss_mcExists();
stage.removeEventListener(Event.RENDER,renderedF);
}
function unimetal_homeref_mcExists():void {
if (unimetal_homeref_mc!=null) {
if (unimetal_homeref_mc.stage!=null) {
trace("YESdudemar unimetalhomeref exists");
removeChild(unimetal_homeref_mc);
} else {
trace("NO home ref does not exist");
}
}
}
So when that is clicked I am going to that frame label, and if any other movieClip is on the stage I am removing that clip.
So basically I need to go through and change every single removeChild and addChild to showModalContent and removeModalContent? Do I really need to go and do that? Or can I just do it where we are referring to in the subnav?
-
You should be able to keep the frames part as frames. Those are already mutually exclusive (though not with things added with addChild, of course).
If the only addChild calls are those that you would have changed to showModalContent, you could actually override addChild in Website to call showModalContent for you.
Basically, anything you want to be automatically removed when something else is added, should be added with showModalContent.
-
so, I should be doing something like this correct?
Code:
workcatagorydropdown_mc.catagoryprint_mc.addEventListener(MouseEvent.CLICK, printHandler);
function printHandler(event:MouseEvent):void {
showModalContent(print_mc);
removeModelContent();
}
Sorry for so many questions, this is just confusing me more and more the more ways there are at doing things..Thanks so much for your patience.
-
Well, that would add print_mc as the modal content, then immediately remove it. If you want print_mc to show, just use showModalContent(print_mc).
You only need to use removeModalContent when you want to remove the content and not replace it with anything else.
-
so removeModalContent would remove the current clip correct?
It gives me this error:
1120: Access of undefined property print_mc.
It has an instance name, and a linkage identifier as well.
-
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at Website/showModalContent()[/Design/The Silver Collective/_classes/Website.as:97]
at SILVERCOLLECTIVEv18cs4_fla::mc_workcatagory_40/printHandler()[SILVERCOLLECTIVEv18cs4_fla.mc_workcatagory_40::fra me1:93]
Code:
if (currentlyShowing!=null) {
Code:
addChild(currentlyShowing);
-
Yes, that is the purpose of removeModalContent - to remove the content, whatever it may be.
If you're getting that error, then print_mc is undefined in the context you are calling it from. I suspect this is because it is a property of a different movieclip.
-
sorry, my last message referred to the print_mc situation.
The above error would occur if you passed null to showModalContent.
-
So, okay, I duplicated the clip, gave it a different instance name..
Code:
workcatagorydropdown_mc.catagoryprint_mc.addEventListener(MouseEvent.CLICK, printHandler);
function printHandler(event:MouseEvent):void {
print2_mc = new mc_print2();
//newRoot.gotoAndStop("print");
newClassRoot.showModalContent(print2_mc);
}
1120: Access of undefined property print2_mc.
How do I fix this?
-
You need to declare new variables with var, otherwise the compiler thinks you're trying to set a variable that it should already know about.
Code:
var print2_mc:mc_print2 = new mc_print2();
And none of that code gives anything an instancename, but you didn't need one anyway. What did you mean by saying you had given it a different instance name?
-
and I can't have more than one arguement such as
showModalContent & removeModalContent in the same function?
1137: Incorrect number of arguments. Expected no more than 0.
Code:
workcatagorydropdown_mc.catagoryprint_mc.addEventListener(MouseEvent.CLICK, printHandler);
function printHandler(event:MouseEvent):void {
var print2_mc = new mc_print2();
var work_mc = new mc_work();
//newRoot.gotoAndStop("print");
newClassRoot.showModalContent(print2_mc);
newClassRoot.removeModalContent(work_mc)
}
When I load print2_mc it will just overlap work_mc if I don't remove it..
-
The whole point of showModalContent is that it removes previous content for you. As long as work_mc was added with showModalContent(work_mc), then showModalContent(print2_mc) will automatically remove work_mc.
-
I see where that can be very useful, what if I wanted to remove something then that wasn't loaded with removeModalContent? I will still try to load work_mc with showModalContent but I'm just curious
-
Nice, that seems to work well. Thanks! I updated the back button to use showModalContent instead of addChild, I'll be changing a ton of stuff around tomorrow so I'll let you know how this works out and let you take a look.
-
Flax,
Just wanted to let you know I recoded the entire site based on the knowledge that you provided to me and everything is working really smooth now! Thanks alot!