开发者

Minecraft Skin Preview Problem

According to another question, you can view your skin with this code:

<applet code="net.minecraft.skintest.ModelPreviewApplet"
        archive="http://www.minecraft.net/skin/skintest.jar" codebase="."
        width="320" height="320">
    <param name="name" value="535" />
</applet>

Which works!

But does anyone knows how i can make a textbox and a button which puts the written text in the value="535" t开发者_JS百科ag (replaces "535" with the text box input)?

Link to the other question: Is there a web-embeddable skin preview application?


You can write your applet into the DOM at run-time like this:

<div id="wrapper"></div>
<input type="text" value="" onchange="writeApp(this.value)">
<input type="button" value="go">

<script type="text/javascript">
function writeApp(pVal) {
     document.getElementById('wrapper').innerHTML = '<applet  code="net.minecraft.skintest.ModelPreviewApplet"  archive="http://www.minecraft.net/skin/skintest.jar" codebase="."  width="320" height="320"><param name="name" value="'+pVal+'" /></applet>'   
}   
</script>

Strangely enough, the applet doen't seem to like values other than "525"


That should be easy, but I don't think it will do what you want it to do.

I'm assuming you want to have a preview window with the texture preview, and allow users to type in new texture IDs, push the button, and see the preview right away.

Simply changing the value of the param after the page has loaded won't accomplish that.

When the button gets pushed, you'll need to remove the applet and re-create it, with the new param value in order for the changes to take effect.

Here's the code you asked for:

<applet
        code="net.minecraft.skintest.ModelPreviewApplet"
        archive="http://www.minecraft.net/skin/skintest.jar" codebase="."
        width="320"
        height="320">
    <param name="name" id="previewName" value="535" />
</applet>

<input type="text" id="newValue" />

<script>
document.getElementById('newValue').onblur = function(event) {
    // grab value
    var iVal = parseInt(this.value);
    if(!iVal && iVal !== 0) return;

    // update param
    document.getElementById('previewName').value = iVal;
    return true;
};
</script>

If you try that and it doesn't accomplish what you wanted, let me know and I can write the code that will do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜