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.

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!!!

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-

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.