Note that there are some explanatory texts on larger screens.

plurals
  1. POForcing method sequences on ActionScript 3.0
    primarykey
    data
    text
    <p>I'm having problems with asynchronous sequences on Flex/ActionScript. Here is an example:</p> <pre><code>private function start():void{ _menu = new MyMenu(); _screen.addElement(_menu); //Here, some Mouse Event Listener to Menu Click } </code></pre> <p>Now, let's assume that a click on the menu happened.</p> <pre><code>private function menuClick(event:Event):void{ removeMenu(); addMenu(event.SomethingPassedByTheClick); } </code></pre> <p>Now, forget about the error on the event handler thing, let's just think about the process, ok? My problem is that sometimes addMenu() finishes before removeMenu(), which leads to errors. The above script is just a logical representation of my problem, not a real script. To sunup, I need to be able to define that the method addMenu() HAS to wait for removeMenu() to be done before be called. Any thoughts? Thanks for your attention.</p> <p>Edit:</p> <p>A more accurate example of my problem:</p> <pre><code>private function createComplete():void{ _screenArray = new Array( new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); startUp(); } private function startUp():void{ //Some mathematical calculations that changes a few 0 to 1's. addNewComponent(); } private function addNewComponent():void{ removeAllComponents(); //More calculus on the array in order to create a component in vague space. addComponentOnCalculatedArea(x, y); //here is my problem: Sometimes, add Method is called before the removeAllComponents, which causes the new added component be removed by the removeAllComponents() method. } </code></pre> <p>Thanks everyone. I had the wrong premise. What was wrong whas my mathematics calcs, not the order of the methods being called. I noticed that by adding trace() in each method of the Script.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload