4 Replies Latest reply on Sep 14, 2010 10:47 AM by bobgalka

    How to set a property in one custom component from another

    bobgalka

      Hey all....

      I have been trying to lean how to refactor code from Catalyst in Flash Builder... Making progress but I am stumped on how to handle the following...

       

      I have one custom component that processes files from a couple of directories... I have another custom component that displays progress bars for each directory...  so.. in the file processing component I want to manually update the progress bars with the setProgress function....

       

      Here is the progress bar module....  (let's call it CustomComponent10.mxml)

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Group

      xmlns:s="library://ns.adobe.com/flex/spark"

      xmlns:fx="http://ns.adobe.com/mxml/2009"

      xmlns:components="components.*"

      xmlns:d="http://ns.adobe.com/fxg/2008/dt"

      xmlns:mx="library://ns.adobe.com/flex/mx">

       

      <s:Rect height="150" d:userLabel="progressContainer" width="443" x="0.5" y="0.5">

       

      <s:stroke>

       

      <s:SolidColorStroke caps="none" joints="miter" miterLimit="10" weight="1"/>

       

      </s:stroke>

       

      </s:Rect>

       

      <mx:ProgressBar x="16" y="12" id="beforeProgress" width="418"

      mode = "manual"

      minimum = "0"

      maximum = "100"

      visible = "true"

      direction="right"

      labelPlacement="center"

      label="Before Images 0%"/>

       

      <mx:ProgressBar x="16" y="56" width="418" id="afterProgress"

      mode = "manual"

      minimum = "0"

      maximum = "100"

      visible = "true"

      direction="right"

      labelPlacement="center"

      label="After Images 0%"/>

       

      <mx:ProgressBar x="16" y="102" width="418" id="bgProgress"

      mode = "manual"

      minimum = "0"

      maximum = "100"

      visible = "true"

      direction="right"

      labelPlacement="center"

      label="Background Images 0%"/>

       

      </s:Group>

       

      so from the file processing module (let's call it CustomComponent4.mxml) I try to code the following.....

       

      public var app:Object = mx.core.FlexGlobals.topLevelApplication;

       

      if (app.folder == "before")

      {

      app.beforeProgress.setProgress(app.index, app.files.length);

      app.beforeProgress.label = "Before Images: " + (app.file.length/app.index)*100 + "%";

      }

      else

      {

      app.afterProgress.setProgress(app.index, app.files.length);

      app.afterProgress.label = "After Images: " + (app.files.length/app.index)*100 + "%";

      }

       

      but I get this at run time.....

      ReferenceError: Error #1069: Property beforeProgress not found on Main and there is no default value.
      at components::CustomComponent4/doLoaderComplete()[C:\Users\Bob\Adobe Flash Builder 4\BeforeAndAfterGallery-artboards_1\src\components\CustomComponent4.mxml:127]

       

      what to do.. what to do...  ;O)

       

      thanks for looking

       

      bob