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

  • Home
  • SEARCH
  • 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 7841689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:09:09+00:00 2026-06-02T16:09:09+00:00

Consider the following code <fx:Script source=Script.as /> …………………. <s:Group> <s:layout> <s:HorizontalLayout/> </s:layout> <s:Spacer width=10

  • 0

Consider the following code

<fx:Script source="Script.as" />
......................
<s:Group>
    <s:layout>
        <s:HorizontalLayout/>
    </s:layout>
    <s:Spacer width="10" />
    <s:Button label="1" click="doSomething()"/>
    <s:Button label="2" click="holder.getCanvas().testDraw()"/>
    <s:Button label="3" click="doSomething()"/>
</s:Group>
<s:Scroller id="canvasGroup" width="650" height="500">
    <s:Group>
        <local:CanvasHolder id="canvas" />
    </s:Group>
</s:Scroller>

I want to move buttons in a separate module (let’s call it Toolbar.mxml). Thus I’ll need to move <fx:Script source="Script.as" /> (in Script.as I use canvas as well). Here’s my questions:

  1. How can I see canvas var in Toolbar.mxml (and can I)?
  2. Is it possible somehow to pu <fx:Script source="Script.as" /> so that it could be seen from Toolbar.mxml.
  • 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-06-02T16:09:10+00:00Added an answer on June 2, 2026 at 4:09 pm
    1. You won’t be able to automatically “see” canvas in Toolbar.mxml. I would recommend using Flex’s Event architecture to access it.

      //Extend Event class to hold any data that must be passed
      //from Toolbar -> canvas
      public class CustomEvent extends Event
      {
          public static const CUSTOM_EVENT:String = "CustomEventTypeString";
          public var mImportantInfo:String = "";
      
          public function CustomEvent();
          {
              super(CUSTOM_EVENT);
          }
      
          override public function clone():Event
          {
              var evt:CustomEvent = new CustomEvent();
              evt.mImportantInfo = mImportantInfo;
              return evt;
          }
      }
      
      //in Script.as
      myToolbarID.addEventListener(CustomEvent.CUSTOM_EVENT,customEventHandler);
      ...
      protected function customEventHandler(var evt:CustomEvent)
      {
          canvas.myFunction(evt.mImportantInfo);
      }
      
      //in Toolbar.mxml
      var evt:CustomEvent = new CustomEvent();
      evt.mImportantInfo = "canvas needs me!";
      dispatchEvent(evt);
      

      Alternatively, you can pass the canvas object to the Toolbar directly.

      <local:Toolbar ... myCanvas="{canvas}" ... />
      
      //in Toolbar.mxml
      public var myCanvas:CanvasHolder;
      ...
      myCanvas.myFunction(...);
      

      Yes, the second option is much simpler, but the first option is often useful when the components that need to talk aren’t easy to pass to each other.

    2. You can put <fx:Script source="Script.as" /> in Toolbar.mxml, if that’s what you need. If you need to call functions in the scope of the parent, I would recommend using the Event architecture again, as opposed to some kind of parent... or Application.application... call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following script for outputting some XML code: var xmlAsString = '<?xml version=1.0?><person><name
Consider the following code: <script> var i = 0; function test() { var _this
Consider the following piece of code. <html> <body> <script> var x = 5; //globally
Consider the following piece of code: <html><head></head> <body> <script type=text/javascript> var outside_scope = outside
consider the following code: <script> function testFunc(){ alert('test') } $(function(){ var g = document.getElementById
Consider following code: enum size = 16; double[size] arr1 = [...]; double[size] arr2 =
Please consider following code: 1. uint16 a = 0x0001; if(a < 0x0002) { //
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
Consider the following code: @Service class UserSpecificService { @Autowired ServiceA serviceA; @Autowired ServiceB serviceB;
Consider the following code: $(a).attr(disabled, disabled); In IE and FF, this will make anchors

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.