Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 712467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:51:05+00:00 2026-05-14T04:51:05+00:00

In my mxml file, I’m doing some calculations in the script tag, and binding

  • 0

In my mxml file, I’m doing some calculations in the script tag, and binding them to a custom component.

 <fx:Script>
  <![CDATA[

   [Bindable] public var calc1:Number;
   [Bindable] public var calc2:Number;

            private function init():void {
               calc1 = //calculation;
               calc2 = //calculation;
            }
  ]]>
 </fx:Script>

    <mycomp:Ball compfield1="{calc1}" compfield2="{calc2}"/>

The problem is that the mxml component is being created before the actionscript is run. So when the component is created, it actually doesn’t get calc1 and calc2 and it fails from that point. I know that binding happens after that, but the component and its functions have already started and have run with the null or 0 initial values.

My solution was to create the component also in actionscript right after calc1 and calc2 have been created. This way I get to control precisely when it’s created

 <fx:Script>
  <![CDATA[

   [Bindable] public var calc1:Number;
   [Bindable] public var calc2:Number;

            private function init():void {
               calc1 = //calculation;
               calc2 = //calculation;

               var Ball:Ball = new Ball(calc1, calc2);
            }
  ]]>
 </fx:Script>

but this is creating all kinds of other problems due to the way I’ve set up the component.

Is there a way I can still use mxml to create the component, yet control that it the <myComp:Ball> gets created only after init() is run and calc1 calc2 evaluated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:51:05+00:00Added an answer on May 14, 2026 at 4:51 am

    Try setting your vars to zero values first:

       [Bindable] public var calc1:Number = 0;
       [Bindable] public var calc2:Number = 0;
    

    Then call the function on creationComplete:

    <mycomp:Ball 
       compfield1="{calc1}"
       compfield2="{calc2}"
       creationComplete="init()"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.