Here is another part of the same code that I’m having a problem with:
I want to add a hitArea to my movieclip, and this is the code I have for the hit area (going back to my post from earlier in this thread):
hit.visible = false;
this.hitArea = hit;
And this is the code that I have on the rest of my page:
// Display FlashVar onto webpage to ensure we are
// receiving it
/*
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.border = false;
tf.x = 50;
tf.y = 10;
addChild(tf);
*/
/////////////////////////////////////////
// Detect the FlashVar from the webpage//
/////////////////////////////////////////
try {
var keyStr:String;
var valueStr:String;
var webStr:String;
var paramObj
bject = LoaderInfo(this.root.loaderInfo).parameters;
for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);
if (keyStr.indexOf(”.”
!= -1){
webStr = keyStr;
keyStr = keyStr.substring(0, keyStr.indexOf(”.”
); //now it’s “home”
}
}
// tf.appendText(keyStr);
} catch (error:Error) {
// tf.appendText(error);
}
////////////////////////////////////
// Add the buttons onto the stage //
////////////////////////////////////
var tl:MovieClip = this;
var buttonA = [“blank”,”hair”,”beauty”,”tapas”,”gifts”,”idos”,”bios”,”whoweare”,”contactus”,”blog”];
for (var i:int=0; i<buttonA.length; i++) {
var childButton:MovieClip = MovieClip(tl.getChildByName(buttonA[i]));
childButton.buttonMode = true;
childButton.addEventListener(“mouseOver”,handleMouse);
childButton.addEventListener(“mouseOut”,handleMouse);
childButton.addEventListener(“mouseDown”,handleMouse);
childButton.addEventListener(“mouseUp”,handleMouse);
}
//////////////////////////////////////////////
// Detect button mouseover, out, down or up //
//////////////////////////////////////////////
function handleMouse(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
var frameLabel = ’’;
switch(evt.type){
case MouseEvent.MOUSE_OUT:
frameLabel = “out”;
break;
case MouseEvent.MOUSE_OVER:
frameLabel=”over”;
break;
case MouseEvent.MOUSE_DOWN:
frameLabel=”down”;
break;
case MouseEvent.MOUSE_UP:
frameLabel=”up”;
break;
}
}
evt.currentTarget.gotoAndPlay(frameLabel);
}
//////////////////////////////
// Handle Button Navigation //
//////////////////////////////
blank.addEventListener(MouseEvent.CLICK,handleBlankMouseClick);
hair.addEventListener(MouseEvent.CLICK,handleHairMouseClick);
beauty.addEventListener(MouseEvent.CLICK,handleBeautyMouseClick);
tapas.addEventListener(MouseEvent.CLICK,handleTapasMouseClick);
gifts.addEventListener(MouseEvent.CLICK,handleGiftsMouseClick);
idos.addEventListener(MouseEvent.CLICK,handleIdosMouseClick);
bios.addEventListener(MouseEvent.CLICK,handleBiosMouseClick);
whoweare.addEventListener(MouseEvent.CLICK,handlewhoweareMouseClick);
contactus.addEventListener(MouseEvent.CLICK,handlecontactusMouseClick);
blog.addEventListener(MouseEvent.CLICK,handleContactMouseClick);
function handleBlankMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“bhd.php”
,”_self”
;
return;
}
}
function handleHairMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“hair.php”
,”_self”
;
return;
}
}
function handleBeautyMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“beauty.php”
,”_self”
;
return;
}
}
function handleTapasMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“tapas.php”
,”_self”
;
return;
}
}
function handleGiftsMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“gifts.php”
,”_self”
;
return;
}
}
function handleIdosMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“idos.php”
,”_self”
;
return;
}
}
function handleBiosMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“bios.php”
,”_self”
;
return;
}
}
function handlewhoweareMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“whoweare.php”
,”_self”
;
return;
}
}
function handlecontactusMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“contactus.php”
,”_self”
;
return;
}
}
function handleContactMouseClick(evt:MouseEvent):void{
if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
navigateToURL(new URLRequest(“http://groupjdesign.com/blog/”
,”_self”
;
return;
}
}
//////////////////////////////////////////////////////////////////////////
// Detect the webpage we are currently on from the flashvars parameter. //
//////////////////////////////////////////////////////////////////////////
function wpdetect() {
trace(“webpages Array successfully loaded”
;
var curpage:String = paramObj[‘currentPage’];
switch(keyStr) {
case "blank":
//home button in down position here
blank.gotoAndStop("down");
trace("User is on the blank page");
break;
}
case "hair":
//home button in down position here
hair.gotoAndStop("down");
trace("User is on the hair page");
break;
case "beauty":
//home button in down position here
beauty.gotoAndStop("down");
trace("User is on the beauty page");
break;
case "tapas":
//home button in down position here
tapas.gotoAndStop("down");
trace("User is on the beauty page");
break;
case "gifts":
//home button in down position here
gifts.gotoAndStop("down");
trace("User is on the beauty page");
break;
case "idos":
//home button in down position here
idos.gotoAndStop("down");
trace("User is on the idos page");
break;
case "bios":
//bios button in down position here
bios.gotoAndStop("down");
trace("User is on the bios page");
break;
case "whoweare":
//whoweare button in down position here
whoweare.gotoAndStop("down");
trace("User is on the whoweare page");
break;
case "contactus":
//contactus button in down position here
contactus.gotoAndStop("down");
trace("User is on the contactus page");
break;
case "blog":
//blog button in down position here
blog.gotoAndStop("down");
trace("User is on the blog page");
break;
default:
trace("Webpage not found. Update Case Statement.");
trace(keyStr);
}
/////////////////////////////
// What webpage are we on? //
/////////////////////////////
wpdetect();
Does anything else need to be connected with the 2 codes?
Thanks so much!
Posted about 1 month ago