Skip to main content
Thomas Hanser
Inspiring
January 29, 2014
Question

Yet Another Convert AS1 to AS3

  • January 29, 2014
  • 1 reply
  • 960 views

Shouldn't be too hard!

I adopted someone else's older Flash project, and I need to update it.

I have a map featuring several buttons on various cities. One button, with many instances, named accordingly.

Roll over a button instance, and it goes to the appropriate label on a MC timeline, showing the appropriate text.

How do I update this to AS3?

_root.seattle.onRollOver = function ()

{

_root.text.gotoandstop("seattle");

}

Seattle is the button instance name, text is the MC name and the seattle is the MC label name.

I'll end up with this code repeated many times, for each of the different buttons.

Any help?

Thanks.

This topic has been closed for replies.

1 reply

Inspiring
January 29, 2014

import flash.events.MouseEvent;

root.seattle.addEventListner(MouseEvent.ROLL_OVER, roHandler);

function roHandler(e:MouseEvent):void{

root.text.gotoAndStop("seattle");

}

Thomas Hanser
Inspiring
January 29, 2014

Thank you!  Making progress.

I fixed your typo Listner to Listener, but I get two compile errors:

Scene 1, Layer 'Actions', Frame 1, Line 191119: Access of possibly undefined property text through a reference with static type flash.display:DisplayObject.

Scene 1, Layer 'Actions', Frame 1, Line 151119: Access of possibly undefined property seattle through a reference with static type flash.display:DisplayObject.

My code:

     stop();

     /* Rollover button command

     */

     import flash.events.MouseEvent;

     root.seattle.addEventListener(MouseEvent.ROLL_OVER, roHandler);

     function roHandler(e:MouseEvent):void{

     root.text.gotoAndStop("seattle");

     }

When I test this movie, it loops endlessly. I have stop commands in place (main timeline AND the MC), but...what am I missing?

Thanks again.

Inspiring
January 30, 2014

its not a good idea to name a movieclip exactly like a common property.

try renaming it to CityLabels or sth.

Seattle is the button instance name, text is the MC name and the seattle is the MC label name.

Honestly, I have difficulties to understand what you are tring to communicate here.

if Seattle is a SimpleButton instance, you should convert it to a MovieClip, since SimpleButtons have some drawbacks when trying to overlay your own eventlisteners.

There is also sth. wrong with the nesting of your string component