Hok's Macromedia Flash Blog

macromedia flash actionscript scripting, php, remoting, webservices, c#, javascript

AS2: user-class-mc and attachMovie - nice trick...

...for calling the init-method automagicly(implicit) under usage of the init-object.



I found this trick in the german flashforum where Florian Krüsch, a great and creative developer, postet this trick.

The idea is very simple:

  • We attach a movie, and using the init-object param of attachMovie.

  • Within we define an initParams-field.

  • The magic is, that now implicitly a setter is called for the initParams-field.

  • This setter just call our init.

This idea is so cool, thank you Mister Krüsch...;-)
class ExtendedMc extends MovieClip
{
   public function ExtendedMc()
   {

   }

   private function init(a,b,c:String):Void
   {
      trace([a,b,c]);
   }

   public function set initParams(initValArr:Array):Void {
      init.apply(this,initValArr);
   }
}
// FLA:
_root.attachMovie("ExtendedMc", "m", 100, {initParams:["Horst","Peter","Gustav"]});

Posted by hOk at January 27, 2004 09:55 AM

Windows XP Home - Shared Folders

My computer works with Windows XP Home. Until now i was totally satisfied with this system. The problem i came through is that if i want to share an folder in our home-network the folder is accessible to any pc in the network.
So i added ntfs-file-permission for only one user. But what happens is following: nobody, inclusive the added user, can't access the folder. Why does this happen? After hours of searching the google and especially the google-groups i came to the reason.
Every lan-access to an XP-Home-PC will tanslated as guest-request by the system implicitly. So the access to the ntfs protected folder have to fail and will fail.
Next time i will buy the professional edition...;-)

Posted by hOk at January 18, 2004 03:06 AM

Good news for MoveableType-Users

...bad news for spammers. MoveableType released a new version
2.661. With this version the <$MTCommentAuthorLink$> will be
resolved by redirecting. So spammers have not the possibility to
push there google-page-rank this way.
But the spammers could still post their links into the comment-body.

Posted by hOk at January 17, 2004 02:29 PM

Question: Highlighting Code

Did anybody know a php-script which highlights code?
Maybe something with linenumbers?
regards, Holger

Posted by hOk at January 9, 2004 03:22 PM

Apache: modrewrite

Oh yes, if you maybe have seen i am currently rebuilding this site.
While doing that i saw, that the blog-archives-directory is outside of
the blog-folder, so i changed the moveable-type settings so that
now the archives-folder is inside the blog-folder.
But now many Links in the web would fail, so we need a redirect.



I solved this problem with two files in the old and deprecated directory.
The first is a .htaccess file which turn the server-side-rewriting of
request on, and rewrites the request to the second file.
The second file simply sends the new location by a header-command
to the client, so maybe google or other clients recognize that the url
is deprecated and store the new one.

Click the following link to see the redirecting in action:
http://www.flashfanatiker.de/archives/000037.html

.htaccess
# Turn the RewriteEngine on
RewriteEngine On

# Rewrite only if we are not accessing
# our redirection-php-file
RewriteCond %{REQUEST_URI} !^.*rewriter.php$

# match all and attach it as path-get-variable
RewriteRule ^.+$ rewriter.php?path=$0

rewriter.php
if ($_GET['path'] == 'files/treeTraceGlobal.htm' ||
$_GET['path'] == 'files/treeTrace.as')
header('Location: http://www.flashfanatiker.de/blog/'. $_GET['path']);
else
header('Location: http://www.flashfanatiker.de/blog/archives/'. $_GET['path']);

Posted by hOk at January 8, 2004 02:03 PM

PHP - Dynamic Request Resolving

download example
view example

If we work with php or any other server-side-language, we mostly
communicate with client through get- or post-requests. While i was
searching on the php.net-site i found an interesting idea there and build a class based on that.

The Idea is to dynamicly resolve request-variables to method-calls. This is easy to realize because we have in php also the possibility to call an method dynamicly. Therefore exists in php the function call_user_func.

It would be not so secure to resolve a request-variable to any function in the current script. So I decided that an extra request-class is needed in which we allowed to resolve and execute any method. Like a sandbox.

Example-Usage: <?php

// Include the request-resolve
// class
require_once 'Request.php';

// the class which handles
// our requests
class RequestResolver
{
   // declare a receiver-method
   function sayHello ($param)
   {
      echo 'Hello '. $param .'<br />';
   }

   // declare another receiver-method
   function sayGoodbye ($param)
   {
      echo 'Goodbye '. $param .'<br />';
   }

   // declare another receiver-method
   function divideBy2 ($param)
   {
      echo $param / 2;
   }
}

?>

<html>
<head><title>Request.php</title></head>
<body>

<h4>Result:</h4>

<?php

// start resolving requests,
// with our RequestResolver-class
// as context
Request::resolve(new RequestResolver);

?>


<h4>Test get-requests</h4>

<a href="<?php basename(__FILE__) ?>?sayHello=world">sayHello(world)</a><br />
<a href="<?php basename(__FILE__) ?>?sayGoodbye=world">sayGoodbye(world)</a><br />


<h4>Test post-request</h4>

<form action="<?php basename(__FILE__) ?>" method="post">
<label>divideBy2:</label>
<input type="text" name="divideBy2" /><br />
<input type="submit" />
</form>


</body>
</html>

Posted by hOk at January 3, 2004 01:27 PM

New Place