Search  

WARNING 1058 - AS2 TO AS3

HomeForumsFlash DiscussionWarning 1058 - AS2 to AS3
Default-profile jennicandance
66 posts
Bought between 10 and 49 items

I have a mc set to a button with part of it set as the hit area with this code in as2:

hit._visible = false; this.hitArea = hit;

Is there anyway that I can change that to work with as3? I researched it, and it told me to take out the _ before visible. The warning goes away, but my file doesn’t work.

Thanks in advance!

Posted about 1 month ago
66839 LuizZak
381 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

The code is correct (without the underscore), but without the rest of the code, it’s impossible to know why it isn’t working.

Posted about 1 month ago
Default-profile jennicandance
66 posts
Bought between 10 and 49 items

Thanks for your reply!

Here is my flash code:


try {
    var keyStr:String;
    var valueStr:String;
    var webStr:String;
    var paramObj:Object = 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);
}

function handlemouse(evt:MouseEvent):void{
       if(evt.currentTarget != MovieClip(getChildByName(keyStr))){
           var frameLabel = '';
           switch(evt.type){
              case MouseEvent.MOUSE_OUT:
                frameLabel = "over";
                break;
              case MouseEvent.MOUSE_OVER:
                frameLabel="out";
                break;
              case MouseEvent.MOUSE_DOWN:
                frameLabel="out";
                break;

           }
           evt.currentTarget.gotoAndPlay(frameLabel);
    }
}

homeButton.addEventListener("mouseOver", handlemouse);
homeButton.addEventListener("mouseOut", handlemouse);
homeButton.addEventListener("mouseDown", handlemouse);

this.homeButton.onRollOver = function() {
    homeButton.gotoAndPlay("over");
}
this.homeButton.onRollOut = function() {
    homeButton.gotoAndPlay("out");
}
this.homeButton.onPress = function() {
    homeButton.gotoAndPlay("out");
}


I’m getting an error that reads:

Warning: 1090: Migration issue: The onRollOver event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( ‘mouseOver’, callback_handler).

When I try and rollover the button, I get this error:

TypeError: Error #2007: Parameter name must be non-null. at flash.display::DisplayObjectContainer/getChildByName() at groupj_fla::MainTimeline/handlemouse()

Any idea of what to do? Sorry, I’m a flash newbie!

Posted about 1 month ago
38045 Ziyad
153 posts
Referred at least one person Sold between 100 and 1 000 dollars

Hey jennicandance,

I have only started the migration to AS3 recently. I have recently learnt about these new AS3 Event Listeners and I’ve noticed your use of ones such as “mouseOver”. Whereas it should be MouseEvent.MOUSE_OVER

So the general structure is: EventType.EventName

So try using this:

import flash.events.MouseEvent;

homeButton.addEventListener(MouseEvent.MOUSE_OVER, handlemouse); homeButton.addEventListener(MouseEvent.MOUSE_OUT, handlemouse); homeButton.addEventListener(MouseEvent.MOUSE_DOWN, handlemouse);

you don’t need the import if you are adding it to frame actions.

Hope this helps,

Ziyad

Edit: Have a look at this page there are a list of events from the Adobe online documentation. http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/package-detail.html

Posted about 1 month ago
Default-profile jennicandance
66 posts
Bought between 10 and 49 items

Thanks Ziyad!! :)

So I now have my code to this:

homeButton.addEventListener(MouseEvent.MOUSE_OVER,handleBlankMouseOver); homeButton.addEventListener(MouseEvent.MOUSE_OUT,handleBlankMouseOut); homeButton.addEventListener(MouseEvent.MOUSE_DOWN,handleBlankMouseDown);

function handleBlankMouseOver.onRollOver = function() { homeButton.gotoAndPlay(“over”;); }

function handleBlankMouseOut.onRollOut = function() { homeButton.gotoAndPlay(“out”;); }

function handleBlankMouseDown.onPress = function() { homeButton.gotoAndPlay(“out”;); }

And my error is: Expecing left paren before dot… and I really have no idea what that means. :(

I have a feeling that the ‘homeButton.gotoAndPlay(“out”;); is wrong… but I’m not sure what that needs to be… ?

My problem with Flash is that I never feel like I can connect one thing to the next. Grr… frustration. :(

Posted about 1 month ago
68658 MBMedia
244 posts
Exclusive author Author was featured Referred at least one person Sold between 5 000 and 10 000 dollars

You’re still trying to write AS2 in AS3 , the onRollOut, etc are completely unnecessary. I wrote this about a year ago, it should help:

Article

Posted about 1 month ago
68658 MBMedia
244 posts
Exclusive author Author was featured Referred at least one person Sold between 5 000 and 10 000 dollars

by the way, this is the answer:

http://pastie.org/329870

Posted about 1 month ago
Default-profile jennicandance
66 posts
Bought between 10 and 49 items

Yay! It worked! :) Thanks so much for the code and for your help! :)

Posted about 1 month ago
Default-profile jennicandance
66 posts
Bought between 10 and 49 items

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:Object = 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
38045 Ziyad
153 posts
Referred at least one person Sold between 100 and 1 000 dollars

Hey jennicandance,

I’d love to help but I’m not 100% sure what you are asking for. What are you trying to do with the collision detection?

Posted about 1 month ago