-
problems converting a string into a movieClip name
My code is below. I have an external Class AS file doing most of my code but I need some of the moviClips to highlight areas (other movieClips) when they're rolled over.
I've kept instance names the same + an H for their highlights to lessen the amount of code and be able to use array's and for loops.
my code is below and brings up this error:
Actionscript Code:
TypeError: Error #1034: Type Coercion failed: cannot convert "areanaH" to flash.display.MovieClip. at EnterpriseZone_fla::Layer1_1/end()
please help...
Actionscript Code:
import flash.display.MovieClip;
function hArea (e:MouseEvent) { var mName:MovieClip; mName = MovieClip((e.target.name) + "H"); mName.gotoAndStop(2); }
function end (e:MouseEvent) { var mName:MovieClip; mName = MovieClip((e.target.name) + "H"); mName.gotoAndStop(1); }
var stopAll:Array = new Array (bHomes1H,areanaH);
for (var i:int=0;i<stopAll.length;i++){ stopAll[i].stop(); }
var rollArray:Array = new Array (bHomes1,areana);
for (var Mc:int=0;Mc<rollArray.length;Mc++){ rollArray[Mc].addEventListener( MouseEvent.MOUSE_OVER,hArea ); rollArray[Mc].addEventListener( MouseEvent.MOUSE_OUT,end ); }
-
Use getChildByName e.g.:
var mName:MovieClip = this.getChildByName(e.target.name + "H");
Cheers,
Rob
-
I tried
Actionscript Code:
import flash.display.MovieClip;
function hArea (e:MouseEvent) { getChildByName(e.target.name + "H").gotoAndStop(2); }
function end (e:MouseEvent) { getChildByName(e.target.name + "H").gotoAndStop(1); }
var stopAll:Array = new Array (bHomes1H,areanaH);
for (var i:int=0;i<stopAll.length;i++){ stopAll[i].stop(); }
var rollArray:Array = new Array (bHomes1,areana);
for (var Mc:int=0;Mc<rollArray.length;Mc++){ rollArray[Mc].addEventListener( MouseEvent.MOUSE_OVER,hArea ); rollArray[Mc].addEventListener( MouseEvent.MOUSE_OUT,end ); }
and got
Actionscript Code:
Symbol 'Layer 1', Layer 'actions', Frame 1, Line 8 1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:DisplayObject.
sorry
-
MovieClip(getChildByName(e.target.name + "H")).gotoAndStop(2);
-
Tags for this Thread
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
|