How to Load a SWF in Dynamically Loaded HTML
Hello,
I have a Flash movie with a multi-line text field that loads
HTML text. As per the below Macromedia documentation I have swfs as
images inside my HTML text.
I'm trying to find a way to pre-load these swfs - if I do
loadmovie to load the swf, when the html file is loaded will it
need to reload the swf from scratch or will it take my loaded
version? I'd love to show a "loading" message in the text as the
swf was loading but am unsure how to do this now that I have the
swf reference embedded in the html text.
Any ideas?
Thanks!
Julia
From the Macromedia documentation:
Image tag (<img>
The <img> tag lets you embed external JPEG files, SWF
files, and movie clips inside text fields. The <img> tag has
one required attribute, src, which specifies the path to a JPEG
file, a SWF file, or the linkage identifier of a movie clip symbol.
Thanks - your answer is exactly what I was looking for.
I'm noticing that every swf I load via dynamic HTML is
distorted - is there a way to prevent this? I can set the width and
height of each swf in the HTML, which works ok, but then I run into
a problem when I try and have a component item (like an accordion)
included in the dynamic text field. It works properly, and the
framing is sized correctly, but the guts are still skewed. I
haven't been able to figure out why the swfs are being distorted in
the first place.
Any ideas?
Thanks,
Julia
Similar Messages
-
How to embed a swf video into an html page?
I am haing trouble embedding my swf video into my html page. Here is my code:
<embed height="340" width="549" src="flashvideos/test.swf" allowscriptaccess="always" allowfullscreen="true" flashvars="&MM_ComponentVersion=1&skinName=C:/Users/RogerPa1/Documents/Visual Studio 2008/WebSites/WebSite1/Products/Create/flashvideos&streamName=C:\Users\RogerPa1\Docum ents\Visual Studio 2008\WebSites\WebSite1\Products\Create\flashvideos\Robotics&autoPlay=true&autoRew ind=false"></embed>
When I run the page the place where the flash player should be is blank. But if I right click I can select settings so the flash player is there. I'm using absolute urls for the flashvars because I read in a forum that that's what you're supposed to do. Anyway I am a little frustrated that the video won't play. I tried creating a video with no skin and the same problem occurs.
Thank You
idesofdecemberAnswered
-
Compiling a CSS into SWF without merged SDK and dynamically loading
I have a flex application that is built with the SDK merged in (for my own good reasons). This application dynamically loads a style SWF that was built without the SDK merged. Unfortunately, it seems that the loaded SWF fails to resolve its references with the SDK and gives me a 1014 run-time error.
If I merge the SDK into the CSS SWF then it works. If I set both my application and the CSS SWF to use the SDK as an RSL then it works. In short the matrix is:
CSS SWF, SDK merged?
Application, SDK merged?
Works?
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
No
Yes
I do not want a big CSS SWF to dynamically load with all the SDK in it when I already have the SDK loaded with my application. Any help much appreciated.Hi,
In you rsl project properties, go to Flex Library Build Path and go to library path tab. Here you can edit your imported library. There's no need in RSL to import the libraries merge into code but external(even the Adobe libraries should be loaded as external) cause you load it already from your application project (as rsl or merge into code).
Bye! -
Load AS2 swf into AS3 swf problem
I have a flash with AS3 and inside this swf i load in a AS2 swf.
to load swf works just fine, but the problem is when i load this i want to go to
a specific part of it, for example i want to go to frame 3 in the loaded swf.
i must control this from the AS3 swf, does someone know if this is possible?
thanks in advanceso can i do like this then to go to frame 3 in my loaded swf?
MovieClip(ldr.content).gotoAndStop(3); ?
sorry for being such an airhead
thanks for helping me out =)
Date: Sun, 7 Jun 2009 10:25:09 -0600
From: [email protected]
To: [email protected]
Subject: load AS2 swf into AS3 swf problem
no.
if, in your loaded swf, you have a function f1() on the loaded swf's main timeline and you load that swf using a loader (say ldr), use:
MovieClip(ldr.content).f1(); // to call f1() in the loaded swf
> -
What is the code to load a .swf file in AS3 on the same layer?
I'm new to AS3 and am trying to figure out the code for loading a .swf file on the same layer of the same page, thereby replacing all of the information. I don't want to put it on layer 2, etc. Another easy thing I can do in AS2 but am struggling with in AS3.
thanks!
SteveThere are no 'layers' in AS3 - there is just the display list. You can use addChildAt to add things at a specific depth - thereby placing it behind or above something, but if you just use addChild it goes on top of whatever is currently there...
Anyway - to answer your question, you can load a .swf with a Loader object like so:
var l:Loader = new Loader();
l.load(new URLRequest("myFile.swf"));
addChild(l);
You can wait for complete like was shown, but you don't have to. And this will not 'replace' anything - it just loads myFile.swf on top of anything currently being shown. If you want to 'replace' what's there you need to remove it first:
while(numChildren){
removeChildAt(0); -
Hi,
I'm creating a dynamic OSMF plugin. That plugin needs to load external SWF file before sending the PLUGIN_LOAD event to the player.
How can I override the dispatch of the PLUGIN_LOAD event on my MyCustomPluginPluginInfo custom class ?
If it's not possible, the solution is to create a new MediaElement within my MyCustomPluginPluginInfo:
var mediaElement:MediaElement = mediaFactory.createMediaElement( new URLResource(null) ); //the resource is null at this point
On the player side I add that line when the plugin is loaded successfully:
//Add listener on Media Element creation
mediaFactory.addEventListener(MediaFactoryEvent.MEDIA_ELEMENT_CREATE, onMediaElementCreate);
Is it a god solution or not ?
Is there another way to do that ?
Thanks !Hello!
I'm not sure you can do it through loadPlugin stage due to an swf loader is used in factory on that moment.
As for loading an extra swf "per instance" way I'd rather do it using an element LoadTrait than try to bypass the standard factory way.
Regards! -
How do I dynamically load a SWF that was compiled from an Fla with a linked external class file
I am dynamically loading external SWFs in a Main Fla in response to clicks on a menu.
The loading code is standard and works fine for all of the SWFs except one. When I try to load it I get the following error:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
I am certain that the URL to the problem SWF is correct. The SWF itself doesn't load any other SWFs or images.
The problem SWF is linked to an external class file and compiled with it.
i.e. in the properties panel of the main timeline of the problem SWF's Fla I have entered the path to the external class.
1. there is no problem compiling this SWF with the class (it works fine by itself)
2. if I remove the external class from the properties panel and don't use it the resulting SWF imports without a problem into the Main Fla mentioned before
So the problem seems to be the fact that the external class is linked in the properties panel. Is this a path problem?
Would appreciate any suggestions,
Thanks!despite what you say, that loaded swf most likely is loading something and that's the cause of the error.
you could test that by putting the main swf's embedding html file in the same directory with problematic swf. if the problem is as explained above, you'll have no problem when the main html is in the same directory with the loaded swf. -
Can't target main stage from dynamically loaded swf...
A part of the Flash app. I'm working on right now does the following -
Main stage loads an external swf using the following function:
function loadAsset(evt:String):void{
var assetName:String = evt;
if (assetName != null){
var assetLdr:Loader = new Loader();
var assetURL:String = assetName;
var assetURLReq:URLRequest = new URLRequest(assetURL);
assetLdr.load(assetURLReq);
assetLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)
assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);
function loaded(event:Event):void {
var targetLoader:Loader = Loader(event.target.loader);
assetWindow.addChild(targetLoader);
The externally loaded swf loads another external swf into itself using the following function:
function loadQuiz(evt:String):void{
var quizName:String = evt;
if (quizName != null){
var quizLdr:Loader = new Loader();
var quizURL:String = quizName;
var quizURLReq:URLRequest = new URLRequest(quizURL);
quizLdr.load(quizURLReq);
quizLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)
quizLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayQuizLoaderProgress);
function loaded(event:Event):void {
var targetLoader:Loader = Loader(event.target.loader);
quizWindow.assetLoader.addChild(targetLoader);
Everything loads fine, but from the quizWindow.assetLoader.addChild(targetLoader) level, I want to send a message/fill in a dynamic text box on the Main Stage. I have been "parenting" my brains out and I'm not sure how to communicate with that level.
can anyone show me the proper path or method based off the above, or have a suggestion?
Cheers,
~ChiplehAndrei1,
Thanks again for your help. I was finally able to get the solution you posted below to work for me.
Much appreciation,
~Chipleh
"In your loaded movie write:
function traceMyself(e:MouseEvent):void{
dispatchEvent(new Event("I_WANT_TEXT"));
function writeText(text:String):void {
xmlFileName1.text = text;
In the top movie that loads external swfs something like that:
loadedSwf.addEventListener("I_WANT_TEXT", onTextRequest, true);
function onTextRequest(e:Event):void {
Object(e.target).writeText(tQuizXmlFile1.theQuizXmlFile.text);
This way these two entities are independent and, most importantly, don't care who is the parent or grandparent." -
IE Active Content + Dynamically Loaded Swfs...any help?
Hi,
I've recently become aware of the whole IE active content
problem and I followed the tutorial at
http://activecontent.blogspot.com/
to adjust my html files accordingly. However I have one site
located at:
http://www.mrdodson.com/SavannahSucks/SavannahSucks.html
which loads several swfs dynamically. However in IE none of the
swfs will start loading until you click on one of the markers
which, unfortunately locks the user into a zoomed in view with no
way of exiting until the external file finishes loading. Can anyone
provide any suggestion on how I can get around this? Should I load
the clips in a different fashion or can it be resolved by adding
something to the HTML? I'm a recent grad trying to finish up my
portfolio and this is really holding me back. Many thanks for any
suggestions.
-Robplease if anyone knows anything i would really appreciate it.
i can't send my portfolio out until i fix this one thing so pretty
much my life is on hold until i can resolve this. -
Flex 4.6 IOS Mobile packager - can it load and play swf's dynamically at run time?
I have an app that shows the viewer slides in a SWFLoader object. I load the slides at runtime from a remote server. When I package the app for IOS using 4.6 the swf slides load and play fine in the IOS emulator on the PC. They don't load, however, when I deploy to a provisioned iPad.
My guess is that IOS can handle doesn't know what to do with dynamically loaded swf data. I'm not positive though because it plays in the emulator. Is that emulator truly emulating xcode or is it running flash?
Note: this same app plays an rtmp flash stream just fine even on the device itself. Just can't handle a dynamically loaded swf.The correct answer to this question appears to be that Apple's terms of service *do not* prohibit the loading of swf's on IOS from remote servers dynamically at runtime. They prohibit the loading of swf's that *contain executable ActionScript code*.
I loaded a PPT into Adobe Connect and then retrieved the resultant slide swf's from the Connect server. I took these swf's and loaded them into my iPad app, dynamically at runtime, from a remote server. The swf's loaded and animations played. I made no changes to my code. I'm just using a plain old SWFLoader object.
Loading swf's dynamically at runtime from remote servers into IOS works - if you make the swf's right. How to do that I'm not sure. -
How to load multiple swfs to my main flash file??
I am using the following code
In actions for Frame 1:
var myrequest:URLRequest=new URLRequest("A.swf");
var myloader:Loader=new Loader();
myloader.load(myrequest);
img1.addEventListener(MouseEvent.CLICK, clickButton);
function clickButton(event:MouseEvent):void{
stage.addChild(myloader);
img1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_5);
function fl_ClickToGoToAndStopAtFrame_5(event:MouseEvent):void
gotoAndStop(13);
In action for Frame 13: (img2 is another button)
img2.addEventListener(MouseEvent.CLICK, unloadFunction);
function unloadFunction(event:Event):void{
stage.removeChild(myloader);
This code works perfectly fine. My only problem is, How do I get multiple swf loaded. When I tried to copy and paste the same code for the other swf, but the following errors appear. I'm pretty sure theres a way to have multiple swfs (btw the multiple swfs will be linked from different frames).
Scene 1, Layer 'PAGES!', Frame 2, Line 7 1021: Duplicate function definition.
Scene 1, Layer 'PAGES!', Frame 2, Line 2 1151: A conflict exists with definition myloader in namespace internal.
Scene 1, Layer 'PAGES!', Frame 2, Line 1 1151: A conflict exists with definition myrequest in namespace internal.
Can someone please help me with this. ThanksYou define the same variable or function names more than once in a file. But you can reuse them in other frames. Try something more like the following in frame 2....
myrequest=new URLRequest("A.swf");
myloader.load(myrequest);
leave all of the rest out for starters... the same function from frame 1 can be re-used without rewriting them. I don't know what the deal is with img1, but if you need to change what it does, then add that back in. -
How do I script SWF files instead of JPG files in XML loader?
I have a SWF loader (greensock.com platform) and a thumbnail image scroll underneath it made of small image buttons. Each image button has a link which loads a new SWF file into the SWF loader above. Here is the code for each button which loads the bigger SWF file into the loader above:
Button3.addEventListener(MouseEvent.CLICK, Button3_PlayPopUp);
function Button3_PlayPopUp(event:MouseEvent): void {
//setting the sourceVar
sourceVar="3.swf";
//making the SWFLoader load
//as setting the soureVar after the SWFLoader is created won't do anything unlesss
//I also re-create the SWFLoader with the new sourceVar when the button is clicked
loader_howToLoader2.url = sourceVar;
loader_howToLoader2.load(true);
Then I decided to load all button via XML loader. I followed the tutorial on XML loaders which deals with loading jpg images and assigning URL links to them in the following manner first in XML file:
<image src="appThmb_imgs/appThmb_imgs117x175/A-illuminatorUpLit_117x175.jpg" title="UpDownGlowingVase" url="http://www.888acolyte.com"/>
and then in AS3 like this:
var xmlLoader:URLLoader = new URLLoader();
thisOne.link = imageList[item].attribute("url");
function clickScrollerItem(e:MouseEvent):void {
//trace("clicked item " + e.currentTarget.itemNum + " - visit url: " + e.currentTarget.link);
var urlRequest:URLRequest = new URLRequest(e.currentTarget.link);
try {
navigateToURL(urlRequest);
catch (e:Error) {
// handle error here
trace(e);
My question is: How do I apply the code to each individual small thumbnail button to load a bigger image into the SWF loader above? Do I have to add something to XML file or this way it will never work with jpg images? Can url in XML file set the source var (//setting the sourceVar), since they are all individual and then somehow apply the making SWL loader to load part (//making the SWFLoader load) as a standard somewhere in the AS3 code?O.K. Here is my COMPLETE function.
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
function LoadXML(e:Event):void {
trace("xml load complete");
xmlData = new XML(e.target.data);
//trace(xmlData.image); //we'll see each image xml element listed in the output panel with this xmlList
buildScroller(xmlData.image); //rather than trace the xmlList, we send it to our buildScroller function
//build scroller from xml
function buildScroller(imageList:XMLList):void{
trace("build Scroller");
//var scroller_x:int=0;
for (var item:uint = 0; item<imageList.length();item++) {
var thisOne:MovieClip = new MovieClip();
//thisOne.img_width=imageList[item].attribute("width");
//outline
var blackBox:Sprite = new Sprite();
blackBox.graphics.beginFill(0xFFFFFF);
blackBox.graphics.drawRect(-1, -1, 86, 128);//-1,-1 places rectangle 1px left and up.86, 128 draws rectangle 1px wider on all sides of placed image dimenstions of 84x126
thisOne.addChild(blackBox);
//scroller_x += thisOne.img_width + 20;
//var currentX = currentImageWidth+spaceBetween;//modified line to adjust variable thumb widths
thisOne.x = (84 + padding) *item;//84 is the width of the loaded images and 15 (which was before paddign var) is the padding
//thisOne.x = scroller_x;//modified line to adjust variable thumb widths
thisOne.itemNum = item;
thisOne.title = imageList[item].attribute("title");
thisOne.link = imageList[item].attribute("url");
thisOne.src = imageList[item].attribute("src");
thisOne.alpha = 0;//makes all thumb images at alpha=0 before they are fully loaded
//trace(thisOne.itemNum, thisOne.title, thisOne.link, thisOne.src);
//Loading and Adding the Images
//image container
var thisThumb:MovieClip = new MovieClip();
//add image
var ldr:Loader = new Loader();
//var url:String = imageList[item].attribute("src");
var urlReq:URLRequest = new URLRequest(thisOne.src);
trace("loading thumbnail "+item+" into Scroller: " + thisOne.src);//url
ldr.load(urlReq);
//assign event listeners for Loader
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);//tells us when the loading is complete
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);//tells us if there are any typo errors when the loading is complete
thisThumb.addChild(ldr);
thisOne.addChild(thisThumb);
//create listeners for this thumb
thisOne.buttonMode = true;//makes boxes act as buttons
thisOne.addEventListener(MouseEvent.CLICK, clickScrollerItem);//makes boxes act as buttons
thisOne.addEventListener(MouseEvent.MOUSE_OVER, overScrollerItem);//traces the title when the mouse is over the bounding box in the Output Panel
thisOne.addEventListener(MouseEvent.MOUSE_OUT, outScrollerItem);//traces the title when the mouse is out the bounding box in the Output Panel
//add item
scroller.addChild(thisOne);
But I am not sure if I expressed myself clearly. All what you have indicated happens. Images are being loaded and url strings are working. I can not figure out how to tweek the code so instead of url specified in xml file I can load swf image into the SWF loader on the same screen? -
How can you display a dynamically loaded vi to the Web Server?
I am working with LabView 6.1 and the Web Server. I can call a subvi and have it display on a remote machine using a browser with no problem. But what I would like to do is dynamically load and run a vi and have it display on the remote computer using only a browser. I have tried a small example of a front panel that invokes the run vi method (and fp.open prop) on another vi when a button is pressed, but the invoked vi is displayed only on the local computer. Is there any way of viewing dynamically loaded vi's on a remote machine without having a copy of LabView running on it?
If i understand your question correctly, you want to monitor vi that are dynamically loaded on a remote machine without having LabVIEW installed on the machine from witch you want the monitor. I don't think it's possible how ever a good reference book would be Internet applications in LabVIEW. You can find it on BARNES&NOBLE.
Hope i could help -
Problem with possition of swf when is loading dynamically to textfield
Hi guys,
I'm loading a XML to Dynamic Text field and all is OK, but
the SWF is show at left out site of the flash document, I only want
put a icon and a text in the same line, something like this:
<body><img align="left" src="icon.swf"
width="15"><mess>You have 4 new
messages</mess></body>
I was try with many kinds of tags, CSS and attributes and
nothing,
Regards, ElierFinally, I can't do it with HTML or CSS, so I do this inside
a movie in icon.swf:
this._x = 68;
this._y = -8;
You must adjust your values to your specific issue, I tried
to localToGlobal but I didn't know. -
How do i stop loading a swf file which is still in progress.
//I have three buttons on the stage (btn1, btn2, btn3)
when i click the first button swf starts loading
while the swf is loading if i press the 2nd button
the first swf wont stop loading and both the swfs start playing
but if the first swf is fully loaded then every thing workes fine.
so please let me know how do i stop loading a file which is still in progress.
var _contentSWF:ContentSWF
var _content
btn1.addEventListener(MouseEvent.CLICK, handleClick)
btn2.addEventListener(MouseEvent.CLICK, handleClick)
btn3.addEventListener(MouseEvent.CLICK, handleClick)
function handleClick(){
if(_content!=undefined){
_contentSWF.removeContent()
removeChild(_contentSWF);
_contentSWF =null;
_contentSWF = new ContentSWF()
_content = addChild(contentSWF);
_contentSWF.init(some path.swf)
//ContentSWF.as
private var _path:String
private var swfLoader:Loader
private var _content
public class ContentSWF extends Sprite{
public function init(path){
if(_content!=null){
_content.content.removeEventListener(Event.COMPLETE, completeHandler)
_content.removeChild(mymc)
_content=null
swfLoader=new Loader();
_path = path
swfLoader.load(new URLRequest(path));
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
public function removeContent(){
swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoaded);
swfLoader.unloadAndStop()
private function swfLoaded(e:Event){
_content = addChild(mymc)Thanks Kglad, it all worked fine but can you help me in this.
I have 4 movieclips (_a,_b,_c,_d) when i click each of the movieclip they load a SWF(my_mc)
now when the swf file loades it starts loading a Sound(mp3)
Now when i press another button (_b) while this mp3 is loading
all the methords like Loader.close and loader.unloadAndStop() workes fine but i dont know how dose the MP3 loades and start playing
I also used the below script in my_mc.swf , but it wont work
this.addEventListener(Event.unload, myfun)
function myfun(e:Event){
\ if(_sound.bytesLoaded<_sound.bytesTotal){
_sound.close()
if (_chanel){
_chanel.stop()
Maybe you are looking for
-
How do I rename a numbers spreadsheet on my iPad2?
I am confused as to why when I revise a spreadsheet in the numbers app, why it renames it with a number after my original document name. I want to revise my spreadsheet and keep it as the original filename exactly when I save it. Does anyone know h
-
Disallow running multiple instances of the same web start application..
on the client? I have an application that is launched on the client by clicking on the link to the JNLP file. The problem is that I don't want the application to launch twice if the user clicks the link twice. Is there a way to keep web start from ru
-
[java] JDO ENHANCER: Enhancer: enhancing classfile ... [java] Error while enhancing: JDO ENHANCER: At least one error occurred while enhancing input class for Transparent Persistence; detailed message(s): I/O error while reading input stream
-
I keep getting emails saying my password has been reset but i am not doing it?
every week i am getting a reset your password link and then another saying my password has been reset. i am running out of passwords to choose. is it likely to be an error
-
cant update or add apps to new iPhone 4s itunes not accepting my billing information what can I do