I'm, using Flex 4.5.
In my application I have a CandlestickChart with basic CandlestickSeries.
I give the user the ability to add a linechart on top of the candlesChart by adding a LineSeries to the CandleStickChart as explained in adobe's docs here: here
My problem is that when the line is added it changes the shape of the candle to be narrower. Moreover, every line that is added is making the candle be narrower.
I've looked around and found this thread in adobe's forums: "CandlestickChart problem with LineSeries" which describes the exact same problem.
Unfortunately, the thread is still not answered.
Does any one knows a solution for this problem?
Thanks in advance,
Ravid
Well, the solution I found is not nice and better solutions are still appreciated but for those of you that have the same problem this solution worked for me:
The problem occurs because the candle's default item renderer uses the item's width to calculate the size of the candle which is make sense.
The problem, is that when you add another series there is a bug and the item's width is changed thefore the candle is changed.
My solution is to create a copy of the default item renderer and draw the candles based on the graph's width and number of candles you wish to put there (so you don't use the item's width).
It fixes the problem but if you use tooltips functionality than it kinda messes its placement relative to the candle.
I know this answer is a bit late, but in case it helps anyone else, here's what I did.
(It's not thoroughly tested either)
Make a class that extends the CandleStickChart class and simply override the "applySeriesSet" function as so:
override protected function applySeriesSet(seriesSet:Array /* of Series */,
transform:DataTransform):Array /* of Series */
{
// filter out the non-candlestick series
var filteredSeriesSet:Array = new Array();
for each(var series:Series in seriesSet){
if(series is CandlestickSeries) filteredSeriesSet.push(series);
}
// call the CandlestickChart applySeriesSet function with the filtered set, ignore return value
super.applySeriesSet(filteredSeriesSet, transform);
// do the code that the CartesianChart applySeriesSet function would have done, but with the unfiltered seriesSet
// would have preferred to do something like super.super.applySeriesSet(seriesSet, transform);
var n:int = seriesSet.length;
for (var i:int = 0; i < n; i++)
{
var newSeries:IChartElement = seriesSet[i];
if (newSeries is Series)
customizeSeries(Series(seriesSet[i]), i);
}
return seriesSet;
}
Related
I'm looking for a simple and quick way to clear the entire Phaser screen, like how in HTML5 canvas you can erase everything by resetting the width of the canvas to itself. I couldn't find any such method with a search - only graphics.clear(), but that doesn't hit other stuff like text objects. Is there such a way to clear screen?
Thanks.
There are methods to destroy specific elements - obj.kill() and obj.destroy() - but it is possible to delete all elements by calling game.world.removeAll().
#FabiánRodríguez replied, but you can also make a array or object literal with the objects you'd like to remove, so iterate and remove each. That is when you want to group objects.
var layout = {
rect: new Phaser.Rectangle(0, 0, 200, 200)
};
for(var i in layout) {
layout[i].kill();
layout[i].remove();
}
I've included a zoom functionality similar to the one explained at this website:
http://www.flashandmath.com/howtos/zoom/
This works perfectly on my background image(a map, that is), but I want to keep the symbols on my map the same size while zooming in.
I probably could work this out by changing all the children's size when calling the zoom-function, but I am hoping there is some kind of easy code adapt in my children class to make the size of the instances unchangable. Is there?
Thanks!
One crude way, so you don't have to calculate the symbols scale, would be to remove the symbols from the mapDisplayObject so they're no longer a child and instead put symbol placeholders. Then match each symbol's x and y to each place holder, using localToGlobal...
If your children are not scaled or skewed or rotated you can iterate all of them and set transformation matrix to 1/parentScale. Something like:
for each (var child:DisplayObject in parent) {
var matrix:Matrix = child.transform.matrix;
matrix.a = 1/parentScale;
matrix.d = 1/parentScale;
child.transform.matrix = marix;
}
I have a scrollpane to which I add movieclips to. I am using it a an online users list. It works well so far but now I have run into a problem. I am able to remove the movieclips I want easily enough using removechild, but when I remove it there is only a blank space where the removed clip was. So I need to know how to have the scrollpane refresh somehow and move the clips below that one removed up. How can I do this?
I have tried invalidate, refreshPane, update, etc. Maybe I didnt have them in the correct order or something, but how can this be done?
If the answer is complex, could an example be provided please? Im really not good enough with as3 just yet to code an entire algorithm to get the number of children, remove them all, readding them, etc.
Any help please?
Just a variation, but saves the -1, simply rearrange such as:
lstOnline.removeChild(lstOnline.getChildByName("NAMEHERE"));
var numleft:Number = lstOnline.numChildren;
for(var i = 0; i < numleft - 1; i++) {
lstOnline.getChildAt(i).y = i*60;
}
Guess I was a little better than I thought. In case anyone else faces this problem, the solution I found was the following:
var numleft:Number = lstOnline.numChildren;
lstOnline.removeChild(lstOnline.getChildByName("NAMEHERE"));
for(var i = 0; i < numleft - 1; i++) {
lstOnline.getChildAt(i).y = i*60;
}
lstOnline is the name of the ScrollPane and in my case 60 is the height of the added movieclips.
How can I remove only every image found in a Bordercontainer which also holds Textinputs and Buttons ?
i tried:
for(var i:int=0;i<container.numElements;i++){
if(container.getElementAt(i) is Image){
container.removeElementAt(i);}
}
But as expected this loop does not fully work since the numElements changes which means that not all Images get removed.
I know there is some simple trick to this...but I cant think of it right now...Please help
As commenters have suggested, it seems like looping backwards would be the way to do it. I'd try something like this:
var totalElements : int = container.numElements;
for(var i:int=totalElements-1;i>=0;i--){
if(container.getElementAt(i) is Image){
container.removeElementAt(i);
}
}
By storing the numElements in a variable before starting the loop, you can be sure that the value will not change while processing the loop. Since your going backwards, you don't have to worry about the child index changing.
A second option would be to queue up the image instances in one loop and remove them in a second loop using the removeElement method. I suspect the two loop method will have significantly worse performance.
Looping backwards would be 1 way to do this.
Another would be
for(var i:int=0; i<container.numElements; i++){
if(container.getElementAt(i) is Image){
container.removeElementAt(i);
i--; //This nullifies the effect of removing an element
}
}
Anyone know how to animate the size/position of child elements of a layout in Flex 4 ?
Example:
I have a list component with a custom layout. I want when I change the positions of the child elements I want them to animate their move to the new positions.
There is currently no built in way, nor plans, to make animated layouts in Flex 4 :/.
What I've done to make this happen is to animate the setting of "setLayoutBoundsPosition" and "setLayoutBoundsSize" in the layout. So instead of creating a "Move" and "Resize" effect for each item in the layout, which would actually set the width and height explicitly, set the matrix. Then make sure the layout isn't invalidated again (which will happen if you set the width/height directly), or you might start getting an infinite loop. You might have to do some tricks to get this to work right (I haven't got it to work quite right with the Spark Effects, but it's really easy to do with Tweener/Tweenmax, since they have plugins and such to use "setActualSize" or "setLayoutBoundsSize", etc.).
I use TweenMax to animate layouts, and they have a few plugins to make this easy. TweenMax visibly looks like 3x faster (20 fps vs 7fps) than Spark Effects, too, so I'd go with that. It looks something like this, in the updateDisplayList method of your layout.
TweenMax.to(child, duration, {setLayoutBoundsPosition:{x:childX * i, y:childY * i}});
Just like you would normally...
public override function updateDisplayList(width:Number, height:Number) : void {
for (var i:uint = 0; i < target.numElements; i++)
{
var resizeElement:Resize = new Resize(target.getElementAt(i) as IVisualElement);
resizeElement.widthTo = 500;
resizeElement.play();
}
}