|
-
talking to another class
i am still trying to wrap my head around as3/oop logic- say i have an interactive image on the stage...it is its own class (BigImage), with private functions to do different things. Depending on what you want, you can shrink it, tweek it, move it, etc.... Behind it, i have an MC , also it's own class (BackDrop), designed to respond to this images changes (scale, alpha, etc)---if, for example, i drag the image, BackDrop mc, will follow. At present, my logic was to set up public function s on the BackDrop mc , and then from the BigImage class, call these as they are necessary. So, for example, i have a public function on the BackDrop that states:
Code:
public function positionMe(wd:Number,ht:Number):void
{
this.readyHeight=false;
this.readyWidth=false;
this.finalW=wd;
this.finalH=ht;
this.alpha=0
this.x=stage.stageWidth/2
this.y=stage.stageHeight/2
this.addEventListener(Event.ENTER_FRAME,rebuild)
}
and then from BigImage, on a click, drag, or whatever, i have :
Code:
private function fadeIn(e:Event):void
{
this.newW=maxW;
this.newH=maxH;
bd=BackDrop(stage.getChildByName('backdrop'))
bd.positionMe(newW+10,newH+10)
}
i get this feeling there is a more oop way of doing the same thing....there's a voice in my head saying eventListeners and dispatchEvent -so, before i start really bad habits, can someone guide me the right way, and also tell me why this the wrong way?
ps- i already read this http://board.flashkit.com/board/showthread.php?t=743340
and i am browsing oop related articles after i click submit new thread....just asking the above to help the learning curve
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
|