Flash Link for HTML AS3 Image

I have a flash as3 file and I am importing an HTML file containing this link:

<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, so that life understands me, I looked everywhere.

There were several 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);

      

}

(this example is fragmented as hell, I just included it to illustrate what I am trying to do)

Basically, I feel like I need to load an image into the getImageReference method ... but I'm so lost ... any help would be appreciated!

0


a source to share


3 answers


If you are going to use <img> in the htmlText field, " you must set the textbox to multiline and wrap the text "

I tried it and it works great for me. He uploaded 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" in the textbox properties panel.

+1


a source


I found that referencing tags <img>

in TextFields in Flash can be problematic.

I noticed that the problem was found here in the adobe bug tracker:

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



Once, as a workaround, I created a separate swf file the same size as the image and embedded it (i.e. a 160x47 step and a MovieClip / button clickable with navigateToURL). Basically, you can embed swf files in TextFields just like images.

It's not ideal, but it seemed like a worthy compromise, given that swf 'button' can now be used and laid out more or less the same way you used a tag <img>

.

+2


a source


AIR (Mobile) ignores IMG tags for security, seemingly ... useless in my opinion. Adding the fact that TextFlow is not recommended or supported for it in any Mobile, and there are many other attempts to get less IMG tag to show, is beyond question. I would put the almost impossible with these components (of course, in the AIR Mobile environment, which is poorly documented and contradicts the online sources around the problems, so it is incomprehensible and confusing that they are fresh from the beta version).

+1


a source







All Articles