Archive » August, 2006 «
Thursday, August 31st, 2006 | Author: dehash
A small example of embedding fonts in a textfield:
Actionscript:
-
package {
-
-
import flash.display.Sprite;
-
import flash.text.TextField;
-
import flash.text.TextFormat;
-
import flash.text.TextFieldAutoSize;
-
-
public class EmbedFontsExample extends Sprite {
-
-
[Embed(source="wingding.ttf", fontFamily="wingdingFont")]
-
private var MyFont:Class;
-
-
public function EmbedFontsExample() {
-
-
var tf:TextFormat = new TextFormat();
-
tf.font = "wingdingFont";
-
tf.size = 32;
-
-
var txt:TextField = new TextField();
-
txt.selectable = false;
-
txt.backgroundColor = 0xEEEEEE;
-
txt.embedFonts = true;
-
txt.autoSize = TextFieldAutoSize.LEFT;
-
txt.defaultTextFormat = tf;
-
txt.text = "Embed Fonts \nExample";
-
txt.x=50;
-
txt.y=50;
-
-
addChild(txt);
-
}
-
}
-
}
Category: Flash | Leave a Comment
Friday, August 25th, 2006 | Author: dehash
nameafterproject.xml is an ant build file that automates a few changes I was making each time to the Bit-101 FlashDevelop AS3 Project template. After running it with Ant (immediately after making a new AS3 Project) my project name, main class, & target swf all have the same base name which saves me some typing as I prefer it that way. It needs working on a little but it does the job fine for now. I have put it in \FlashDevelop\Data\ProjectTemplates\05 AS3 Project\nameafterproject.xml and to run it add this line in ToolBar.xml
XML:
-
<button label="ANT name after project" click="PluginCommand" image="54"
-
tag="Run;SaveAll;ant -buildfile nameafterproject.xml -Dproject.name=@PROJECTNAME"
-
shortcut="ShiftF11" />
// nameafterproject.xml
XML:
-
<?xml version="1.0"?>
-
<project name="set up project" default="nameafterproject" basedir="./">
-
<!-- include Bit-101 build.properties file -->
-
<property file="build.properties"/>
-
<target name="nameafterproject">
-
<!-- ensure project.name has a value-->
-
<fail unless="project.name" message="No project.name supplied"/>
-
<!-- check ${project.name}.as does not exist (don't want to overwrite by mistake)-->
-
<available file="${basedir}/${source.dir}/${project.name}.as"
-
property="project.name.as.file.present"/>
-
<fail if="project.name.as.file.present" message="${project.name}.as already exists"/>
-
<!-- copy App.as to ${project.name}.as -->
-
<copy file="${basedir}/${source.dir}/App.as"
-
tofile="${basedir}/${source.dir}/${project.name}.as"/>
-
<!-- change App to ${project.name} inside ${project.name}.as -->
-
<replaceregexp file="${basedir}/${source.dir}/${project.name}.as"
-
match="App" replace="${project.name}" byline="true"/>
-
<!-- change source.file & output.file values in build.properties -->
-
<replaceregexp file="${basedir}/build.properties"
-
match="^source.file=App.as$" replace="source.file=${project.name}.as"
-
byline="true"/>
-
<replaceregexp file="${basedir}/build.properties"
-
match="^output.file=App.swf$" replace="output.file=${project.name}.swf"
-
byline="true"/>
-
</target>
-
</project>
Category: Flash | Leave a Comment
Tuesday, August 22nd, 2006 | Author: dehash
Displaying code was being a bit of a pain and I thought I would have to devote a lot of time to making some cool and complex system to make pasting code here easy. But I just got the iG:Syntax Hiliter which I found out about here and after five minutes it is working very well and I am very happy with that. Seems a good solution :)
Category: Flash | Leave a Comment
Sunday, August 20th, 2006 | Author: dehash
In addition to the instructions here I have added an entry to ToolBar.xml so that I can display the swf in the standalone Flash player. It calls ant on the build.xml file with the target "launchstandalone" :
XML:
-
<button label="StandAlone" click="PluginCommand" image="54" tag="Run;SaveAll;ant launchstandalone" shortcut="F11" />
Also added xtrace.as to \ProjectTemplates\05 AS3 Project\src\ and it can be used without import in all projects
Also xtrace can take an array as an argument for example:
Actionscript:
-
xtrace([var1, var2]);
-
// which outputs the same as
-
xtrace(var1 + ", " + var2);
Category: Flash | 2 Comments
Thursday, August 17th, 2006 | Author: dehash
SVG file drawn using Inkscape and embedded in swf at compile time. The box at bottom left had a radial gradient fill in the svg that does not appear in the swf.
SVGEmbed.as code below compiled using FlashDevelop and a Bit-101 template
Actionscript:
-
package {
-
import flash.display.Sprite;
-
public class SVGEmbed extends Sprite {
-
[Embed(source="../assets/plainsvg1.svg")]
-
private var SimpleSVG:Class;
-
-
public function SVGEmbed() {
-
init();
-
}
-
private function init():void {
-
var mySVG:Sprite = new SimpleSVG();
-
mySVG.scaleX=0.5;
-
mySVG.scaleY=0.5;
-
addChild(mySVG);
-
}
-
}
-
}
Category: Code Examples, Flash, Flex SVG | 2 Comments
Monday, August 14th, 2006 | Author: dehash
Using the Penner easing equations directly:
more...
Category: Flash | Leave a Comment
Thursday, August 10th, 2006 | Author: dehash
BIT-101 has written a great tutorial showing howto setup FlashDevelop for AS3 work.
Works right out of the box and will probably become my editor of choice. Plus some nice code templates too.
Category: Flash | 2 Comments