actionscript 3 - Flash CS5 + AS3 Timeline Navigation -


new cs5 , as3 if making fundamental mistake please don't hesitate correct me.

i trying build lengthy , complicated form. require navigation through different pieces of it. new flash , as3 started prototyping , got 2 buttons navigate forward , backwards in timeline. problem when trying bring out of "code snippet" (correct term?) area , main actionscript file. buttons appear, pressing them not execute mouseevent.

so 2 questions. 1. doing right? 2. why doesn't mouseevent work when code in .as file?

form.fla - frame 1 code snippet

var form:form = new form(); addchild(form); 

form.as

package   {     import flash.display.movieclip;     import fl.controls.button;     import flash.events.mouseevent;      public class form extends movieclip      {         private var nextbutton:button;         private var prevbutton:button;          public function form()          {             setupnavigation();         }          private function setupnavigation():void         {             nextbutton = new button();             nextbutton.label = "next";             // ... size , position code             nextbutton.addeventlistener(mouseevent.click, moveforward);              prevbutton = new button();             prevbutton.label = "previous";             // ... size , position code             prevbutton.addeventlistener(mouseevent.click, movebackward);              addchild(nextbutton);             addchild(prevbutton);         }          // setup mouse events         private function moveforward(event:mouseevent):void         {             nextframe();         }          private function movebackward(event:mouseevent):void         {             prevframe();         }     } } 

you have pass reference of main timeline form class, using setter function

var form:form = new form(); form.maintimeline = this; addchild(form); 

in form class (not snippet, class correct term), add following function , variable:

private var _maintimeline:object;  public function set maintimeline(mtl:object):void {     _maintimeline = mtl; } 

then in move forward/backward functions change prevframe() , nextframe() to:

_maintimeline.prevframe(); _maintimeline.nextframe(); 

there several ways accomplish trying achieve, meaning method of changing sections. way 1 way it. there maybe better approaches approach here not glaringly wrong or anything. :)


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -