To embed the fonts for a dynamic text field in Flash select the text field and open the properties panel. In the properties panel you will be able to see a button called "Embed", click on that and it will ask you what all you want to embed such as Uppercase letters, Lowercase letters or Numerics.
Select the appropriate and press Ok and you are done.
Thursday, June 25, 2009
Monday, May 25, 2009
JSON to Flash: YouTube Case Study
I had to implement a custom YouTube gadget in Flash. The term gadget does not refer to a specific gadget technology, such as Google Gadgets. YouTube Gadget refers only to small web applications, implemented in HTML or Flash, that are displayed within an iFrame on a YouTube brand channel.
And for that purpose I had to fetch the list of videos published by a particular YouTube user which can only be fetched in the form of JSON, RSS or Atom Feed. I decided to go with JSON, initially it was difficult for me to fetch the appropriate values I needed because the JSON returned by YouTube is quite complex in structured but finally I was able to sort it out.
JSON stands for JavaScript Object Notation and is mainly used to transmit such structured data over a network connection.
Example:
http://gdata.youtube.com/feeds/api/videos?max-results=5&alt=json&orderby=published&author=designworxz
If you change the last parameter in the URL which is "author=designworxz" to "author=your youtube username" it will fetch list of videos published by you in the form of JSON.
The great community over at http://json.org have created a JSON parsing library for AS1, AS2 & AS3. But we will focus on Flash CS3 & AS2.0. You can find that parse class here: http://json.org/JSON.as
Below is the code to parse the JSON returned by YouTube -
The variable "s" will display the complete JSON returned by YouTube in the Output window & then the only thing you have to do is to fetch the required String, Variables & Values from the returned JSON.
Good Luck!!
And for that purpose I had to fetch the list of videos published by a particular YouTube user which can only be fetched in the form of JSON, RSS or Atom Feed. I decided to go with JSON, initially it was difficult for me to fetch the appropriate values I needed because the JSON returned by YouTube is quite complex in structured but finally I was able to sort it out.
JSON stands for JavaScript Object Notation and is mainly used to transmit such structured data over a network connection.
Example:
{
"firstName": "Atul",
"lastName": "Narang"
}
In my case the JSON has to be parsed from the following URL -http://gdata.youtube.com/feeds/api/videos?max-results=5&alt=json&orderby=published&author=designworxz
If you change the last parameter in the URL which is "author=designworxz" to "author=your youtube username" it will fetch list of videos published by you in the form of JSON.
The great community over at http://json.org have created a JSON parsing library for AS1, AS2 & AS3. But we will focus on Flash CS3 & AS2.0. You can find that parse class here: http://json.org/JSON.as
Below is the code to parse the JSON returned by YouTube -
import JSON;
var jsondata:LoadVars = new LoadVars();
jsondata.onLoad = function(success) {
if (success) {
trace("load successful");
var o:Object = json.parse(unescape(this.toString()));
var s:String = json.stringify(o);
trace(s);
} else {
trace("unable to load JSON data");
}
};
jsondata.load("http://gdata.youtube.com/feeds/api/videos?max-results=5&alt=json&orderby=published&author=designworxz");
The variable "s" will display the complete JSON returned by YouTube in the Output window & then the only thing you have to do is to fetch the required String, Variables & Values from the returned JSON.
Good Luck!!
Monday, March 16, 2009
Flash CS3 UI Scrollbar
Guys, if you attach the UI Scrollbar component with Dynamic textbox in Flash where the text will be populated from XML or a Text file, the scrollbar won't work and resize automatically.
When I was working on one of my flash component where the data was being populated from XML, I assumed that the scrollbar will automatically adjust according to the amount of the data but nothing really happened.
So to make the scrollbar work after you have populated your dynamic textbox with the content you can type the following action to make the UIScrollbar work -
mc_scroll.maxScrollPosition = details.textHeight;
"mc_scroll" is the instance name of my scrollbar attached with the dynamic textbox & "details" is the name of my dynamic text box.
When I was working on one of my flash component where the data was being populated from XML, I assumed that the scrollbar will automatically adjust according to the amount of the data but nothing really happened.
So to make the scrollbar work after you have populated your dynamic textbox with the content you can type the following action to make the UIScrollbar work -
mc_scroll.maxScrollPosition = details.textHeight;
"mc_scroll" is the instance name of my scrollbar attached with the dynamic textbox & "details" is the name of my dynamic text box.
Friday, March 13, 2009
Playing multiple videos Dynamically
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
Create a connection object
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
Create a NetStream object and pass the NetConnection object
var stream_ns:NetStream = new NetStream(connection_nc);
stream_ns.client = new Object();
One connection object can be used for more than one video stream.
myVideo.attachNetStream(stream_ns);
stream_ns.play("video.flv");
myVideo is the name of my video object placed on the stage & video.flv is the video file which needs to be played. Now if you want to play another video you have to create a new NetStream object for each video otherwise it will not work. I spent 4 hours just to figure this out & kept trying different techniques to make my 4 different videos work with the same NetStream object. But unfortunately it is not possible.
So guys the trick is to create different NetStream object for each video & have fun.
Happy Streaming!!!
import flash.net.NetConnection;
import flash.net.NetStream;
Create a connection object
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
Create a NetStream object and pass the NetConnection object
var stream_ns:NetStream = new NetStream(connection_nc);
stream_ns.client = new Object();
One connection object can be used for more than one video stream.
myVideo.attachNetStream(stream_ns);
stream_ns.play("video.flv");
myVideo is the name of my video object placed on the stage & video.flv is the video file which needs to be played. Now if you want to play another video you have to create a new NetStream object for each video otherwise it will not work. I spent 4 hours just to figure this out & kept trying different techniques to make my 4 different videos work with the same NetStream object. But unfortunately it is not possible.
So guys the trick is to create different NetStream object for each video & have fun.
Happy Streaming!!!
Wednesday, March 11, 2009
Flash XML parsing including HTML tags in the XML
If you want to parse the HTML tags within your XML, the XML document should look like below -

And in the Flash scripting if you have a Dynamic Textbox named dynTxt the code will be as follows -
dynTxt.htmlText = Variable holding your text data
Following are the tags supported by Flash while parsing XML-

And in the Flash scripting if you have a Dynamic Textbox named dynTxt the code will be as follows -
dynTxt.htmlText = Variable holding your text data
Following are the tags supported by Flash while parsing XML-
Mask on Dynamic Textbox
I encountered a strange problem in Flash when I tried masking a dynamic text box and it didn't work. After doing lots of research on the internet I found out that if you mask a dynamic text box the text won't appear.
So to save time for the people trying to mask the dynamic text box here is the tip, click your text box in the properties panel click the Embed button and embed the fonts and your text will start appearing again.
So to save time for the people trying to mask the dynamic text box here is the tip, click your text box in the properties panel click the Embed button and embed the fonts and your text will start appearing again.
Thursday, February 26, 2009
Online Rugby Game
I have recently finished an online Rugby Game which can be accessed at - www.303.com.au/projects/rugby/rugby.html
Hope you like it!
Hope you like it!
Subscribe to:
Posts (Atom)
