Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionScript custom tags enhancement #41

Open
garata opened this issue Nov 9, 2013 · 0 comments
Open

ActionScript custom tags enhancement #41

garata opened this issue Nov 9, 2013 · 0 comments

Comments

@garata
Copy link

garata commented Nov 9, 2013

Hi all, I'm opening this issue because I'd like a new feature is implemented into FlashJS, allowing developer to add actionscript bootstrapping in script tag sections. How I imagine the script element is illustrated below.

<script id="actionscript1" type="text/actionscript" data-width="200px" data-height="200px"  data-scaletoscreen="false">
<!-- FlashJS ActionScript code goes here without any worries about xml escaped characters -->
</script>

Please note that I've nothing against the actionscript custom HTML tag, but I feel that these application specific tags find their appropriate usage in web design realm and when you need them to support your web application logic. In most browsers your custom tags will be treated as inline elements like span, this means you have to write CSS to declare rules such as "actionscript { display: none }" at least to prevent unwanted content display when JS is disabled or you page is not processed as expected.

Thus, the ActionScript Tag Executor would be easily adapted for the new pseudo script tag as follow.

var $push = Array.prototype.push;
var tags0 = document.getElementsByTagName('actionscript');
var tags1 = document.getElementsByTagName('script');
var tags  = [];
$push.apply(tags, tags0);
$push.apply(tags, tags1);

for (var i = 0; i < tags.length; i++) {
    var astag = tags[i];

    if (astag.tagName === 'SCRIPT' && 'text/actionscript' !== (astag.type || ''))
        continue;

    var scriptText = replaceAll(astag.innerHTML, "&lt;", '<');
    scriptText = replaceAll(scriptText, "&gt;", '>');
    var width = astag.getAttribute('data-width') || astag.getAttribute('width');
    var height = astag.getAttribute('data-height') || astag.getAttribute('height');
    var scaleToScreen = astag.getAttribute('data-scaleToScreen') || astag.getAttribute('scaleToScreen');
    var canvas = w.document.createElement('canvas');
    canvas.setAttribute('width', width);
    canvas.setAttribute('height', height);
    canvas.id = 'flashjs' + UID();

    // replace existing node astag with the new span element canvas
    //astag.parentNode.appendChild(canvas);
    //astag.parentNode.removeChild(astag);
    astag.parentNode.replaceChild(canvas, astag);

    var stage = new Stage('#' + canvas.id, parseInt(width), parseInt(height));
    //...
    //...
}

I think what is most enticing about this diverse approach is that you don’t have to vary too much the existing code base in order to begin using it.

Best regards, Giorgio Arata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant