简体   繁体   English

Flash HTML图片链接AS3

[英]Flash HTML image link AS3

I have a flash as3 file, and I'm importing an HTML file that contains this link: 我有一个Flash as3文件,并且正在导入一个包含以下链接的HTML文件:

<a href="purchase.php?lang=0&"><img src="https://www.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" id="paypal_button"></a>

and I cannot for the life of me figure it out, I've looked everywhere. 我无法一生解决这个问题,我无所不在。

There were a couple of forums that suggested: 有几个论坛建议:

function onTicketLoad():void {
if(paypal != null && this.contains(paypal)) {
    removeChild(paypal);
}
var imgLoader:DisplayObject = content_text.getImageReference("paypal_button");
//imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onHtmlImageLoaded);
paypal.addChild(imgLoader.content);
}

function onHtmlImageLoaded(e:Event):void {
    e.target.removeEventListener(Event.COMPLETE, onHtmlImageLoaded);

    paypal.addChild(e.target.content);
    paypal.buttonMode = true;
    paypal.useHandCursor = true;
    addChild(paypal);
}

(that example is fragmented as all hell, I just included it to illustrate what I'm trying to do) (该示例是零散的,我只是将其包括在内以说明我正在尝试做的事情)

Basically I think I need to load the image into the getImageReference method... but I'm so lost... any help would be appreciated! 基本上我认为我需要将图像加载到getImageReference方法中...但是我很迷路...任何帮助将不胜感激!

I've found creating links on <img> tags in TextFields in Flash can be problematic. 我发现在Flash的TextField中的<img>标签上创建链接可能会出现问题。

I spotted the issue has been reported on the adobe bug tracker here: 我发现此问题已在Adobe Bug Tracker上报告:

http://bugs.adobe.com/jira/browse/FP-2146 http://bugs.adobe.com/jira/browse/FP-2146

Once as a workaround I created a separate swf file the exact same size as the image and embedded that instead (ie a 160x47 stage and a MovieClip/button with a clickable link using navigateToURL). 作为一种解决方法,我创建了一个与图像大小完全相同的单独的swf文件,并嵌入了该文件(例如,一个160x47的舞台和一个带有NavigationToURL可单击链接的MovieClip /按钮)。 Basically you can embed swf files within TextFields the same way as images. 基本上,您可以将SWF文件嵌入到TextField中,方法与图像相同。

It's not ideal but it did seem like a decent compromise considering the swf 'button' can now be used and laid out in more or less the same way as you would have used the <img> tag. 这并不理想,但是考虑到现在可以使用swf“按钮”并以与使用<img>标签相同的方式进行布局,这似乎是一个不错的妥协。

AIR (Mobile) ignores IMG tags for security apparently... useless in my opinion. AIR(Mobile)显然忽略了IMG标签的安全性……我认为这毫无用处。 Adding the fact the TextFlow is not recommend or supported for that either in Mobile, and many other fruit less attempts to get an IMG tag to render is beyond challenging so far. 无论是在Mobile中还是不建议或不支持TextFlow的事实,到目前为止,要获得IMG标签进行渲染的许多其他尝试都比较困难。 I'll wager nearly impossible with the given components (in AIR Mobile land of course, which is not well documented and conflictive with online sources around the issues, so it is unclear and confusing being fresh out of beta). 我将使用给定的组件进行几乎不可能的赌注(当然,在AIR Mobile领域中,该文件没有得到很好的记录,并且与有关该问题的在线资源相矛盾,因此尚不清楚,并且不清楚是否刚刚通过Beta测试)。

If you are going to use the < img > tag in an htmlText box, " you must set the text field to be multiline and to wrap text " 如果要在htmlText框中使用<img>标记,则“ 必须将文本字段设置为多行并包装文本

I tried it, and it works fine for me. 我尝试了一下,对我来说很好用。 It loaded the image and the link worked too. 它加载了图像,链接也起作用。 Here is my code: 这是我的代码:

import flash.text.TextField;

var labelText:String = '<a href="purchase.php?lang=0&"><img src="https://www.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" id="paypal_button"></a>';
var label:TextField = new TextField();
label.border = true;
label.multiline = true;
label.wordWrap = true;
label.width = 200;
label.height = 100;
addChild(label);
label.htmlText = labelText;

My example uses pure AS3, but it should be exactly the same as selecting "multiline" and "wordwrap" from your textfields properties panel. 我的示例使用的是纯AS3,但应与从文本字段属性面板中选择“多行”和“自动换行”完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM