• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Facing problem to call a variable from anothe MXML Component.

New Here ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

How to access a variable declared in a function as "public" of an MXML Component, from another function of a deifferent MXML component. If the other MXML is declared as application I can access the canvas & BorderContaier. But If I declare as component instead of application it is not working in Flash Builder 4. Any solution?

Views

421

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

After a function finishes the variables declared in it, does not exist.

You will need to

1. Make the variable public.

2. Have the variable declared outside of the function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

I actually define the variable as "public", and also declared that before I start my function.

But still the control is not able to fine the veritable from an MXML Component, as I declared that in an different MXMl Component.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 05, 2010 May 05, 2010

Copy link to clipboard

Copied

I see, when I read your post it looked like you were trying to access a variable you defined in a function.  In any case, have you given the component an ID? If you gave that component an ID you should be able to do instanceName.variableName to access the public variable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2010 May 05, 2010

Copy link to clipboard

Copied

LATEST

I have created two MXMl components in a single project. The main MXMl application is on default package and I put the two components on different package.

Now the two components alfa.mxml and bita.mxml are on package extra.I have declared the variable in alfa.mxml like

public var vid:Video;

and use this variable in the same mxml file like:

var vidHolder:UIComponent = new UIComponent();
                    this.vid = new Video(camera.width, camera.height);
                    vid.attachCamera(camera);
                    vidHolder.addChild(vid);

Now I have a function on bita.mxml named click.I tried to call the variable vid from this function like:

     private var card:alfa=new alfa();


     public function click(): void{


         var snapDt:BitmapData = new BitmapData(card.vid.width, card.vid.height);
              

                snapshotData.draw(card.video);

                var scaleF:Number = this.pic.width/card.vid.width;


}

Here I try with debug and alert, but I saw that the control is unable to call/trace the variable vid.

In this same code I am facing another problem like:

I declared two canvases in this two mxml component.

for alfa.mxml


<mx:Canvas id="wc" x="0" y="0">
        </mx:Canvas>

and for bita.mxml

<mx:Canvas id="pic" width="75" left="10" top="10" borderStyle="none" borderColor="#000000">
            </mx:Canvas>

Now, with wc I tried to view through webcam. Then, when I capture the image I tried to view that with pic.

The problem is that the control is able to find wc, and it works perfect but cannot find pic.

Can you plese resolve this problem too????

.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines