Welcome to Farid's tutorials,a simple blog that i use to document some nice code pattern that i find useful for my reference in future projects and also to share links that are useful. I do lots of C#/ ASP.NET, MSSQL, bit of R, Python, Arduino, RaspPI, bit of linux and IOS and Android development on a professional/ personal basis. Hope this blog is useful for you as how i find it useful for me.
Friday, May 25, 2007
Div appear on top of Flash
Here is the Offical Adobe Tech note Link
But whats the Code? well its just adding new parameter to the flash embed code.
Add the following parameter to the OBJECT tag:
<param name="wmode" value="transparent">
Add the following parameter to the EMBED tag:
wmode="transparent"
Saturday, May 19, 2007
Loading XML into Flash
1) Create the XML file (mine uses just the child attributes) - (save it as settings.xml) so here it is...
<settings>
<setting rtmpserver="rtmp:/app1" playserver="http://visual/play" />
</settings>
2) in Flash Quite simply this is the code
var myXml:XML = new XML();
myXml.ignoreWhite = true;
myXml.load("settings.xml");
myXml.onLoad = function(success) {
if (success) {
rtmpSvr = this.firstChild.childNodes[0].attributes.rtmpserver
playSvr = this.firstChild.childNodes[0].attributes.playserver
trace(rtmpSvr + " - " + playSvr)
}
}
and thats it...
Sunday, April 29, 2007
Using Flash Component: TREE
If you have used MS Outlook you might be familiar with how it looks like, Below is the flash movie that we wil be creating:-
Link to the completed Tree
Steps to create the above:
1) Drag a tree component to stage and name the instance: "myTree"
2) create a dynamice text box and name the instance: "status_txt"
3) create a new layer and call it 'action' and well type the code below:-
//Tree
//create XML object
var myTreeDP:XML = new XML();
myTreeDP.ignoreWhite = true;
myTreeDP.load("data.xml");
//when XML is loaded send data to TREE
myTreeDP.onLoad = function() {
myTree.dataProvider = this.firstChild;
};
//create listener for tree,w hen click do the following
var treeListener:Object = new Object();
treeListener.change = function(evt:Object) {
selNode = evt.target.selectedNode
selNoteData = selNode.attributes.label
selNoteMessage = selNode.attributes.comment
if (selNoteMessage == undefined) {
selNoteMessage = ""
}
status_txt.text = selNoteData + " - " + selNoteMessage
};
//assign listener to tree.
myTree.addEventListener("change", treeListener);
4) Next you need the data file as the tree takes data from XML (it can take from the actionscript, but my example takes from XML) so launch Notepad and paste the following:-
i tried pasting my XML code here, DAMM blogger, makes the code hidden.. weird. anyways i wont leave you hanging, so here is a link to the data.xml file
5) save the xml file as data.xml in the same directory as your flash, save your flash, publish and preview and you get your tree.
what else to try?
i think the real trick about tree is how to apply it, im cracking my head thinging about this, how to use it for my work'place e-learning portal, seem like a good idea to make a simple 'internal' email application, but i suppose i need more time to figure this out. any suggestion.. do comment.
Sunday, March 25, 2007
Using Flash Components (Flash mx2004 - Flash 8)
- Add a 'combobox' component and call the instance 'vid_ccb'
- Add a 'label' call it 'selVid_txt'
- Add a 'List' call it 'vList'
- Add 'label' call it 'selVidLs_txt'
- Add a number stepper, call it 'nStep'
- Add 'label' call it 'nstep_txt'
- add a 'window' call it 'vWin'

Next, create 2 smily faces (size it to 10x10 pixel) as the list uses icons, so u need to make 2 MC of smily faces, and ensure under linkage properties, its like this. Note i have 2 smily faces for first one the linkage identifier is 'icon_sm1' and second one is 'icon_sm2'

Next is the Codes. Copy and paste the actionscript to a new layer. code is simple, easy for your to figure out..(btw, im actually trying to make a video player with a playlist, work in progress)
//combo box setup
_root.vid_ccb.addItem("video 1", 1);
_root.vid_ccb.addItem("video 2", 2);
vid_ccb.dataProvider = [{label:"video 1", data:1}, {label:"video 2", data:2}, {label:"video 3", data:3}];
var oListener:Object = new Object();
oListener.change = function(oEvent:Object):Void {
if (oEvent.target._name == "vid_ccb") {
selectVidItem = vid_ccb.selectedItem.label;
_root.selVid_txt.text = selectVidItem;
}
if (oEvent.target._name == "vList") {
selectLsItem = vList.selectedItem.label;
_root.selVidLs_txt.text = selectLsItem ;
vWin.visible = true
vWin.title = selectLsItem
}
if (oEvent.target._name == "nStep") {
nstep_txt.text = nStep.value
}
};
oListener.click = function(oEvent:Object):Void {
if (oEvent.target._name == "vWin") {
oEvent.target.visible = false
}
}
_root.vid_ccb.addEventListener("change", oListener);
_root.selVid_txt.autoSize = true;
vList.dataProvider = [{label:"video 1", data:1, icon: "icon_sm1"},
{label:"video 2", data:2, icon: "icon_sm2"},
{label:"video 3", data:3, icon: "icon_sm2"},
{label:"video 4", data:4, icon: "icon_sm1"},
{label:"video 5", data:5, icon: "icon_sm1"},
{label:"video 6", data:6, icon: "icon_sm2"},
{label:"video 7", data:7, icon: "icon_sm1"}
];
vList.addEventListener("change", oListener);
vList.iconField ="icon";
vList.multipleSelection = true; //to allow multiple selection via ctrl btn
_root.nStep.minimum = 0
_root.nStep.maximum = 100
_root.nStep.stepSize = 10
nStep.addEventListener("change", oListener);
vWin.visible = false
vWin.closeButton = true
vWin.addEventListener("click", oListener);
Friday, October 06, 2006
Playing back external FLV files dynamically
As an alternative to importing video into the Flash authoring environment, you can use ActionScript to dynamically play back external FLV files in Flash Player. You can play back FLV files from an HTTP address or from the local file system. To play back FLV files, you use the NetConnection and NetStream classes and the
attachVideo()
method of the Video class. (For more information, see "NetConnection class", "NetStream class", and Video.attachVideo()
in Flash ActionScript Language Reference.) You can create FLV files by importing video into the Flash authoring tool and exporting it as an FLV file. (See "Macromedia Flash Video (FLV)" in Using Flash.) If you have Flash Professional, you can use the FLV Export plug-in to export FLV files from supported video-editing applications. (See "Exporting FLV files from video-editing applications (Flash Professional only)" in Using Flash.)
Using external FLV files provides certain capabilities that are not available when you use imported video:
- Longer video clips can be used in your Flash documents without slowing down playback. External FLV files are played using cached memory. This means that large files are stored in small pieces and accessed dynamically, which does not require as much memory as embedded video files.
- An external FLV file can have a different frame rate than the Flash document in which it plays. For example, you can set the Flash document frame rate to 30 fps and the video frame rate to 21 fps. This gives you greater control in ensuring smooth video playback.
- With external FLV files, Flash document playback does not have to be interrupted while the video file is loading. Imported video files can sometimes interrupt document playback to perform certain functions (for example, accessing a CD-ROM drive). FLV files can perform functions independently of the Flash document, which does not interrupt playback.
- Captioning of video content is easier with external FLV files because you can use event handlers to access metadata for the video.
Tip: To load FLV files from a web server, you might need to register the file extension and MIME type with your web server; check your web server documentation. The MIME type for FLV files is video/x-flv.
The following procedure shows how to play back a file named videoFile.flv that is stored in the same location as your SWF file.
To play back an external FLV file in a Flash document:
- With the document open in the Flash authoring tool, in the Library panel (Window > Library) select New Video from the Library options menu to create a video object.
- Drag a video object from the Library panel onto the Stage; this creates a video object instance.
- With the video object selected on the Stage, in the Property inspector (Window > Properties) enter
my_video
in the Instance Name text box. - Open the Components panel (Window > Development Panels > Components), and drag a TextArea component to the Stage.
- With the TextArea object selected on the Stage, enter
status
in the Instance Name text box in the Property inspector. - Select Frame 1 in the Timeline, and open the Actions panel (Window > Development Panels > Actions).
- Add the following code to the Actions panel:
// Create a NetConnection object
var netConn:NetConnection = new NetConnection();
// Create a local streaming connection
netConn.connect(null);
// Create a NetStream object and define an onStatus() function
var netStream:NetStream = new NetStream(netConn);
netStream.onStatus = function(infoObject) {
status_txt.text += "Status (NetStream)" + newline;
status_txt.text += "Level: "+infoObject.level + newline;
status_txt.text += "Code: "+infoObject.code + newline;
};
// Attach the NetStream video feed to the Video object
my_video.attachVideo(netStream);
// Set the buffer time
netStream.setBufferTime(5);
// Begin playing the FLV file
netStream.play("videoFile.flv");