私はフレックスで作っていますが、ボタンをクリックするとxml内のボタンのテキストがランダムなエントリに変更されます。 xmlはassetsフォルダにあり、games.xmlというタイトルが付けられています。ボタンを押したときにランダムなゲームを選択したいと思います。ここflex - ボタンのテキストをランダムなxmlエントリに変更onclick
ここgames.xml
<games>
<game> GameName1
<description> description1 </description>
</game>
<game> GameName2
<description> description2 </description>
</game>
<game> GameName3
<description> description3 </description>
</game>
</games>
とあるフレックスファイルはあなたが提供することができます任意の助け
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
backgroundColor="#0000FF" title="games!">
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
gamebutton.label="test" <---i want this to be a random game name
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button id="gamebutton" click="button1_clickHandler(event)" horizontalCenter="0" top="10" x="0" width="95%" label="Pick A Game"/>
</s:View>
感謝です!
コードの最終版では、数字のプレースホルダだけでなく、ゲームの名前も異なります。それをXMLから引き出す方法はありますか?申し訳ありませんが最初にはっきりしませんでした – BretzelPretzel