Create a png with php and as3

For a project I was on awhile ago, I needed to decorate a character with different items of clothing. When the user was done ‘dressing’ their character, they would press a button and the whole character would shrink down so it would fit as an ornament on a tree. In order to not confuse the issue, I am going to only show the code that enables you to take a movieclip and create a png from it. In order to do this, you will need to include the Flex SDK as a part of your flash build (for the Base64Encoder class) and you need to download as3corelib. To include the Flex SDK, in your Flash preferences add this line: (Mac OSX)

//VERSION will prob be 3.5, 4 etc...
/Applications/Adobe Flash Builder 4/sdks/flex_sdk_VERSION/frameworks/projects/framework/src

Code after the jump…

  CreatePNG (44.4 KiB, 14 hits)

Read the rest of this entry »

,

No Comments

Cast XMLNode to Boolean – AS3

I was having a bit of difficulty making an xml node that had a value of true/false be cast properly as a Boolean. Turns out a good method is to when you are setting it, test it against a string value of true. The boolean will only be set to true if the string in your XML file is “true”.

1
2
//Example
var myBoolean:Boolean = XML.isTrueFalse == "true";

2 Comments

Synergy – Work Across Computers

A good friend of mine showed me this program and with a bit of help, we were able to get it running. This is going from my home computer (dell tower) to my work laptop (macbook pro). It is very handy to be able to (using my home computer), mouse over to my macbook pro, work on something, mouse back over to my tower, and continue etc. You can also copy/paste text between the computers which is pretty sweet when copying snippets of code. (I currently use DropBox to share files). I won’t do an exhaustive tutorial on how to set up synergy, as the ‘Using Synergy’ link on the sourceforge site is pretty good, but wanted to offer a few tricks to get it working:

With my setup at home, my mac book pro is to the right of my tower. To get started, choose a computer you will use as the ‘server’. (The one that will control all the computers connected in this method; in my case my dell tower):

  1. Set up your computers by entering both in the Screens box (use your actual computer names)
  2. For the client computer (in my case the mac) in the alias screen you should type ComputerName.local (this is not needed for your server computer)
  3. Setup your links. Mine read:
  4. MacName is right of DellTower (and the corresponding rules…)
  5. DellTower is left of MacName

The mac (using it as the client):

  1. All you need to do is open terminal and enter a command like this:
    /Users/username/Desktop/synergy-1.3.1/synergyc -f 192.168.blah.blah

I had to use the IP address of my dell as the computer name was not working.

I think it makes it easier having the Windows computer as the host because you have a GUI to configure it and don’t need to fuss with the config file on the mac. Hope this helps someone!

,

3 Comments

Force Windows 7 to use Flash Player 10

I was developing a Flex app and for the life of me I could not get it to use Flash Player 10 when it would compile. I downloaded the Flash Player 10 Projector content debugger and ran it. Nothing. I tried all sorts of editing flex config files, compiler arguments etc to no avail. Turns out you need to run the content debugger as ‘administrator’. (Right click ‘Run as Administrator). This fixed it up, no need to edit config files or add compiler arguments to my project. Hope this saves someone some headache as I had forgotten about this ‘feature’ on Windows 7.

, ,

No Comments

Avoid Twitter API-IP Call Limit

Twitter limits the amount of calls you can make to its API and from one IP to a few hundred an hour. So that means if you have something on the page that is showing your latest tweets, it will only work for the first few hundred people. We have a really high traffic site and needed a more robust solution.

What we did is create a php file that loads the XML from the twitter user timeline (example) and saves it on our server. We setup a chron job to call it every minute. The Flash movie loads the XML file that our php file creates for us ensuring that we will never go over the limit but always have the most up to date content from Twitter displayed on our website.

If you have any questions or want an example of the source, post in the comments. Running Example.

Resources Used:

  • The LoadXML and LoadURL files from here.
  • The AxisScroller from here.
  • Tweenlite
  • , , ,

    No Comments

    Convert links in text to clickable links in Flash AS3

    I found this on StackOverflow but it took quite a bit of searching to find. Here you go:

    1
    
    title_str = title_str.replace(/((https?|ftp|telnet|file):((\/\/)|(\\\\))+[\w\d:#@%\/;$()~_?\+-=\\\.&]*)/g, "<u><a href='$1'>$1</a></u>");

    ,

    No Comments

    Dynamically Add UIScrollbar to Textfield AS3

    This is building off my previous post and adding a scrollbar to the textfield if there are too may tweets to fit in it. You don’t need to load data from a HTTPService but this is helpful for loading data when you don’t know its length ahead of time.

    Read the rest of this entry »

    , , ,

    No Comments

    Drop Down Menu with AS3

    Here is a code snippet that I have been using to create dropdown menus from movieclips in actionscript 3. I probably should try to wrap this up in a class as I bust out this snippet whenever I need this functionality. Usually when I have a ‘button’ that I need to have open up a larger movieclip with selectable/dynamic information in it. Would be nice to set a moviclip to be the ‘menu trigger’ (in the example: _sMouseOver) and another to be ‘the target’ (in the example: _sMenu) in a class… Maybe I will work on a class implementation later.

      AS3 Mouse Over Menu (15.4 KiB, 163 hits)

    Code Snippet after the jump: Read the rest of this entry »

    ,

    No Comments

    Make Money on the Internet

    My younger brother has been finding various ways of making money on the internet over the past four years. He has tried forums, blogs, and product review sites. He knows a lot about SEO, web analytics, and what works/doesn’t online. He has achieved what many people desire to do and that is to quit his day job and work from home. I am so very proud of him and would encourage you to check out his website at make money on the internet. I value transparency and openness and so does my brother. He posts his earnings reports, goals, and case studies of what he has tried.

    , ,

    1 Comment

    AS3 – Snow Effect

    The best snow script that I have seen thus far. You get great performance even with 1500 different snowflakes in the movie and practically everything is customizable. I will definitely be using this in projects that require a snow affect.

    What you can customize:

  • side the snow blows in from
  • number of flakes
  • size of flakes
  • distance from camera (range)
  • snow alpha
  • wind force
  • time between wind force changes
  • gravity (b/c who doesnt want 0 gravity snow)
  • Check it out: Tim Soret – Snow

    , ,

    1 Comment

    Switch to our mobile site