Re: Flex RL ?
- From: Tarindel <aapomeranz@xxxxxxxxx>
- Date: Mon, 17 Sep 2007 10:23:01 -0700
On Sep 17, 9:36 am, konijn_ <kon...@xxxxxxxxx> wrote:
<SNIP Code>
I have the following :
( Context around it snipped but the thing should be fairly obvious to
read )
//dp = data provider
[Bindable]
public var dp:Array=new Array(rows*cols);
<mx:ArrayCollection id="consoleArray" source="{dp}"/>
<mx:Repeater id="r" dataProvider="{consoleArray}">
<mx:Label id = "cell"
x= "{setX(r.currentIndex)}"
y= "{setY(r.currentIndex)}"
text="{setNews(r.currentIndex)}"
color="white" fontFamily="Terminal" fontWeight="bold"
fontSize="15" click="doClick()" fontAntiAliasType="normal"
textAlign="center"/>
</mx:Repeater>
So basically this way with the repeater control I create row * cols
labels that contain each 1 character. The spacing tends to be awkward
sometimes, but it looks reasonably well. I takes about 3 to 4 seconds
to initialize which is ok for a flash game I guess. I like your
approach probably more though. It might be faster to copy label
Objects than initialize them ?
That is quite cool -- I haven't really explored the repeater
functionality yet.
Here's an idea I just had -- rather than initializing individual
labels for each character, have you considered the idea of making the
entire drawable area one big textbox, and then writing to the textbox
using the htmlText property and either a monospace font or the TT html
element? I think you might be able to blast the whole playing area to
the screen in one go, and the monospacing would take care of the
placement issue for you automatically. It would also improve your
load time since it would be initializing one control rather than x*y
individual labels. I really have no idea if it would actually work,
but it seems worth trying. :)
Also, here's one more hint that you might be able to make good use of:
It's possible to fill out a DataGrid manually, which can come in handy
when you want to stuff one full of data but don't have preconstructed
XML from some other source. Here's how you do it:
// Declare your datagrid
<mx:DataGrid x="0" y="0" height="183" width="238" id="ScoreGrid"
dataProvider="{ScoreArray}">
// Instantiate your data provider
[Bindable] public var ScoreArray:ArrayCollection = new
ArrayCollection();
// Write a function to fill out your data (FinalScores is a user-
defined class)
public function DisplayScores(FinalScores:Array) : void
{
ScoreArray.removeAll();
for (var i:int=0; i < FinalScores.length; i++)
{
ScoreArray.addItem(
{ Name:FinalScores[i].GetName(),
VPts:FinalScores[i].GetTotalPts(), Gold:FinalScores[i].GetGold() }
);
}
}
When you call DisplayScores(), it will stuff your ArrayCollection full
of data, which will then show up in your DataGrid.
I could see doing something like this for inventory displays: switch
the state to an inventory screen, grab your character's inventory, and
use a loop to stuff it into a datagrid. Of course, this is assuming
that you're doing your inventory in the classic roguelike style, and
not pictorially.
.
- Follow-Ups:
- Re: Flex RL ?
- From: konijn_
- Re: Flex RL ?
- References:
- Flex RL ?
- From: konijn_
- Re: Flex RL ?
- From: Radomir 'The Sheep' Dopieralski
- Re: Flex RL ?
- From: konijn_
- Re: Flex RL ?
- From: Tarindel
- Re: Flex RL ?
- From: konijn_
- Flex RL ?
- Prev by Date: Re: Flex RL ?
- Next by Date: Re: Flex RL ?
- Previous by thread: Re: Flex RL ?
- Next by thread: Re: Flex RL ?
- Index(es):
Relevant Pages
|