<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4451875241443579550</id><updated>2012-02-16T00:59:54.711-08:00</updated><category term='contextmenu'/><category term='how to'/><category term='Flash'/><category term='Context menu'/><category term='actionscript 3'/><category term='CS3'/><category term='preloader'/><category term='pre loader'/><category term='CS4'/><category term='tutorial'/><category term='AS3'/><title type='text'>My Geek Life</title><subtitle type='html'>And other random things</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dansgeeklife.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4451875241443579550/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://dansgeeklife.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dan</name><uri>http://www.blogger.com/profile/08333184657145740542</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/_OsYAjvQccsE/SueSV9g9akI/AAAAAAAAACI/VJ8oi1G4GEw/S220/jonny.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4451875241443579550.post-7975582301937545389</id><published>2009-10-28T18:35:00.000-07:00</published><updated>2009-10-29T11:32:39.741-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CS4'/><category scheme='http://www.blogger.com/atom/ns#' term='CS3'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='Context menu'/><category scheme='http://www.blogger.com/atom/ns#' term='how to'/><category scheme='http://www.blogger.com/atom/ns#' term='AS3'/><category scheme='http://www.blogger.com/atom/ns#' term='Flash'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript 3'/><category scheme='http://www.blogger.com/atom/ns#' term='contextmenu'/><title type='text'>Context Menu</title><content type='html'>So, i have viewed a lot of flash files over the last few years and noticed that a large amount of them don't bother with the context menu. A few just hide it completely, well, as much as flash allows you to anyway. This isn't bad but you could get a lot more out of it if you wanted to. You can add your own items to that menu and even get them to perform functions within the flash movie. When i first came across this i found it quite hard to understand but none the less i soldiered on with it until i got it. Since then i have used it in all of my projects for many different things but the main use is to link back to your websites if your flash movie isn't hosted there or if you host it on a few different sites.&lt;br /&gt;&lt;br /&gt;So to get started, open up an actionscript 3 file. Select the first frame and open up the actions panel(press F9).&lt;br /&gt;&lt;br /&gt;!!!Remember that all code is case sensitive and should be copied exactly else it may not work!!!&lt;br /&gt;&lt;br /&gt;Put this code in the panel:&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;var myMenu:ContextMenu = new ContextMenu();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;myMenu.hideBuiltInItems();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;var item1:ContextMenuItem = new ContextMenuItem("what you want to see goes in here");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;myMenu.customItems.push(item1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;item1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openLink);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;function openLink(event:ContextMenuEvent):void&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;    navigateToURL(new URLRequest("http://www.dansgeeklife.co.nr"));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;contextMenu = myMenu;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Explaining the code:&lt;br /&gt;&lt;br /&gt;var myMenu:ContextMenu = new ContextMenu();&lt;br /&gt;This is creating a new variable, naming it myMenu, telling flash what type of variable it is ContextMenu, and telling flash its a new ContextMenu.&lt;br /&gt;&lt;br /&gt;myMenu.hideBuiltInItems();&lt;br /&gt;This does what it says... It hides the standard built in items. You can hide them individually if you want to, just look on the adobe as3 help files to find all the options.&lt;br /&gt;&lt;br /&gt;var item1:ContextMenuItem = new ContextMenuItem("what you want to see goes in here");&lt;br /&gt;This creates a new context menu item, change the last bit to what you want to see like your website name, more games etc.&lt;br /&gt;&lt;br /&gt;myMenu.customItems.push(item1);&lt;br /&gt;This adds the newly created menu item into your custom menu. Without doing this the item would not show up.&lt;br /&gt;&lt;br /&gt;item1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openLink);&lt;br /&gt;This adds an event listener to the menu item so when you click it it performs your function.&lt;br /&gt;&lt;br /&gt;function openLink(event:ContextMenuEvent):void&lt;br /&gt;This creates the function to be run on clicking your new menu item. The event type is ContextMenuEvent telling flash to listen for that.&lt;br /&gt;&lt;br /&gt;navigateToURL(new URLRequest("http://www.dansgeeklife.co.nr"));&lt;br /&gt;This tells flash to look up an internet address, a new URL request is made directed to the website defined by you.&lt;br /&gt;&lt;br /&gt;contextMenu = myMenu;&lt;br /&gt;This tells flash that its context menu is to be replaced with your new context menu.&lt;br /&gt;&lt;br /&gt;Now test the file and right click. The menu should now show the item you defined and when clicked should take you to the website you defined.&lt;br /&gt;&lt;br /&gt;There are a few other options to look at too, like, you can add an item to the menu and stop it from being selectable. This is good for adding copyright information, your name and the date it was made for example. To do this just put the line:&lt;br /&gt;item1.enabled = false;&lt;br /&gt;After the line defining the item1 variable. Of coarse doing this would mean that the item cannot be clicked and therefore cannot run any function so doing this would be useless if you want to use it as a button for doing something within your flash movie. But you don't need to have the items run any function. you can just add them to the menu without them being used for anything.&lt;br /&gt;&lt;br /&gt;Also, to add more items to your menu you don't need to make more or the myMenu variables. Just copy out your item1 variable and change its name to item2, then copy out the customItems.push line and change that to item2 too so it would look like:&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;var myMenu:ContextMenu = new ContextMenu();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;myMenu.hideBuiltInItems();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;var item1:ContextMenuItem = new ContextMenuItem("what you want to see goes in here");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;var item2:ContextMenuItem = new ContextMenuItem("what you want to see goes in here");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;item2.enabled = false;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;myMenu.customItems.push(item1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;myMenu.customItems.push(item2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;item1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openLink);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;function openLink(event:ContextMenuEvent):void&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;    navigateToURL(new URLRequest("http://www.dansgeeklife.co.nr"));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;contextMenu = myMenu;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;That just about covers the basics of custom context menus, hope it helps!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4451875241443579550-7975582301937545389?l=dansgeeklife.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dansgeeklife.blogspot.com/feeds/7975582301937545389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dansgeeklife.blogspot.com/2009/10/so-i-have-viewed-lot-of-flash-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4451875241443579550/posts/default/7975582301937545389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4451875241443579550/posts/default/7975582301937545389'/><link rel='alternate' type='text/html' href='http://dansgeeklife.blogspot.com/2009/10/so-i-have-viewed-lot-of-flash-files.html' title='Context Menu'/><author><name>Dan</name><uri>http://www.blogger.com/profile/08333184657145740542</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/_OsYAjvQccsE/SueSV9g9akI/AAAAAAAAACI/VJ8oi1G4GEw/S220/jonny.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4451875241443579550.post-3624058904824165560</id><published>2009-10-28T08:37:00.001-07:00</published><updated>2009-10-28T13:57:40.839-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CS4'/><category scheme='http://www.blogger.com/atom/ns#' term='CS3'/><category scheme='http://www.blogger.com/atom/ns#' term='preloader'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='how to'/><category scheme='http://www.blogger.com/atom/ns#' term='AS3'/><category scheme='http://www.blogger.com/atom/ns#' term='Flash'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript 3'/><category scheme='http://www.blogger.com/atom/ns#' term='pre loader'/><title type='text'>Preloaders...</title><content type='html'>Making a Flash file for your website can add some interactivity such as games or animations. The problem is, a large file or people with slow connections will have to wait for the file to load before it can be viewed. Without a preloader this would just look like a blank screen, and could look like the page or content isn't loading. This is bad for your page making it less user friendly and less likely to be visited again.&lt;br /&gt;&lt;br /&gt;So we need a preloader to show that the file is loading and keep people viewing your website. This can be as simple or complex as you like, though simple ones are the easiest and don't add too mush to your file size.&lt;br /&gt;&lt;br /&gt;To begin, open up a new Flash File(actionscript 3) and create 2 or 3 blank keyframes on the first layer.&lt;br /&gt;&lt;br /&gt;In the new frames add some large picture files from your computer, anything big will do. This is to increase the size of your file so when you test it, it has some size to it to show you that it works properly. Don't put anything on the first frame, this is where the preloader is going to sit and you don't want anything in the way on this frame.&lt;br /&gt;&lt;br /&gt;In the first frame, draw a rectangle and make it 400 pixels wide and 15 pixels high with an outline and center it to the stage (ctrl+alt+2, ctrl+alt+5). The colour doesn't matter so long as it is different to the stage background so it can be seen. Select the inner(not the outline) rectangle and convert it to a movie clip(select it and press F8). In the options box that opens up: name the clip anything you want, select movieclip from the selection box( or list in CS3), make sure the registration point is in the top left hand box(the block of 9 squares to the right of the name box, the square that is blacked out is the selected one) and press OK.&lt;br /&gt;&lt;br /&gt;In the properties inspector where it says &lt;instance&gt;&lt;instance&gt;&lt;span style="font-style: italic; font-weight: bold; color: rgb(204, 204, 204);"&gt;Instance Name&lt;/span&gt;, type in loadBar. Now select the first frame in the timeline and open the actions panel(press F9). in the box that opens up, type:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;!!!All code should be typed EXACTLY as it is seen, the capitals are important and the code will only work with them in the right place!!!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(anything green is code, that's what needs to be typed, anything else is just my explination of the code and should be left out of the actions panel)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;stop();&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;This tells flash to stop on this frame, so it doesn't play through to your pictures which will cause problems.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;function loader(preLoader:ProgressEvent):void&lt;br /&gt;{&lt;br /&gt; var percent:Number = Math.floor((preLoader.bytesLoaded*100)/preLoader.bytesTotal);&lt;br /&gt;&lt;br /&gt; if(percent &lt;=99)         &lt;br /&gt;{                   &lt;br /&gt;loadBar.width = percent*4;         &lt;br /&gt;}         &lt;br /&gt;else if(percent == 100)         &lt;br /&gt;{                  &lt;br /&gt;loadBar.width = 400;                   &lt;br /&gt;loaderInfo.removeEventListener(ProgressEvent.PROGRESS, loader);         &lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;loaderInfo.addEventListener(ProgressEvent.PROGRESS, loader);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Thats all the code needed to get it to work, now i will explain it a bit in case you don't quite understand it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;function&lt;/span&gt;: this tells flash that it should do something&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;loader&lt;/span&gt;: this is just the name i used to identify our function, this can be set to anything you like so long as it isn't a predefined keyword used by flash, like function, stage and class are.&lt;br /&gt;&lt;br /&gt;&lt;/instance&gt;&lt;span style="font-weight: bold;"&gt;(preLoader:ProgressEvent)&lt;/span&gt;: This is the event type, for example if walk was a human function it would be the event type (event:MovementEvent)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;:void&lt;/span&gt; : This tells flash that the function will be returning nothing so it doesn't expect it to&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;var percent:Number = Math.floor((preloader.bytesLoaded*100) /preloader.bytesTotal);&lt;/span&gt; : This is the most important part of the code... the maths.&lt;br /&gt;&lt;br /&gt;var is telling flash that this is a variable, percent is just the name, same rules apply here as naming functions,&lt;br /&gt;&lt;br /&gt;Number is the variable type.&lt;br /&gt;&lt;br /&gt;Math.floor tells flash that the calculation inside its () part needs to be rounded down, this is important to make the number 0-100 not a 2.787469484 or anything like that as that would mess up our loading bar.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;((preloader.bytesLoaded*100) /preloader.bytesTotal); &lt;/span&gt;This is the calculation, the current amount of the flash file that has loaded times  100 divided by the total size of the flash file to make a 0-100 number.&lt;br /&gt;&lt;br /&gt;I think the if statements are pretty self explanatory.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;loaderInfo.addEventListener(ProgressEvent.PROGRESS, loader);&lt;/span&gt; This tells flash to listen for the loading event and do the function loader when it hears the event.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;loaderInfo.removeEventListener(ProgressEvent.PROGRESS, loader);&lt;/span&gt; This tells flash to stop listening for the event, this has to be done or flash will produce errors when it no longer has anything to listen for.&lt;br /&gt;&lt;br /&gt;I think that just about covers the simple preloader in flash. There are ways of making more impressive looking preloaders but this is functional and works so what else would you need?&lt;br /&gt;&lt;br /&gt;To see some of my preloaders in action just play one of my games from the link at the bottom of the blog page.&lt;br /&gt;&lt;br /&gt;Thanks for reading and i hope this helps you!&lt;/instance&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4451875241443579550-3624058904824165560?l=dansgeeklife.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dansgeeklife.blogspot.com/feeds/3624058904824165560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dansgeeklife.blogspot.com/2009/10/preloaders.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4451875241443579550/posts/default/3624058904824165560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4451875241443579550/posts/default/3624058904824165560'/><link rel='alternate' type='text/html' href='http://dansgeeklife.blogspot.com/2009/10/preloaders.html' title='Preloaders...'/><author><name>Dan</name><uri>http://www.blogger.com/profile/08333184657145740542</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/_OsYAjvQccsE/SueSV9g9akI/AAAAAAAAACI/VJ8oi1G4GEw/S220/jonny.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4451875241443579550.post-7324340533861009956</id><published>2009-10-27T08:23:00.000-07:00</published><updated>2009-10-28T23:52:04.910-07:00</updated><title type='text'>Introduction</title><content type='html'>So, this is a blog about my life as a geek.&lt;br /&gt;&lt;br /&gt;About me, well...&lt;br /&gt;&lt;br /&gt;My name is Dan, i'm 22 and i'm a geek!&lt;br /&gt;&lt;br /&gt;A few months ago i started learning ActionScript3 (AS3), a programming language used in Flash. I'm not a fast learner but i am learning to do some cool stuff, mainly game related as i feel it's a fun way to learn and should keep my interest for more than an hour.&lt;br /&gt;&lt;br /&gt;I also play guitar and drums, not like a pro but i can knock out a few chords and keep in time most of the time too. I have been in a few bands and played a few gigs but nothing too serious, it's more about having fun than anything else... and we sucked!&lt;br /&gt;&lt;br /&gt;That just about sums me up.&lt;br /&gt;&lt;br /&gt;About this blog...&lt;br /&gt;&lt;br /&gt;I am writing this blog as a chronicle of my AS3 progress. Where i get stuck and what i accomplish over the next however long it takes me and such. Not to say i wont post anything else, but mostly my AS3 stuff will be here for all to view and hopefully learn from if you are also learning AS3 and find this in looking for the answer.&lt;br /&gt;&lt;br /&gt;So far i have made a few silly little games that aren't very good but it's a start, eh?&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.kongregate.com/accounts/cantor"&gt;You can see and play those here &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I think thats enough for now anyway.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4451875241443579550-7324340533861009956?l=dansgeeklife.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dansgeeklife.blogspot.com/feeds/7324340533861009956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dansgeeklife.blogspot.com/2009/10/introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4451875241443579550/posts/default/7324340533861009956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4451875241443579550/posts/default/7324340533861009956'/><link rel='alternate' type='text/html' href='http://dansgeeklife.blogspot.com/2009/10/introduction.html' title='Introduction'/><author><name>Dan</name><uri>http://www.blogger.com/profile/08333184657145740542</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/_OsYAjvQccsE/SueSV9g9akI/AAAAAAAAACI/VJ8oi1G4GEw/S220/jonny.jpg'/></author><thr:total>0</thr:total></entry></feed>
