5 Replies Latest reply on Dec 17, 2009 11:41 AM by BoydMills

    syntax question

    BoydMills Level 1

      I have two files, one an mxml file, one a .as file.

       

      the mxml file is presented here in abbreviated form:

      ---------

      <vci:LoginBase
      xmlns:mx="http://www.adobe.com/2006/mxml"
      xmlns:vci="com.vcicontrols.gui.*"

      borderStyle="none"
      width="600" height="400" horizontalCenter="0" verticalCenter="0"
      backgroundAlpha="0.3"  backgroundSize="100%"
      initialize="init();"
      creationComplete="startup();"
      >
      <mx:Image source="assets/images/VCI trans.png"  scaleX="0.3" scaleY="0.3" left="5"  id="WelcomeVCILogo"  />

      </vci:LoginBase>
      -----------------

       

      the init() and startup() functions are both within the .as file and execute properly.

       

      My question then is how to access the Image defined in the mxml file by code in the .as file.

       

      I presume it is some "simple" (if you know it) syntax issue.

      Please advise.

        • 1. Re: syntax question
          BoydMills Level 1

          If it helps at all, when I step through the .as code using the

          Builder in debug mode, I can inspect 'this.WelcomeVCILogo' as an Image object.

           

          But when I try to add a line of code such as:

           

          this.WelcomeVCILogo.load("abc");

           

          I get the following compile error:

           

          ========================

          Severity and Description Path Resource Location Creation Time Id
          1119: Access of possibly undefined property WelcomeVCILogo through a reference with static type com.vcicontrols.gui:LoginBase. VCI/src/com/vcicontrols/gui LoginBase.as line 129 1261071129666 3345
          ========================

           

          I'm guessing if it complains about a "static" typle, logically there must be a "dynamic" type?

           

           

          Please advise.

           

          Boyd

          • 2. Re: syntax question
            Gregory Lafrance Level 6

            parentApplication.WelcomeVCILogo

             

            or

             

            mx.core.Application.application.WelcomeVCILogo

             

            If this post answers your question or helps, please mark it as such.


            Greg Lafrance
            www.ChikaraDev.com

            Flex Development and Support Services

            • 3. Re: syntax question
              BoydMills Level 1

              Sorry, nope, that doesn't work.

               

              If it should, then maybe something is missing?

               

              Please advise.

              • 4. Re: syntax question
                BoydMills Level 1

                I did make a small change to the loginbase.as file so as to import from the .mxml file:

                [import com.vcicontrols.gui.Login;]

                below are the two files, login.mxml and loginbase.as

                Both have been stripped of irrelevant code for the purpose of this post.

                 

                Having added the mentioned import, the code now compiles, so we seem to be in the right direction.

                I left in the module [getbackground():String] to indicate that it does get dynamically created variables from the application level.  VCIFormsPage is defined as an mx:Label in the vci.mxml application module.

                 

                 

                But now I get an execution error:

                ================

                ReferenceError: Error #1069: Property WelcomeVCILogo not found on VCI and there is no default value.
                at com.vcicontrols.gui::LoginBase/GetConfigurationResult()[C:\from luc 4 point\VCI\src\com\vcicontrols\gui\LoginBase.as:132]
                at flash.events::EventDispatcher/dispatchEventFunction()

                 

                ==================

                 

                 

                ======================================

                login.mxml:
                ================
                <vci:LoginBase
                xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:vci="com.vcicontrols.gui.*"

                borderStyle="none"
                width="600" height="400" horizontalCenter="0" verticalCenter="0"
                backgroundAlpha="0.3"  backgroundSize="100%"
                initialize="init();"
                creationComplete="startup();"
                >

                <mx:Image source="assets/images/VCI trans.png"
                        scaleX="0.3" scaleY="0.3" left="5"
                        id="WelcomeVCILogo"
                        />

                </vci:LoginBase>
                =================
                loginbase.as:
                =================
                package com.vcicontrols.gui
                {
                import com.vcicontrols.events.PortalEvent;

                import flash.events.NetStatusEvent;
                import flash.net.SharedObject;
                import flash.net.SharedObjectFlushStatus;

                import generated.webservices.ServiceVCI;
                import generated.webservices.WsVCIGetConfigurationDataResultEvent;

                import mx.containers.Canvas;
                import mx.controls.Alert;
                import mx.controls.Image;
                import mx.core.Application;
                import mx.rpc.events.FaultEvent;


                import com.vcicontrols.gui.Login;

                    
                public class LoginBase extends Canvas
                {
                protected var mouseEvents:PortalMouseEvents = new PortalMouseEvents();
                private var sharedObject:SharedObject;
                [Bindable]protected var userId:String;
                [Bindable]protected var rememberUserId:Boolean;
                [Bindable]protected var bgImage:Image;
                        private var GetConfigurationWS:ServiceVCI;

                 

                  protected function getbackground():String
                {
                    return( this.parentApplication.VCIFormsPage.text +
                          "VCIWebFileRetrieve.aspx?SPECIAL=WelcomeBackgroundImage");
                }

                     
                        private function GetConfigurationResult( event:WsVCIGetConfigurationDataResultEvent):void
                        {
                      
                           setStyle("backgroundImage", getbackground()  );
                           this.parentApplication.WelcomeVCILogo.load(getbackground());
                      
                }
                    


                }
                }===========================================

                • 5. Re: syntax question
                  BoydMills Level 1

                  I redefined the mx file to specify:

                   

                   

                  <mx:Image source="{WelcomeVCILogoImage}"  ....

                   

                  then changed the the .as file to include:

                   

                  [

                  Bindable]protected var WelcomeVCILogoImage:String;

                   

                   

                  Then when resolved, assign

                  WelcomeVCILogoImage = getbackground();

                   

                   

                   

                   

                  And that works!

                   

                   

                  Same thing in reverse order.