Thursday, 20 September 2012
as3 empty a movieclip
Well I was a little puzzled as to how to do that. However I did find this 3 liner and works a flipping treat!
for (var i:int = cliptoclear.numChildren - 1; i >= 0; i--) {
cliptoclear .removeChildAt(i);
}
.
Wednesday, 29 August 2012
Resize html5 canvas width/height element to its content
Im looking for a similar method to the one below. Unfortunately you can't change the width of a canvas element half way through your code with out redrawing it.... pants.
I think theirs away to save the content of the canvas to an image before you re-size the width.
After which you simply redraw the content after re-size.
...I couldnt get it to work so my codes a little bit more drawn out.
var canvas;
var context;
var width;
var height;
function domLoaded(e){
canvas = document.getElementById("scroller");
context = canvas.getContext("2d");
width = canvas.getAttribute('width');
height = canvas.getAttribute('height');
var imageObj = new Image();
canvas.style.backgroundColor="red";
imageObj.onload = function() {
context.drawImage(imageObj, 0, 0);
var txt = "Doesnt matter how much text you put here the canvas will resize.";
context.font = "15pt Calibri";
context.fillText(txt,imageObj.width, 15);
var totalWidth = context.measureText(txt).width+imageObj.width;
canvas.width = totalWidth;
width = canvas.getAttribute('width');
context.drawImage(imageObj, 0, 0);
context.font = "15pt Calibri";
context.fillText(txt,imageObj.width, 15);
};
imageObj.src = "http://www.html5canvastutorials.com/demos/assets/darth-vader.jpg";
}
document.addEventListener("DOMContentLoaded", domLoaded);
Tuesday, 28 August 2012
draw html5 canvas element to a master canvas element
So from a flash point of view this would be similar to creating an empty moving clip and then using addchild add content to that movieclip.
Then add the movieclip to the stage.
So I found this post....
http://kaioa.com/node/103
I kind of got it... But I'm a little new to javascript and to me it seemed a little bit complicated to having methods sent into other methods.
So I changed it a little for somthing that sits more comfortably in my brain sells!
My code looks like this and was just what I was after...
var canvas;var context;var width;var height;
function domLoaded(e){
canvas = document.getElementById("scroller");
context = canvas.getContext("2d");
width = canvas.getAttribute('width');
height = canvas.getAttribute('height');
var renderToCanvas = function (width, height) {
var buffer = document.createElement('canvas');
var canvasCradle = buffer.getContext("2d");
buffer.width = width;
buffer.height = height;
canvasCradle.font = "15pt Calibri";
canvasCradle.fillText("Morning all!", 25, 20);
return buffer;
};
var cached = renderToCanvas(150, 25);
context.drawImage(cached, 0, 0);
}
document.addEventListener("DOMContentLoaded", domLoaded);
So on Dom load I GET my canvas element that has an id called scroller from my html markup.
I get its width/hight/context ect and set them to vars.
Now Im ready to create a new canvas element to be drawn to "canvas"
Ive created cached which is equal to the method renderToCanvas
This then creates a new canvas element
I can treat that like any other canvas elements... add what I want to it. I return that canvas element
Cached is now that element I created on the fly and I can now use drawImage on master canvas to draw it to screen.
Sunday, 5 August 2012
new app simple lists
Tuesday, 31 July 2012
3 Day mountain bike trip, Lakes and Scotland
photos from out 3 day trip are here...
Flickr album of Lakes and Scotland mountain biking
We got our Bikes into the back of Jamies Pickup truck. I had my specialized pro pitch 2011. Jamie had his Specialized XC.
We were going for an old favourite, Whinlatter...
http://www.forestry.gov.uk/alturatrail
Whinlatter is like a RollerCoaster but one that lasts a bit longer! Climb for a while, downhill, climb for a while and one final downhill. You could easily do two runs of this trail in a day.
It sounds basic but its great. The climbs are fine and the downhill sections are great. Lovely berms, switch backs and jumps.
Heres the stats on that ride...
http://www.endomondo.com/workouts/75609808
After that we chucked the bikes into the pickup, we had a quick pint in a nice local pub and booted it up to Innerleithen, Scotland.
We were staying at a local camp site in tents...
http://www.tweedsidecaravanparkinnerleithen.co.uk/
Nice enough but I had managed to forget my sleeping bag and pillow. ... Winning.
We were meeting a friend in Innerleithen that was stopping in a Cottage with a group of his mates that had also come up from York. We all went out for a meal that evening at a local Italian. I got smashed in the hope it would knock me out, so that I might sleep even without a sleeping bag. ... Didnt work. Didnt sleep well at all.
Any how after a hearty breakfast it was time for the first trail of the day at Innerleithen. This has some killer black routes. we Got there at 10am and already I must of counted 20/30 top of the range downhill bikes... Beasts... But no good for the climb we were about to do on the red route. Climbed for over an hour. Big big climb. We climbed from 620ft to 2025ft.
But in return for out hard work we got some of the most epic downhil trails Ive done. Not sure which was more excited, me or the bike! It just felt really at home on that trail, safe and absolutely able to smash it. Some lovely jumps that you had time to get ready for. Towards the bottom we got some good flatter trail with fast switch backs.
At the end for the last mile you join the down hill black. Probably the most testing part of the ride for me and the bike. ... one word Epic! I had downhillers coming down at all angles in full face helmets and neck brasses. But I think me and the pro pitch held our own. I was hanging off the back of the bike with my seat right down while my bike threw me into corners and jumps with no problem. Great great fun.
The stats for Innerleithen...
http://www.endomondo.com/workouts/75609808
The Innerleithen Run was just for starters! A couple of the lads bikes needed a bit of maintance one bike had snapped a chain the other smashed a gear shifter on a fall. These guys sorted any issues out in double time for us...
http://www.alpinebikes.com/
We then loaded all the bikes into the van and Jamies pickup truck and rocked up to Glentress, 10 minutes drive for Innerleithen. Glentress had everything you would need blue,red, black runs and a massive jump park.
We started off with a bite to eat in the cafe and then headed up another long uphill red route. After maybe 45minutes we got to the top. I was really starting to feel low on energy now. Food nor energy bars would make feel any better. I was reaching my limit for the day.
After a 5 minute break we set off down into the first part of the trail "spooky wood". ... amazing. Again I seemed to feel more at one with bike with the seat post right down and my ass hanging off the back and letting the bike tear into corners and shifting my weight with it. It was awesome, the reason I had bought this bike was for this kind of stuff. Switch backs, berms, table tops, humps, jumps. It had it all.
Towards the end I was really starting to suffer. I was desperate to keep my energy up so I could push the bike where I wanted it to go but my arms were starting to give up. I had got to the point of just holding on!
By the time we got to the end my head was saying lets go again... my body was saying lets sleep for a week! ...
The stats...
http://www.endomondo.com/workouts/75927685
That evening I opted to stop in the cottage, a spare bunk bed was going so I had that.
For food we took a taxi over to peebles... Which just so happened to be where my mum and dad had there honey moon 30 something years ago.
Burger,beers,Taxi home, In-betweeners the movie DVD then BED
Next morning we had hoped to give the black run a going over at Glentress, but the lads that had done it in the past said it would be a bad idea... Apparently the climbs are a bit intense! Instead we opted for a raz round the jump park and then back to the top using short cuts up fire roads to spooky wood and down again.
This time we went for some of the blue run. The blue run is great! It is a must. smooth switchbacks with jumps and berms.
This happened to be the only place on the entire trip where I nearly lost it. Took a table top jump with my weight over the front... Just managed to get it back over the rear wheel before landing.
I am crap at jumps though... must manage my weight better, and trust in my bike!
And that was it done! back to york in 3/4 hours.
http://www.endomondo.com/workouts/75927685
Once again these are the photos from our three days...
Flickr album of Lakes and Scotland mountain biking
Amazing weekend!
Thursday, 17 May 2012
Checking for empty xml nodes in as3
so something like....
<aidanmack></aidanmack>ok so this script isn't all there but I reckon you should get the idea.I would of thought doing something like this....if(aidanmack == null){trace("its empty")}orif(aidanmack == undefined){trace("its empty")}orif(aidanmack ==""){trace("its empty")}... WOULD have worked but noooo. doesn't bite at all!Instead I've found you have to check the length!so..if(aidanmack.length > 0){trace("has something in it");}else{trace("its empty");}
Saturday, 5 May 2012
corona scrollview masking issues now fixed!
When I submitted the app I received an email to tell me that my app submission had been unsuccessful due an issue where the screen would go black if the app lost focus. For example if you took a phone call and then came back to the app it would now be black.
This proofed difficult to home down as it was only occurring on device, I could not reproduce the problem within the corona simulator.
Finally after hours of commenting bits of code out I homed it down to an issue with masking on the scrollers for picking googly parts.
Then after many hours of trying to fix it I realised the issue wasn't my code.. It was in fact an issue with corona.
I submitted this as a bug about two weeks ago... Its now finally been fixed today! Hats off to corona though. They do listen to there community and I had allot of support from staff members on the forums.
If you are not a subscriber you will not be able to install the version that supports it. Corona release fixes for subscribers. None subscribers can only get there hands on the stable version.
So next stop resubmission to the amazon market!
https://play.google.com/store/apps/details?id=com.googleeyes
Thursday, 26 April 2012
corona lua storyboard...
When I was developing googly face the main problem I had was keeping variables clean and listeners nulled after use. My developers head was working like it would in as3. That didn't cut it... In the end, admittedly googly face scene management was cobbled together with a barrage of "nilling" vars and listeners here there and every where.... meh it worked, but would of been a frecking nightmare if it was in anyway more complicated.
https://play.google.com/store/apps/details?id=com.googleeyes&hl=en
This was the main issue I had to address when I thinking about my new app.
I had heard about coronas new storyboard API and this evening I have been doing some research into how it all works... Looks great!
http://blog.anscamobile.com/2011/11/introducing-the-storyboard-api/
Its also made me that little bit more comfortable with my jukebox development ... Turns out the framework I came up with in my head for the juke is very similar to the storyboard api... maybe a little simpler but the same idea.
So anyway I can relate to this storyboard api quite easily.. But I need to get a better understanding of tables... I think its allot like objects in flash. This is what corona recommends for passing groups of data from one scene to the next.
Im also thinking about implementing a model as well, like in a MVC architecture. I think this would be one lua file full of global vars...? maybe? I dont like globals though... I was always advised to stay away from them in flash and always have done!
We will see...
I have some graphics that I've been working on this week. Time for some coding! ... It looks like a wet weekend so should get some done.
Im also going to do a quick blog post about screen set up for bother android/Idevice
Wednesday, 18 April 2012
Googly face scroll bar masking issue
Spent this evening trying to sort a bug out that occurs if your in edit mode of googly face. At this point if the app loses focus, for example you answer a phone call and you then go back to googly face you will find all the graphics are screwed up. At first, after a corona staff member looked at it we came to the conclusion that this was an issue with load from media method. I even checked this in as a bug .. but after a little more playing I have come to realise it has nothing to do with get media method. It is Infact something to do with a mask assigned to a group that contains the scroller for the menus. I'm still not completely convinced this isn't a bug, if it isn't then its an issue with the scroll http://developer.anscamobile.com/code/scroll-content
It might be that this code is now obsolete and as been replaced. Hopefully get chance to reseach this over the weekend and implement it.
I need to get it fixed as it's stopping me from getting googly face on the amazon market.
Tuesday, 27 March 2012
Googly face.. its for the kids.
..I really need to work on that... Its not a bad app really?? especially when its free!
But what was quit humbling and put a smile on my face (googly face) was when Nicola (my ball un chain) told me her niece who is 3years old asked out of the blue, to play on googly face... Nice that! And its nice to see the kids I have watched using it roll over laughing and argue about whos turns next..
So the download numbers or disappointing.. But for the ones I have seen with the app, makes me that little bit more proud of googly face.
https://play.google.com/store/apps/details?id=com.googleeyes
Tuesday, 20 March 2012
Googly face v1.5 - Tash pack
Every one seemed to love the moustache you could add in the previous version, so I have spent the week drawing up a few new ones. The "tashes" when in play mode animate in some way are form. Should keep the kids occupied for a bit.. and grown ups.
Ive also added a bit more polish to the modification screen. Items now animate onto the screen with a sound effect.
I've changed one of the hair items as well, looks better now
https://play.google.com/store/apps/details?id=com.googleeyes
Wednesday, 14 March 2012
Introducing googly face
Its an app that's aimed at parents that need to entertain there children for a while. It certainly seems to work. Most children I have shown it to seem to love it. In fact my girl friends brothers kids would not go to sleep until they made one last "googly face".
I was really excited to get it out on the market... maybe a little to excited. some of the graphics on release were a little ropey. Something I'm looking to rectify over the coming months. I don't like the hair types.. I could really to do with a proper illustrator to do some "hair" illustrations for me.
Googly face has taken me best part of 4-5 months to develop. I worked on it on evenings and weekends. But with distractions... Thats the problem when working at home at a table in a room that looks directly into the living room, theirs always something on the telly or a video game to distract you. So its actually kind of hard to say exactly how many hours I have put into it. I think its allot though.
Allot has been over coming issues with a new language. Googly face is built using the corona sdk. Corona uses a language called lua. In some respects its been easy as, as a flash developer I can easily relate to lua... But lua is not ummmm a particularly strict language.. is strict the right word? maybe.
Basically I'm used to working with instances of code blocks... classes. My brain is very much wired to work like that. Something I found hard to adjust to in lua.
But I can talk about that in another post some other time!
I've not really said what it does have I!
In brief googly face allows you to...
- select a photo from camera of gallery on a mobile device
- position and resize that image
- add various cartoon like parts to that image. That might be a pig nose, googly eyes, a tash ect.
- when a user presses the the play button these parts come to life. They animate, they play sound, they do stuff when pressed ect.
Thursday, 8 March 2012
Understand mobile advertising terms.
A full and up to date mobile advertising glossary for terms used across the industry | Adfonic:
'via Blog this'
Tuesday, 6 March 2012
LocalConnection example in Actionscript 3.0
'via Blog this'Publish Post
Wednesday, 8 February 2012
Tuesday, 7 February 2012
Friday, 27 January 2012
Object-Oriented Programming Concepts (The Java™ Tutorials > Learning the Java Language)
I dont use inheritance much in my programing. Only program specific classes like "movieclip" but not normally classes I have built myself. Really feel I should be. But never have reason to!
Lesson: Object-Oriented Programming Concepts (The Java™ Tutorials > Learning the Java Language):
'via Blog this'
Tuesday, 10 January 2012
And this
A new favorite: Stevie Nicks - Stand Back (Eli Escobar Discomix 'Young Edits Re-Mix of A Remix') by @LukeYouth http://t.co/uvXHGGjF -- AORDISCO (@AORDISCO)
Will check this later
A new favorite: This is It (Rayko edit) [low quality] by Rare Wiri Records http://t.co/ADsnyXmo on #SoundCloud -- AORDISCO (@AORDISCO)
Monday, 9 January 2012
Pinup
yesteryear pinup meet modern cheer leader pinup!
New years eve
Snap I took of York minister on New years eve
Just a few of my own thoughts on me and the industry I belong to...
Tuesday, 3 January 2012
New Album: phantogram
http://www.last.fm/music/Phantogram/Eyelid+Movies
Worth a listen.
Also bought Soulwax - Nite Versions....
http://www.last.fm/music/Soulwax/Nite%2520Versions?ac=soulwax
Just because I lost it and there my favourite band!