swiffy输入文本框的解决方法 [英] swiffy input textfield workaround

查看:141
本文介绍了swiffy输入文本框的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是小白来这个论坛,一个小白的JavaScript,但我知道AS3的公平份额。

I'm a noob to this forum and a noob to javascript, but I know a fair share of as3.

所以swiffy不支持输入文本字段。我认为,一个解决方法是将调用从swiffy对象的JavaScript函数(我可以用callExternalInterface做),这将载入一个HTML输入文本字段到iframe或以上我swiffy对象的高z索引层一个div ,准确定位,所以它看起来像它的swiffy对象的一部分,但遗憾的是我的JavaScript知识还处于初级阶段。

So swiffy doesn't support input text-fields. I thought that a workaround would be to call a javascript function from the swiffy object (which I can do using callExternalInterface) which would load an HTML input text-field into an iFrame or a div on a higher z-index layer above my swiffy object, positioned exactly so it looks like it's all part of the swiffy object, but sadly my javascript knowledge is in its infancy.

我已经打算吧,做研究,尝试不同的东西,五,六个小时,现在,一切我尝试不工作。我加载它定义的文本字段外部HTML文件,到目前为止,我已经得到的东西来加载,但它的所有古怪,虽然它现在显示在正确的位置上,这是打破网站的布局,并显示在一个小盒子里,告诉我,我需要一个插件来做到这一点。

I've been going at it, doing research, trying different things, for five or six hours now and everything I try doesnt work. I'm loading an external HTML file which defines the text-field, and so far I have gotten something to load, but it's all weird, and while it now shows up at the right position, it 'breaks' the layout of the site, and shows up in a little box that tells me I need a plug-in to do that.

这就是我现在所拥有的,它的可怜,甚至没有在所有的工作。(load_email是JavaScript函数我可是从我的Flash文件调用)

This is what I have right now, and it's pathetic and doesn't even work at all.. (load_email is the javascript function Im calling from my flash file)

function load_email(){
document.getElementById("swiffycontainer").innerHTML='<object type="type/html" id="email.html" </object>'
placeDiv();
console.info("email0");
}



function placeDiv(x_pos, y_pos) {
  var d = document.getElementById('email.html');
  console.info("boo");
  d.style.position = "relative";
  d.style.left = 292+'px';
  d.style.top = 380+'px';
  d.style.zIndex =2000;
  console.info("boo2");
}

可怜,是吧。

Pathetic, isn't it.

请帮忙?

回答我的问题:

原来这一切都是非常简单的比我做出来的人。

Turns out this is all much simpler than I was making it out to be.

我在巴基斯坦的朋友帮我出过的Skype,这是如何让输入文本框到通过JavaScript你swiffy,从那里应该可以凑齐某种邮件器:

My friend in Pakistan helped me out over Skype, this is how to get input textfields into your swiffy via javascript, from there it should be possible to cobble together some kind of emailer:

您无需加载任何外部HTML文件,只需删除该部分。然后,更改load_email功能是这样的:

You don't need to load any external html file, just delete that part. Then change the load_email function to something like this:

function load_email() {
    var inputFieldName = document.createElement("input");
        inputFieldName.type="text";
        inputFieldName.style.position = "absolute";
        inputFieldName.style.left = "292px";
        inputFieldName.style.top = "370px";
        inputFieldName.style.zIndex = 2000;
        swiffycontainer.appendChild(inputFieldName);
}

巴姆。好去。

Bam. Good to go.

推荐答案

感谢名单你anwser并使用code你贴我在ActionScript 2做了另一个工作演示了一个flash文件,互换swiffy和JavaScript之间的数据(输入和输出)。

Thanx to your anwser and using the code you posted I made another working demo for a flash file in actionscript 2, to interchange data between swiffy and javascript (in and out).

下面是具体步骤:

1)关键是要值与该行发送到swiffy对象的的javascript

1) The key is to send the value to the swiffy object with this line in javascript:

功能sendValue(){               myvalue的= inputFieldName.value;               stage.setFlashVars('myMessageFromTextfield ='+ myvalue的);           }

function sendValue() { myValue=inputFieldName.value; stage.setFlashVars('myMessageFromTextfield='+myValue); }

2)然后,在FLA文件中,在 ACTIONSCRIPT2 ,得到的值:

2) Then, inside the fla file, in actionscript2, get the value:

的getValue =功能(){       如果(_level0.myMessageFromTextfield ==未定义|| _level0.myMessageFromTextfield == undefined)的{           this.cat.animCat.myText.text =;       } 其他 {           this.cat.animCat.myText.text = _level0.myMessageFromTextfield;           returnButton._visible = TRUE;       }   }

getValue = function() { if(_level0.myMessageFromTextfield == "undefined" || _level0.myMessageFromTextfield == undefined) { this.cat.animCat.myText.text = ""; } else { this.cat.animCat.myText.text = _level0.myMessageFromTextfield; returnButton._visible = true; } }

3)我们需要不断地监视,当TE数据apears所以使用的setInterval:

3) We need to constantly monitor when te data apears so use a setInterval:

myInterval = setInterval的(这一点,的getValue,100);

myInterval = setInterval(this, "getValue", 100);

4)现在,将值发送回HTML文件中,我们使用的getURL与数据连接:

4) Now, to send the value back to html file, we use getURL with the data attached:

returnButton.onRelease =功能(){       的getURL(JavaScript的:showMessage('+ _ level0.myMessageFromTextfield +说:猫'););   }

returnButton.onRelease = function() { getURL("Javascript:showMessage('"+_level0.myMessageFromTextfield+" says the cat');"); }

5)最后,又在的javascript 在HTML里我们执行带有参数的功能:

5) And finally, again in javascript inside the html we execute the function with the parameter:

功能showMessage(消息){               警报(消息);           }

function showMessage(message) { alert(message); }

它完美的IE浏览器,火狐,Chrome,Safari浏览器(IOS)。

It works perfectly in IE, Firefox, Chrome, safari (ios).

所以,现在我们可以在ipad或iphone发送文字。

So now we can send text in ipad or iphone.

我附加的源文件中的一个链接:

I attached the source files in the next link:

<一个href="https://onedrive.live.com/redir?resid=E64343A7ADE7D670!1401&authkey=!AO86aUEdyZRqQN4&ithint=file%2czip" rel="nofollow">https://onedrive.live.com/redir?resid=E64343A7ADE7D670!1401&authkey=!AO86aUEdyZRqQN4&ithint=file%2czip

这篇关于swiffy输入文本框的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆