Calling a function only when the State is active

I turn to find the event just to call a function only when the status is active. In fact, I created a State to display the 'product details' click and once the system changes to this State - I have to perform a function.

Here's the context:

Let's say that you are on the home page where you will need to click on a product to see details. By clicking on the product, the State to view the details of the product will be activated and a variable inside the new state you will receive all the data (from the class of product). But I discovered Flex run all States at the beginning and we need to watch how declare our function to make sure that we do not have a null to a variable/object reference. Given that value is moving to the State only when the click event to occur, the process of globalization, execution of all States at the beginning will not have any value yet (for the specific product to deal with in the State of the productDetails). So I can't use creationComplete to perform a simple function like setSpecs(), where all the values (for example, width, height, circumference, diameter, price, etc.) will be instiate specific labels.

What event to use to call a function internal once we are in the State? Just using the creationComplet and stated if he check the currentState = that I have to work on is not enough. I tried 'activate', 'show', 'enterStage' and many others, but without success. I tried to search the Internet, but it seems that this problem is not popular enough to generate sufficient results.

But I know that it is possible in the case otherwise it will be is not logical and since Flex work very well with the event, I found the right event. It's something basic I know, but when you do not know, it seems difficult to find! ;-))

Thanks Greg!

I agree, this is a better method. So I'll change my SENSITIVITY to use viewStack instead of the State. But the problem persists what that, if we use the viewStack State to launch an event only when the State/viewStack is displayed on the screen.

I found something that works very well for me: updateComplete.

First of all, I found this before reading your information about viewStack so it worked very well for the method of the State. That I decided to do a test to viewStack and made the necessary changes to the code to reflect a viewStack navigation and make sure the updateComplete was not within my component (stateProduct.mxml). The system was not able to view the specification as the setSpecs() function was not instantiate when displayed. I added the updateComplete = "{setSpecs ()} ' and everything worked great!" So I conclude that no matter if you are using a viewStack State, the updateComplete event can be used to run or functions only when the component is displayed on the screen.

Now, I have to make my transition between the State working with viewStack effect! ;-))

Thanks to Greg for this useful tip!

Tags: Flex

Similar Questions

  • is there an add-on to play videos only when the tab is active as chrome?

    Hello

    Flash block {web link} Never be annoyed by a Flash animation again! Blocks Flash so it won't get in your way, but if you want to see it, just click it

  • Where can I find all my States system restore? When I try to restore windows only displays the States from today until 7 days ago

    Where can I find all my States system restore? When I try to restore windows only displays the States from today until seven days ago.

    I'm trying to find the States of up to a year ago.

    Hello

    system restore points are not here forever

    It depends on the amount of space reserved for restoring the system restore points on how you

    and as a new one is created the oldest one is deleted

    http://www.windowsvistauserguide.com/system_restore.htm

    There is a box to check points over 5 days which must obviously have checked back 7 days?

    or 7 days a rough estimate on your part?

    and here's how to change the amount of space for the restoration of the system increase or decrease to restore more or less points in the future

    http://www.Vistax64.com/tutorials/76227-system-restore-disk-space.html

    http://www.vista4beginners.com/system-restore-space-used

  • Skype rings only when the application is open

    I have a Skype number for my phone a few days ago and I just noticed a problem. When people try to call me using my Skype number, it sounds only when the application is open and the phone is unlocked. However, people can still call me normally on my Skype ID, it is locked or not currently open to the app. It's a rule I missed when having a Skype number?

    I reset my phone to factory settings and it works now.

  • Skype number rings only when the application is open

    I have a Skype number for my phone a few days ago and I just noticed a problem. When people try to call me using my Skype number, it sounds only when the application is open and the phone is unlocked. However, people can still call me normally on my Skype ID, it is locked or not currently open to the app. It's a rule I missed when with a Skype number?

    (Previously posted this in the Android subforum)

    I reset my phone to factory settings and it works now.

  • Why a normal digital text read like a phone number on my site only when the display on the phone or Tablet?

    Hey everybody.

    I'm working on a website and have an ABN followed of the digital text however it does not read as text on a phone or a tablet. In fact, numbers are invisible and when you click it then numbers and calling area is triggered.

    How can I fix this please.

    Help.

    Double post of why a normal digital text reads like a phone number on my site only when the display on the phone or Tablet?

  • Display shuts off and comes back only when the Satellite A210 is restarted

    Hello

    Satellite A210 display goes off in time and returns only when the computer is restarted.
    Duration usual DURATION 30 or 45 minutes

    Please advice
    # Is it a hardware or software problem?
    # Some other face same problem brings advice?

    The machine is a year and a half old runs windows vista Basic that comes with it.

    I reinstalled the drivers card display also the problem remains same

    Hello

    Have you tried an external monitor on the laptop?
    If the external monitor works fine, it seems to be a problem of internal display and must be replaced.

    You use the factory settings on your laptop computer or you have installed your own version of Windows? Before turning to an authorized service provider, you need to restore factory settings to determine if it s a hardware or software problem. With the factory settings, everything should work fine and if not, I think it s a hardware problem.

    Check this box!

  • My Ipad charger charge my iphone 5s only when the phone is turned off

    Hi guys. My Ipad charger charging my iphone 5s only when the phone is turned off. The phone does not recognize if it is on and I can't transfer files with it. Help, please?

    Hey Bigfootinyourface,

    I understand that you have a problem with your iPad charger or cable. Accessories and connectors uncertified can often result in the mentioned behavior. Article in the link below provides information that you may find useful.

    Identify the fakes or not certified lightning connector accessories
    https://support.Apple.com/en-us/HT204566

    See you soon!

  • How the LED lights up when a threshold is reached, then turns off only when the value does not reach the threshold for a while?

    Hi, I want to write a program that can turn on the LED when a range of value, this is the threshold and only when the value does not reach the threshold for a period of time, say 5 seconds, then the LED will turn off, otherwise it will remain. How can I achieve this in labview? Can someone help me? Really thanks!

    I assume that you use a while loop to keep the updated value.

    Add a record to offset to your looping it initialize with a U32 (time in ms)

    Add the registry to offset to your loop that keeps the previous value of your bool

    When your reaches the threshold value => the light and set the current time in your shift register.

    In the next iteration of the loop weather check value is still above threshold

    => Y-online previous set to true?

    => Y-online the next iteration

    -Online N => turn switch on and set the current time in your shift register.

    -Online N => subtract the time current less time shift record-online more then 5 seconds?

    => Is => keep turning on

    -Online N => turn given

  • FM Radio has its out only when the screen of the phone is turned off

    FM Radio has its out only when the phone screen is turned off. Even for the speakers or headphones.

    I SOLVED!
    I had turned on 'Ok Google' and set it listening to "from any screen. Looks like Google to try and listen to all the time and blocks Radio FM output for headphones and speakers

  • Unable to get the correct rules table result when the State is unknown

    Hi all

    I use OPA version 10.4. I'm writing a rule by using a table of rules. Requirement is such that when the State is unknown then conclusion should evaluate to 'Others' (for example). Now, I have a condition (text) attribute and attribute of conclusion (text). Now when the condition attribute value is "abc" then attribute of the conclusion must be "xyz" but when the condition attribute is 'unknown' or anything else then attribute conclusion must be 'other '. I tried to implement this in the two table rules in word doc and also in excel table of rule but failed to get the desired result. It assesses the 'unknown' conclusion when the condition attribute is 'unknown '. Please suggest.

    Thank you

    Mounia

    ruleTable3.JPG

    ruleTable2.JPG

    Hi Pascal,.

    As the table of treaty rules the rules in the top-down approach, so the 'unknown' State should be written before the value condition.

    If she meets the condition of value firstly she neglects the unknown state and gives the value of the conclusion as 'unknown '.

    Hi Sean,.

    Want your comments on that.

    See you soon,.

    Arup

  • Show LOV only when the field is empty

    Hi all
    My surroundings:
    Oracle 10g on Windows
    Forms [32 bit] Version 9.0.4.1.0 (Production)
    Oracle Database 10 g Enterprise Edition Release 10.2.0.5.0 - 64 bit Production
    With partitioning, OLAP, Data Mining and Real Application Testing options
    Oracle Toolkit Version 9.0.4.1.0 (Production)
    PL/SQL Version 9.0.1.5.1 (Production)

    My problem:
    I have a field in a block, which is text_item and is linked to an element of LOV. I want the LOV appears automatically, whenever I tab in there, only when the element is EMPTY (for example when I try to insert in the block). When, upon request, it should show only the value in the field, and user can choose to activate the LOV, by pressing F9, if she wants to. It now displays automatically each time text agenda is a debate (works very well when the user is inserted, but annoying when she questioned the shape and trying to tab thru.) Every time she focuses on the field, LOV is popping up!)

    The current setting for the property on the element of text field: Type: text element
    The list of values: MY_LOV_NAME
    Validation of list: Yes

    Properties on MY_LOV_NAME
    Auto display: Yes

    Any suggestions? Or trigger level I can use, and if so, what build_in can use?
    New forms and will greatly appreciate advice from pros!

    Thank you
    Libran_girl

    It's very simple,

    IN once - new - item - Instance

    DECLARE
    V_LOV BOOLEAN;
    BEGIN
    IF: NOM_ELEMENT IS NULL
    THEN
    V_LOV = SHOW_LOV (LOV_NAME);
    END IF;
    END;

    Try it, you will get your result, if it doesn't work, try: block_name.item_name

    Abbas

  • Function similar to the States of SWF objects in interactive PDF format

    Is it possible, through the use of maybe text anchors and hyperlinks, to perform a function similar to the States of SWF objects in an interactive PDF?  I hope that there is a clever way to allow end users to press a button that could hide/show page content in an interactive PDF file.  I have experimented with a number of things without success and was curious to know if the users of the forum know a solution.

    See you soon,.

    Steve

    You must use the functions of hide show with buttons. Not nearly simple as WHO, but it works.

    The content that would be show/hide would need to be converted into buttons to make it work.

    Bob

  • I want to activate my window vista business, but when the window is activated, I have a problem and it is error code is 0xC004C020

    I want ro activate my vista Enterprise window, but when the window is activated, I have a problem and it is error code is 0xC004C020

    Visit: http://www.microsoft.com/genuine/diag/> and click on "start the Diagnostics.

    `~`

    0xC004C020 error code

    Symptom

    When you try to use a MAK to activate one or more computers, you may receive the following error message:

    0xC004C020
    The activation server reported that the Multiple Activation key has exceeded its limit.

    Cause

    The MAK has exceeded the activation limit. By design, MAKs have a limited number of activations.

    Workaround

    Contact the product activation call center to obtain a new MAK or to increase the limit on the existing MAK activation.

    `~`

    What type of license you have?

    If you have an OEM or FPP product, then you should have your license key on your computer or on the packaging. Contact the Microsoft Activation Center to find out if your product key is valid:

    1. click on start and in the search for box type: slui.exe 4

    2. press enter on your keyboard

    3. Select your country.

    4. take the phone activation option and brace yourself for a real person.

    `~`

    During the activation of the phone

    Go to Start

    Click run

    And type SLUI 05

    In the drop-down list, select the name of the country you live. This is important because depending on the country you select, you will assign a number to call.

    Click the nearest location > United States

    Click Next

    This window contains all the information you need.

    Step 1 contains the number you call.

    Step 2 contains a series of unique numbers, you will need to provide the series of numbers to the operator (don't make any mistakes).

    Step 3 If everything is Ok, the operator will provide you with a confirmation ID, you will need to enter numbers in the boxes in step 3 and press ENTER.

    Activation of the telephone process is simple, try to use common sense in his answers.

    If the confirmation correct what ID provided it must be welcomed by a new window confirming a real installation.

    UTC/GMT is 23:00 on Saturday, November 19, 2011

  • Field containing average function works only when the data are engaged on the same page. Does not work for fields on other pages.

    I'm having a problem with a field defined to calculate the average of eleven points fields (points 1 to 8 on page 1-9-11 on page 2). My original question was that it could exclude fields of points when they do not have information entered and adjust the average calculation (number of "divided by") accordingly.

    I had someone write JavaScript code for him, but I just found a small problem I don't know if it's something in the code or what the person who originally wrote the script cannot understand it either and suggested that I have post here.

    The middle area (located on the 2nd page of the pdf page two) seems to work exclusively with precision if at least one of the points of the fields on the 2nd page, 9, 10 (and 11) are engaged with the data. No values entered on the first page and only the first page, are for some reason any dividing by a more than expected. For example, if I fill the boxes 1, 2 and 3, it divides the total by four. If I filled just box 7, it halves. If I fill all 8 boxes on the 1st page, it divides by nine. It is corrected as soon as I get the points in one or more of the three boxes on the 2nd page points, suddenly the overall average is accurate. But if boxes 9, 10 and 11 contain no points, then the average is still inaccurate because the number of ' divide by "he uses is one more than what it should. I can't understand how to attach the form to this post, so I downloaded on Dropbox: Dropbox - used Evaluation.pdf.

    Under the direction of State: javascript came work to exclude the empty boxes when the points are entered in one of the three points of fields on the 2nd page (and more), but the average function is not accurate because it adds 1 to the number of ' divide by "in the calculation of the average If the points are only entered into the fields on the 1st page.

    Here's the code I entered in the 'Custom calculation Script' box in the 'Calculate' tab of the Properties menu of Test field:

    Initialize variables

    var num = 0;

    var sum = 0;

    Browse the input fields

    for (var i = 1; i < 12; i ++) {}

    var f = getField ("points." + i);

    If {(f.valueAsString)

    increment the counter to non-empty field

    NUM ++;

    Add the value of the running total field

    sum += + f.value;

    }

    }

    Calculate the average

    If {(num)

    Event.Value = sum / num;

    } else {}

    All fields are empty, then the empty value

    Event.Value = "";

    }

    I do not see that. Add the code of script debugging will display the results that each field is completed:

    Initialize variables
    var num = 0;
    var sum = 0;

    Browse the input fields
    for (var i = 1; i)< 12;="" i++)="">
    var f = getField ("points." + i);
    If {(f.valueAsString)
    increment the counter to non-empty field
    NUM ++;
    Add the value of the running total field
    sum += + f.value;
    }
    }
    Debug - display results as the form is filled;
    Console.Show
    Console.println (sum + "/" + num + "=" + sum/num);
    end of debugging;
    Calculate the average
    If {(num)
    Event.Value = sum / num;
    } else {}
    All fields are empty, then the empty value
    Event.Value = "";
    }

Maybe you are looking for