0

According to this document from Adobe Create and apply view states is <s:State/> a state object. How to create the view states in code-behind ActionScript class?

Corona S.
  • 47
  • 6
  • Actionscript doesn't have code-behind. Your MXML and AS3 code are in separate classes. – Brian Mar 03 '17 at 19:45
  • The AS class is the code behind. – Corona S. Mar 06 '17 at 07:02
  • That's not code behind. It's a separate class. – Brian Mar 06 '17 at 17:43
  • Here is the definition of "code-behind": "(computing, programming) A technique in web design (specifically Microsoft ASP.NET) in which the web page and back-end source code are stored in separate files, allowing web designers and programmers to work independently." - From [link](https://en.wiktionary.org/wiki/code-behind). In my case, the MXML is the design and the AS class is the logic. So it is a code-behind. – Corona S. Mar 08 '17 at 06:47
  • Your MXML file is a full class on its own. You might as well write MyDesign.mxml and MyCodeBehind.mxml (or MyDesign.as and MyCodeBehind.as). There's no dividing line that makes one "front-end" and the other "back-end", unlike code-behind. – Brian Mar 08 '17 at 15:57

1 Answers1

0

I have found a simple solution, and I don't have to declare the states using skinning architecture. I don't even to declare the states in my ApplicationClass which extends WindowedApplication. The solution is: declare the states only in the Main.MXML and by all means with the right namespace, in my case it should be "custom". Here is the Main.MXML:

<?xml version="1.0" encoding="utf-8"?>
<custom:ApplicationClass xmlns:fx="http://ns.adobe.com/mxml/2009"
                         xmlns:s="library://ns.adobe.com/flex/spark"
                         xmlns:mx="library://ns.adobe.com/flex/mx"
                         xmlns:custom="components.*">
    <custom:states>  
        <s:State name="loginState"/> 
        <s:State name="infoState"/>
    </custom:states>

    <s:Panel id="loginPanel" title="Login" includeIn="loginState" />

</custom:ApplicationClass>

I only want to change between different Panels, so this method works well for me. There are certainly other cases, in which the states need to be declared in skinning. I have got this solution form this link: Error: Could not resolve to a component implementation.

Corona S.
  • 47
  • 6