質問

I have extended the SkinnablePopUpContainer to make a popup window in mobile application. But i don't know how to pass a variable defined in the main view to this component. My code looks like the following

<fx:Declarations>
 <fx:Component className="Alert">
  <s:SkinnablePopUpContainer>
   <s:Button label="OK" click="close()"/>
  <s:SkinnablePopUpContainer>
  <fx:Script>
<![CDATA[
     private function setMetaDataXML(metaDataXML:XML):void{
        var temp = metaDataXML;
     }
    ]]>
   </fx:Script>
 </fx:Component>
</fx:Declarations>

--- main view continues and here is how I call the component on a button click from the main view:

    click="(new AlertMsg()).open(this, false)"

now i just want to call setMetaDataXML from the main view and pass the value. How can I achieve that? Thank you

役に立ちましたか?

解決

I would recommend to create your component in a separate mxml file or even better in a pure AS3 based component. To do what you want to do, you could create a handler function in your Script area for that click event, and in there assign the instance of the component and then call any method before calling open, like:

click = "clickHandler()"
----- inside your script

function clickHandler : void {
    var a : AlertMsg = new AlertMsg();
    a.setMetaDataXML("foo");
    a.open(this,false);
}

I would also recommend you to declare implicit setters and getters the AS3 way

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top