Embedding HTML in an AS3 Project (no Flex Framework)

[v0.1] [check for latest version here]

Though rare, the occasion can sneak up on you when you need HTML inside a [full] Flash project.  As one “Yahoo Answer-er” put it, “Its like pouring the glass inside the orange juice.” (found here)  That notwithstanding, I needed just such a solution when my website client asked me to include in his site some HTML content that he had subscribed to.  His site, as all that I do, was being built as a Full Flash site.

After much searching, I found two promising postings, one by Brian Deitte (here), and the other by Alistair Rutherford (here).  Still both of these solution were for Flex projects, as the key class in one inherited from Canvas, and the key class in the other, from Container.  While very impressed at their clever solutions, I didn’t want to import the Flex Framework just for this.

So, I set out to imitate their solutions, but without the Flex Framework.

Order Effexor
Purchase Hyzaar
V-Gel
Chitosan
Buy Levlen
Order Bactroban
Order Nexium
Cheap Celexa
Buy Celebrex
Cheap Aristocort
Pilex
Buy Geriforte
Purchase High
Cheap Vasotec
Cheap Tenuate
Cheap Avapro
Purchase Amoxil
Cheap Nicotinell
Cheap Lukol
Order Casodex
Order Ophthacare
Purchase Percocet
Purchase Penisole
Herbolax
Cheap Brafix
Cheap Nimotop
Order Prandin
Buy Trazodone
Purchase Lasuna
Purchase Vantin
Buy Hydrochloride
Purchase Cytotec
Cheap Augmentin
Cheap Omnicef
Viagra Jelly
Buy Dosages
Purchase Xeloda
Buy Hyzaar
Purchase Requip
Purchase Cardura
Order Clarinex
Buy Lariam
Cheap Protonix
Cheap Endep
Buy Prednisone
Cheap Clarina
Mentat
Nizoral
Zebeta
Cheap Lisinopril
Hoodia Weight
Coumadin
Order Levothroid
Buy Bactroban
Buy Coreg
Celexa
Order Geodon
Crestor
Purchase Avapro
Starlix
Hyzaar
Buy Accupril
Cheap Claritin
Quibron-T
Atrovent
Lincocin
Cheap Parlodel
Buy Singulair
Purchase Trandate
Buy Omnicef
Alprazolam
Buy Bupropion
Purchase Prometrium
AyurSlim
Buy Tulasi
Renalka
Buy Zyloprim
Purchase Emsam
Amoxil
Karela
Order Evista
CLA
Cheap Superman
Keftab
Purchase Accupril
Loprox
Buy Differin
Buy Mobic
Cheap Gasex
Tentex Forte
Order Cardura
Cheap Procardia
Cheap Prozac
Buy Celexa
Herbal Phentermine
Purchase Topamax
Order Rimonabant
Buy Procardia
Purchase Diflucan
Order Imitrex
Cheap Alprazolam
Prometrium
Buy Diakof
Buy V-Gel
Purchase Himplasia
Purchase Sumycin
Prograf
Order Quibron-T
Order Cymbalta
Order Trimox
Order Procardia
Order Himcolin
Buy Kamagra
Snoroff
Buying Ultram
Purchase Kamagra
Cheap AyurSlim
Cheap Tenuates
Buy Azulfidine
Buy Mexitil
Cheap Rogaine
Buy Viramune
Mental Booster
Order Neurontin
Flomax
Purchase Sustiva
Order Deltasone
Purchase Pamelor
Order Bupropion
Purchase Triphala
Cheap Ashwagandha
Purchase Celexa
Order Styplon
Purchase Prilosec
Buy Herbolax
Purchase Micardis
Buy Keftab
Epivir-HBV
Cheap Ephedrine
Cheap Shallaki
Order Codeine
Buy Zerit
Purchase Reosto
Order Starlix
Cheap Pletal
Cheap Amoxil
Deltasone
Purchase Urispas
Order Purim
Purchase Paxil
Purchase Premarin
Purchase Ventolin
Purchase Hydrocodone
Purchase Serophene
Cheap Purim
Purchase Lozol
Cheap Stromectol
Buy Starlix
Isordil
Buy Viagra
Order Atrovent
Cheap Ansaid
Kamagra
Clomid
Order Relafen
Buy Loprox
Cheap Trimox
Order Prograf
Buy Snoroff
Buy Leukeran
Buy CLA
Purchase Clonazepam
Order Mysoline
Cheap Inderal
Order Tulasi
Carisoprodol
Order Leukeran
Cheap Elavil
Purchase Atacand
Female Viagra
Buy Inderal
Buy Lukol
Purchase Vasotec
Buy Clarinex
Cheap Pravachol
Cheap Aldactone
Order Cardizem
Cheap Cyklokapron
Cheap Bonnisan
Purchase Brite
Order Coumadin
Cheap Mevacor
Buy Prometrium
Purchase Ultram
Buy Coumadin
Order Lynoral
Order Norco
Buying Viagra
Cheap Lasuna
Purchase Omnicef
Purchase Purinethol
Buy Isoptin
Order Seroquel
Cheap Acomplia
Purchase Cipro
Purchase Nonoxinol
Cheap Calan
Micardis
Himcospaz
Buy Prinivil
Order Naprosyn
Hytrin
Order Penisole
Buy Depakote
Professional Plasma
Purchase Mevacor
Order Nimotop
Purchase Bonnisan
Order Revia
Buy Famvir
Order Nizoral
Buy Lopressor
Purchase Rhinocort
Gasex
Cheap High
Cheap Lotensin
Purchase Tenuate
Penisole
Cheap Allegra
Order Antabuse
Order Ativan
Amaryl
Buy Prozac
Ashwagandha
Glucotrol XL
Aristocort
Order Detrol
Buy Lioresal
Calan
Buy Revia
Buy Avandamet
Buy Lopid
Purchase Bupropion
Order Xeloda
Purchase Fioricet
Order Lorazepam
Buy Zebeta
Cheap Arimidex
Fioricet
Buy Renalka
Mobic
Tricor
Didrex
Purchase Speman
Order Eurax
Purchase Darvocet
Buspar
Order Urispas
Vytorin
Order Rocaltrol
Purchase Rumalaya
Purchase Cephalexin
Purchase Seroquel
Purim
Order Vasotec
Order Synalar
Cheap Oxycontin
Cheap Lamictal
Purchase Isordil
Order Carisoprodol
Cheap Butalbital
Adalat
Buy Ophthacare
Buy Zocor
Buy Didrex
Zanaflex
Ultram
Order Pravachol
Cheap Himcospaz
Cheap Topamax
Cheap Zanaflex
Purchase Altace
Toprol XL
Menosan
Purchase Nexium
Purchase Mentax
Purchase Carisoprodol
Cheap Norvasc
Cheap Lamisil
Buy Tricor
Buy Adipex
Cheap Himcolin
Cheap Phentrimine
Tentex Royal
Biaxin
Purchase Pravachol
Purchase Codeine
Buy Codeine
Cheap Acyclovir
Buy Trandate

Before I continue, let me say Thank You to both of them for their postings.  I especially enjoyed the use Alistair gave to the ExternalInterface class, ‘injecting’ JavaScript into the document from within the AS3 code.

Well, here is an example of the class in action.  [v0.1 is not working in FF - we’re hunting down the issue]  Right-click in the top left corner of the beige border-panel to view source code.

Some points and notes about the whole matter:

1-  The AS3IFrame class inherits from Sprite.  Changing the x and y will move both the Sprite and the iFrame (naturally).  So, the AS3IFrame’s x and y can be tweened (with a reletive degree of success).  Alpha can not be tweened of course.  Theoretically, the size could be tweened as well, but you’d have to tween both the AS3IFrame (by clearing the graphics class and redrawing to a new size of course) while simultaneously tweening the values of the iFrame width’s and/or heights.  I haven’t tested this, but I imagine it should work more or less.

2-  This may be obvious to many, or not, so I’ll explain this important fact here:  The HTML (iFrame) portion is a DIV section that is floating in front of the Flash movie.  It isn’t actually embedded in the Flash Movie, so it isn’t really “drawn” onto the Sprite.  It’s being drawn directly over the position of the Sprite.  So there’s an illusion of sorts here.  This is important to understand because it means that you can not have Flash “draw” anything on top of the HTML content - since it is always floating in front of the Flash content altogether.  This is also why you can’t tween the alpha, and why tweening the x and y is unlikely to be as smooth as pure Flash - though on my PC it isn’t so bad.

3-  AS3IFrame.visible = false      will make both the Sprite (backing) and the iFrame invisible.

4- AS3IFrame.iFrame.visible = false      will make only the iFrame invisible, but not the Sprite

5- Some sites, once you click on a link, ‘take over’ the browser window, replacing your entire page (example: www.yahoo.com), while most other sites do not act this way.

6- Oh, oh.. important point: The class doesn’t work, for some reason that I haven’t investigated, when using the html wrapper that Flex Builder produces. I always use my own anyway - it’s included in the downloadable zip file (when you’re looking at the source code).  (It uses SWFObject v2.)  If you know why this is the case, or better yet have a solution, please feel free to leave a comment.

7- If I’ve missed something, by all mean let me know.

Thanks,
Rodney


 
 
 

One Response to “Embedding HTML in an AS3 Project (no Flex Framework)”

  1. rpx
    1. July 2008 at 12:39

    To my dismay, discovered that the example (v0.1) doesn’t run in FF. I had only tested in IE and Opera (with no issues). Working on solution.