myXML.load("update.xml?" + Math.random());
Tuesday, September 29, 2009
Cache Problem with IE
this problem is mostly found with IE, while we update the XML file, the flash file still remains the same , due to cache, thus to solve this problem we can use math.random method, and it really works, i tried this a million times.
Wednesday, September 23, 2009
Add Style Sheet to Dynamic Text
sample css for dynamic text
.bodyCopy
{
font-family: Arial;
font-size: 12px;
color: #666666;
line-height: 28px;
}
{
font-family: Arial;
font-size: 12px;
color: #666666;
line-height: 28px;
}
ActionScript
var format = new TextField.StyleSheet();
var path = "main_styles.css";
format.load(path);
format.onLoad = function(success) {
if (success) {
output.styleSheet = format;
var path = "main_styles.css";
format.load(path);
format.onLoad = function(success) {
if (success) {
output.styleSheet = format;
} else{
trace("style sheet not loaded")
}
}
Wednesday, September 16, 2009
Flash ActionScript 2.0 Dynamic Vertical Menu
we all know about XML and its uses over Internet. Now a days, requirements comes mostly for dynamically created flash , i mean to say xml embeded flash file. As for now I am going to show how to create such files. In my example I would show how to create menu item dynamically, embeding XML with flash. So lets start....
-
-
-
-
-
1) First we need to create a XML file maintaining this following formate, you can know more about XML from this link http://www.w3schools.com/xml/default.asp . My XML file should look like this.
2) Open Flash proffesional 8 or upperversion, create a new file, save the file with the XML file you got.
3) Create a rectangel , width:120, and height:20, and then convert it into movieclip and name it as "menuitem"
4) Double click on this particular movieclip and create a new layer, go to the first frame of the new layer and then create a dynamic text field and give it an instance name "name"
5) Come over to the stage and press CTLR + L or you can go to windows>library. you can find the movieclip named menuitem there, right click over the movieclip, chose properties, there yon find Linkage option.
Check for Export for Actionscript, the name for Identifier and Export for first frame will get filled, dont change them, keep it as it is. Press ok and then come to the stage. you can find the menuitem movieclip, remove it from the stage.
6) Select the frist frame and press F9, the action panel will open up. From here on we continue with the actionscript 2.0. Generates a list of menu items , given the inputted parameters. This makes the main menu.
Loading and Interpreting XML
xmlNode = xmlObject.firstChild;
for (var i = 0; i <>
xmlNode.childNodes[i].nodeName;
xmlNode.childNodes[i].attributes.name;
xmlNode.childNodes[i].attributes.action;
xmlNode.childNodes[i].attributes.variables;
}
Get XML
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok){
if (ok){
Createmainmenu(10, 10, 0, this);
}
};
menu_xml.load("myXMLfile.xml");
Generating Menu
if (node_xml.childNodes[i].nodeName == "menu"){
curr_item.node_xml = curr_node;
curr_item.onRollOver = curr_item.onDragOver = function(){
var x = this._x + this._width - 5;
var y = this._y + 5;
GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.node_xml);
};
}else{
curr_item.arrow._visible = false;
curr_item.onRollOver = curr_item.onDragOver = function(){
curr_menu.submenu_mc.removeMovieClip();
};
}
Action
Actions = Object();
Actions.gotoURL = function(urlVar){
getURL(urlVar, "_self");
};
At the End the Script will look like this
GenerateMenu = function(container, name, x, y, depth, node_xml) {
var curr_node;
var curr_item;
var curr_menu = container.createEmptyMovieClip(name, depth);
for (var i=0; i<4;>
curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
curr_item._x = x;
curr_item._y = y + i*curr_item._height;
curr_item.trackAsMenu = true;
curr_node = node_xml.childNodes[i];
curr_item.action = curr_node.attributes.action;
curr_item.variables = curr_node.attributes.variables;
curr_item.name.text = curr_node.attributes.name;
curr_item.onRollOut = curr_item.onDragOut = function(){
var col = new Color(this.background);
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
};
curr_item.onRelease = function(){
Actions[this.action](this.variables);
CloseSubmenus();
};
}
};
Createmainmenu = function(x, y, depth, menu_xml){
GenerateMenu(this, "mainmenu_mc", x, y, depth, menu_xml.firstChild);
mainmenu_mc.onMouseUp = function(){
if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){
CloseSubmenus();
}
};
};
CloseSubmenus = function(){
mainmenu_mc.submenu_mc.removeMovieClip();
};
Actions = Object();
Actions.gotoURL = function(urlVar){
getURL(urlVar, "_self");
};
Actions.newMenu = function(menuxml){
myXMLfile_xml.load(menuxml);
};
myXMLfile_xml = new XML();
myXMLfile_xml.ignoreWhite = true;
myXMLfile_xml.onLoad = function(ok){
if (ok){
Createmainmenu(10, 10, 0, this);
trace( "message area");
}else{
trace("error: XML not successfully loaded");
}
};
myXMLfile_xml.load("myXMLfile.xml");
Flash ActionScript setInterval
Many a times we feel the need to set time intervel between frams so this is an example of it. Lets get started.
1) first we take a variable displayTime and that will be = to the duration
var displayTime = 5;
in here 5 is for 5 seconds hold, if you want then you can increase or decrease the time as you want.
2) Its time for us to create the function
so the name of the function is countDown
var displayTime = 5;
countDown=function(){
}
3) Next is to verify weather the function get loaded sucessfully and display the message after 5 sec.
var displayTime = 5;
countDown=function(message){
}
4) we create a loop function now so that the function starts countion reverse as for ex 5sec, 4sec, 3sec, 2sec, 1sec, and finally go
var displayTime = 5;
countDown=function(message){
displayTime--;
}
5) how would the function know weather it has finished counting or not , thus its time for condition.
var displayTime = 5;
countDown = function(message)
{
displayTime--;
if (displayTime == 0){
}
}
6) finallly you need to stop the loop function or else it would continue the loop function and you get confused, we use clearInterval to end the timer.
var displayTime = 5;
countDown = function(message)
{
displayTime--;
if (displayTime == 0){
clearInterval(timer);
trace("this action you need to paste here")
}
}
timer = setInterval(countDown, 1000);
the whole script would look like this
var displayTime = 5;
countDown = function(message)
{
displayTime--;
if (displayTime == 0){
clearInterval(timer);
trace("this action you need to paste here")
}
}
timer = setInterval(countDown, 1000);
Saturday, September 5, 2009
Web 2.0 Format layout
Wednesday, August 12, 2009
Thursday, July 9, 2009
My Character Design
Graphics
- There is a total of 14 character
- 7 avatar images of the military units (100x100 pixels, only upper body) to be used during the formation phase and in the “Army Composer”
- 7 in-game graphics (full body) of all these military units as they are represented on the battlefield (maybe roughly 40x60 pixels)
- Each of the 7 in-game graphic must have 3 associated animations
- Normal movement from field to field
- Attack motion (e.g. shooting an arrow, attacking with a sword etc.)
- Defense motion
- The in-game graphics should be flat-shaded vector graphics with little emphasis on their organic shape. In this way the units are easily identifiable on the battlefield.
- The avatar images should be more sophisticated vector or pixel graphics
- ALL graphics mentioned should not look playful or funny, but rather grim and ferocious.
- In addition, the military units should cast faint shadows onto the fields they are placed within in order provide a little bit more 3D illusion. It is enough to make short contact shadows at the unit’s
bottom side. No need to make a full length shadow of the entire unit’s body!
Character Name: Rifleman
Weapon: Musket

Character Name: Swordsman
Weapon: Sword

Character Name: Pikeman
Weapon: Pike

Character Name: Vomitting Troll
Weapon: ####

Character Name: Giant
Weapon: ####

Character Name: Rhino Rider
Weapon: Lance

Character Name: Goblin Jumpa
Weapon: Sword; Jumping

Character Name: Orc Warrior
Weapon: Sword

Character Name: Suicide Goblin
Weapon: Suicide Attack

Character Name: Goblin
Weapon: Pike

Character Name: Mortar
War Machine

Character Name: Organ Gun
War Machine

Character Name: Great Canon
War Machine

Character Name: Heavy Cavalry
Weapon: Lance
Subscribe to:
Posts (Atom)
