Hurrah!
My date sorting problem is finally solved. Simply format your date with the most important figures first, and with leading zeros. Then any ordinary sort (ie alphabetical) will return an array of these sorted by year, then month, etc.
eg. 4.15pm 23rd September 2009 => '2009-09-23-16-15'
PS. Actionscript 3 considers 09 to represent the month of October, because January is 0.
A diary about programming problems - to help me more easily learn from (and Google) past mistakes.
Monday, 21 June 2010
Friday, 11 June 2010
Oh dear, oh dear ... oh dear.
Stung by the cache of loaded swfs... again.
Basically, the animation was getting hung up because it couldn't find the variables is was looking for - because instead of loading the updated swf - it was loading some outdated version that didn't have everything in it.
The way to avoid this, for testing purposes, is to attach a querystring with a random value - so that each time the swf is loaded, it is a different call, then the browser will look for the most recent file.
Stung by the cache of loaded swfs... again.
Basically, the animation was getting hung up because it couldn't find the variables is was looking for - because instead of loading the updated swf - it was loading some outdated version that didn't have everything in it.
The way to avoid this, for testing purposes, is to attach a querystring with a random value - so that each time the swf is loaded, it is a different call, then the browser will look for the most recent file.
Text won't load
I have decided to mention this before I figure out how to do it - thinking out loud, as it were, might help me to make sense of it.
So I am going to remove functionality step by step, until I track the source of the problem - I have an array that contains a list of all the text fields, and a pointer to what text it should be displaying, it works on the frames that aren't that complicated.
It also works on my test environment.
So first of all, I will switch off all the php/js type things in the swf, and see if it works then.
So I am going to remove functionality step by step, until I track the source of the problem - I have an array that contains a list of all the text fields, and a pointer to what text it should be displaying, it works on the frames that aren't that complicated.
It also works on my test environment.
So first of all, I will switch off all the php/js type things in the swf, and see if it works then.
Thursday, 10 June 2010
Array.filter
Using a helpful page by 'devon o wolfgang', I am using this:
var arr:Array = ['','later','what','','ok'];
trace(arr);
arr = arr.filter(removeBlankElements);
function removeBlankElements(element:*, index:uint, arr:Array):Boolean {
return element != '';
}
trace(arr);
to get rid of blank string elements in my arrays.
var arr:Array = ['','later','what','','ok'];
trace(arr);
arr = arr.filter(removeBlankElements);
function removeBlankElements(element:*, index:uint, arr:Array):Boolean {
return element != '';
}
trace(arr);
to get rid of blank string elements in my arrays.
Getting the String out of the Textfield
I had always thought, possibly due to the lack of autofill, that you couldn't do this:
trace(f.text.indexOf('h'));
but you can.
Oh well.
trace(f.text.indexOf('h'));
but you can.
Oh well.
Friday, 4 June 2010
Inactivating buttons
This is just to remind myself, it is not the first time I have come across this issue, but I still managed to forget it anyway...
I have a movieclip with a button inside it. I attached an event listener to the movie clip. In order to deactivate it, I had to set mouseEnabled to false for both the button AND the movieclip.
I have a movieclip with a button inside it. I attached an event listener to the movie clip. In order to deactivate it, I had to set mouseEnabled to false for both the button AND the movieclip.
Event Listeners
When adding eventListeners, it is normally necessary to write a specific function that will respond, because most of actionscript's pre-existing functions that you might think you could just use 'straight' as it were, get upset when they receive the event as a parameter.
e.g.
btn.addEventListener(MouseEvent.CLICK, stop);
stop() is not expecting any parameters, and doesn't like the event parameter it receives. I have found one exception to this rule, and the result is quite interesting.
btn.addEventListener(MouseEvent.CLICK, trace);
results in:
[MouseEvent type="click" bubbles=true cancelable=false eventPhase=3 localX=4.15 localY=-0.95 stageX=41.6 stageY=405.65 relatedObject=null ctrlKey=false altKey=false shiftKey=false buttonDown=false delta=0]
Interesting...I wonder what delta is, but can't be bothered to figure it out now.
e.g.
btn.addEventListener(MouseEvent.CLICK, stop);
stop() is not expecting any parameters, and doesn't like the event parameter it receives. I have found one exception to this rule, and the result is quite interesting.
btn.addEventListener(MouseEvent.CLICK, trace);
results in:
[MouseEvent type="click" bubbles=true cancelable=false eventPhase=3 localX=4.15 localY=-0.95 stageX=41.6 stageY=405.65 relatedObject=null ctrlKey=false altKey=false shiftKey=false buttonDown=false delta=0]
Interesting...I wonder what delta is, but can't be bothered to figure it out now.
Subscribe to:
Posts (Atom)