Controlling loaded SWF inside a child
Hello to everyone, may this question be too obvious to
everyone, but I've been googling for hours without any luck.
Have seen examples but they are not exactly as my scenario...
Please, I need some help.
I have loaded a SWF and attached to a MovieClip which exist
in my current movie using the following code, and now I just want
to access the loaded SWF to send it orders like play() or
gotoAndPlay(); I have tried also: container=
MocieClip(loader.content); instead adding child, but it trhows an
error
//this is your minimum code to load a file
var url:String = "put your url here ";
var request:URLRequest = new URLRequest(url);
var loader:Loader = new Loader();
loader.load(request);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
loadComplete);
function loadComplete(event:Event):void {
addChild(loader.content);
//you don't need all that code just concentrate on the bit
you need; when this work then you can start putting the rest
Similar Messages
-
CellRenderer is not displaying icons in a loaded swf, throws null child addChildAt
I'm working with a component that extends List. It works fine unless it's loaded into another swf.
It cannot find the library symbols. I know the symbols exist in the loaded swf.
Is there a quick fix to this?I have the component in the top level also,
I get this error:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChildAt()
at fl.controls::BaseButton/drawBackground()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\BaseButton.as:615]
at fl.controls::LabelButton/draw()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\LabelButton.as:724]
at fl.core::UIComponent/drawNow()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\core\UIComponent.as:1343]
at fl.controls::List/drawList()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\List.as:594]
at fl.controls::List/draw()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\List.as:474]
at .tree::TreeList/draw()
at fl.core::UIComponent/callLaterDispatcher()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\core\UIComponent.as:1532]
I've checked the definitions for the tree component,
The LabelButton and List I don't have much control over.
I'm not sure how to fix this. The xml is correct and loads easily if it's in the root document.
The list component doesn't load the labels, It stops on the first one.
What do I do next? -
(AS3) Controlling Loaded SWF
I am trying to control a loaded .swf with the parent .swf. I
do not know how to call the loaded .swf. I know how to control the
parent with the child, but not the other way around. any
suggestions would be great. thanks!call on the Loader object where the movie is being held.
You'll need to typecast like this....
MovieClip(Loader.contentLoaderInfo.content). My recommendation is
to store that path to a variable
var myLoadedMovie:MovieClip = MovieClip(
varNameOfMyLoader.contentLoaderInfo.content);
change out the varNameOfMyLoader with the proper variable
name and you should be able to target the movieclip as you would
have done in AS2. -
Control/unload swf inside html textfield i AS3
Hi,
In a CS3/As3 project I have xml files with html content loaded in a texfiled inside a mc. In some cases I have swf files embedded with img tag in the xml. The problem is that when a swf is loaded this way It keeps 'living', playing with sounds in the background when other xml files and swf are loaded in the texfiled.
Then, every time it is loaded, a new instance of the swf is created and played.
I have found out you can refer to the loader object with getImageReference method giving an id to img tag and, for example, adding an Event.COMPLETE listener to the loader.
But I don't know how to access to the loaded swf to unload it or at least stop it (mc_name.texfiled_name.swf_id doesn't seem to work in AS3)
Does anybody know if it is possible?
Thanks in advanceThank you, the second method is good to control movieclip in my case (fp9).
But I have still the following problem: the loaded objects (swf or images) seem to remain in memory.
I have a loader like this (swf_Id is the id of img tag)
loader = myMC.MyHtmlTextField.getImageReference("swf_Id");
and, following your indication, a second Mc like this
myMC2=MovieClip(loader.content);
doing the following things seem to remove the objects from stage but with no effects on the memory wich always increases
myMC2.removeChildAt(0);
myMC2=null;
loader.unload();
Any idea about this?
Thanks a lot! -
Controlling loaded swf from main timeline
Hello,
I'm working on loading external swf files for ios. I am able to load the swf files and set them to visible or invisible in different frames. I am having trouble controlling the loaded swf files from the main timeline. Specifically, I would like to have a button on the main timeline, that when clicked will move a loaded swf to frame 1.
Here is a code that loads one swf file:
var myLoader1:Loader;
var loaderContext1:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
if(myLoader1 == null)
myLoader1 = new Loader();
addChild(myLoader1);
myLoader1.load(new URLRequest("folder/file1.swf"),loaderContext1);
myLoader1.visible = true;
backbutton.addEventListener(MouseEvent.MOUSE_DOWN, backbutton1);
function backbutton1(myEvent:MouseEvent):void {???????????? myLoader1.gotoAndStop(1);} (this line does not work)
(Once I load file1.swf, within the file1.swf I click a forward button to move to different frames. My question is: how do I code the 'backbutton' on the main timeline so that it causes the loaded file1.swf to go to frame 1?)
Thank you for your help.sure.
if the movieclip on the loaded swf's main timeline has reference mc, you would use:
MovieClip(myLoader.content).mc.gotoAndStop(1);
p.s. you might find the following helpful, http://kb2.adobe.com/community/publishing/918/cpsid_91887.html -
Load SWF inside naviteWindow [AIR]
Hello,
I have an AIR application where I have to load a SWF from a server.
At some point the user will click on a button and that button will create a new nativeWindow.
Inside that nativeWindow we have a stage reference.
I just want to load a SWF, addChild it to the stage and be happy! :-P
But I'm getting this error:
SecurityError: Error #2070: Security sandbox violation: caller http://somewhere.com/swfapp.swf cannot access Stage owned by app:/Teste.swf.
at flash.display::Stage/get stageWidth()
at com.swfapp::MainClass/initApp()
at flash.display::DisplayObjectContainer/addChild()
at flash.display::Stage/addChild()
at NativeWindowSWFLoader/loadSWFURLComplete()[C:\Users\hats\Desktop\teste\NativeWindowSWFLoader.as:93]
I'm using a normal Loader:
private function loadSWFFromURL():void
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
context.securityDomain = SecurityDomain.currentDomain;
context.allowLoadBytesCodeExecution = true;
context.allowCodeImport = true;
loaderSWFURL = new Loader();
loaderSWFURL.contentLoaderInfo.addEventListener(Event.COMPLETE, loadSWFURLComplete);
loaderSWFURL.load(new URLRequest(urlSWF));
private function loadSWFURLComplete(e:Event):void
//var loaderInfo:LoaderInfo = LoaderInfo(e.target);
//var byteArray:ByteArray = loaderInfo.bytes;
this.stage.addChild(loaderSWFURL);
Can someone hep me on this?
Thank you.Hi,
I've recently come across the same problem. I really need some advice and help.
I was able to load a swf with htmlLoader in a nativeWindow. The swf is a URL base.
On Windows works without any problem but on mac it doesn't show anything.
I ran scout to check if the traces on the swf appear and for my surprise they show on scout but the native window screen in totally white. I really have search everywhere and i can't find an answer.
Any ideas?
I'm running with a retina mac (latest model).
Best regards and thanks. -
Controlling loaded swf rewind?
Hi there, I need to bring the playhead to the begining (rewind) each time the onsound button is clicked. But a loadimage function was used to load the swf. Any ideas?
Hi there! here is the script as is...I picked the project up from another coder and am still learning AS3 but think the loadimage function might be hindering the video control?
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
SoundMixer.soundTransform = new SoundTransform(1, -1);
var imageLoader:Loader;
function loadImage(url:String):void {
// Show Preloader
preloader.visible = true;
// Set properties on my Loader object
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loadImage("trailer_02.swf");
function imageLoaded(e:Event):void {
// Load Image
imageLoadArea.addChild(imageLoader);
var myTransform:SoundTransform=SoundMixer.soundTransform;
myTransform.volume=0;
SoundMixer.soundTransform=myTransform;
// Hide Preloader
preloader.visible = false;
mc_Title.visible = false;
mc_frame.mc_vignette.visible = false;
btn_OFF.visible = true;
function imageLoading(e:ProgressEvent):void {
// Get current download progress
var loaded:Number = e.bytesLoaded / e.bytesTotal;
// Send progress info to "preloader" movie clip
preloader.SetProgress(loaded);
///////////// BUTTON FUNCTIONS /////////////////////////
btn_ON.visible = false;
btn_OFF.visible = false;
btn_ON.addEventListener(MouseEvent.CLICK, soundOnOff);
btn_OFF.addEventListener(MouseEvent.CLICK, soundOnOff);
function soundOnOff(event:MouseEvent):void
if (event.target == btn_ON)
btn_OFF.visible = true;
btn_ON.visible = false;
//SoundMixer.stopAll();
var myTransform:SoundTransform=SoundMixer.soundTransform;
myTransform.volume=0;
SoundMixer.soundTransform=myTransform;
else if (event.target == btn_OFF)
btn_ON.visible = true;
btn_OFF.visible = false;
var myTransform2:SoundTransform=SoundMixer.soundTransform;
myTransform2.volume=1;
SoundMixer.soundTransform=myTransform2; -
Control loaded SWF after loadClip() in F9
Flash IDE version: 9
Flash player version: 9
Using ActionScript 2.0
I am rewriting some old MX code that typically loads a
graphics-only SWF with several frames. Then I boss the SWF around
using loadedSWF.gotoAndStop(), but now that breaks unless I compile
as Flash 7 / AS2. To keep it reasonably current I hope to get this
working in a higher version. We have darn near a jillion of these
graphics SWFs and are in no mood to open them all up. If this has
already been extensively discussed please help me with a pointer to
the juiciest parts!
Regards,
BestobellHello, thank you very much for your reply (and apologies for
my slow acknowledgement). The problem has been very peculiar as it
affects some environments but not others, but your reply suggests I
should look at clumsy mistakes first. I had suspected - 1. some
security problem - 2. flash 9 discouraging too much rummaging
about.
In Flash IDE - works
On my desktop in standalone player - fails
etc. etc. -
Load SWF into empty movieClip?
Hello,
Could anyone please point me in the right direction to find
out how to load an external SWF into an already existing movieClip
instance that is already placed on the stage? This is the way I've
always worked in AS2, but I can't find how to do it in AS3. Can
anyone point me to an example where URLRequest works with a
specified movieClip instance?
Thank you!I understand why you might think I was ignoring your advice,
but this isn't the case. You're expertise is much valued and
respected.
My purpose for continuing to experiment with loading into a
movieClip was an attempt to find an easy way to layer the SWF
behind other elements, but as you know, although it works for this
purpose, it doesn't allow control of the loaded SWF from the main
timeline. For others struggling to learn as I am, here's a link
where I found the answer to my question above:
http://www.hostingforum.ca/776586-as3-controlling-loaded-swf.html
The transition to AS3 is not as easy for some as for others,
and there are new concepts to understand.
Don't know what "nvm" means... curious, but might be better
off not knowing ;) Thanks again for all the help you offer to all
of us who are struggling. -
SwfLoader cause Browser to crash when we change loaded swf multiple times..
Hi Everyone,
I'm developing a Flex application now, and inside my application I am using SWFLoader which will be used to load other .swf file.
The SWFLoader is working, but after I change the .swf file so many times(around 20 times), the application always cause the browser to crash and shutdown automatically.
I suspect this is because of the SWFLoader. If we change the loaded swf inside SWFLoader, it won't remove the old one from memory automatically.
This is my simple code to change the loaded swf inside SWFLoader :
public var applicationLoader : SWFLoader;
public function loadApplication(appName : String) : void {
if(loadedApplSysManager != null) {
var currentApplication : AppInterface = loadedApplSysManager.application as AppInterface;
if(currentApplication != null) {
currentApplication.applicationStateComplete(); // do something inside small app before unload
// try to set everything to null, so GarbageCollection is called ..
applicationLoader.source = null;
applicationLoader.load(null);
var applicationUrl : String = applicationDict[appName];
var urlApp : String = path + applicationUrl + "?noCache=" + version;
applicationLoader.source = urlApp;
btw, I am also using Cairngorm command in every small application and some RSL..
Has anyone ever experience the same thing and have any suggestion?
How can we handle the SWFLoader properly, the loading and unloading process?
Any suggestions will be appreciate..
Thanks,
AndreHere are four links related to this topic:
http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html
http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html
http://blogs.adobe.com/aharui/2009/05/more_on_finding_memory_leaks.html
http://blogs.adobe.com/aharui/2009/08/what_we_know_about_unloading_m.html -
Loading a SWF inside another SWF question
Hello friends,
1. (IMPORTANT) As all we know when putting some Flash SWF
inside an HTML page, normally it starts playing as soon as its
first frame is loaded.
Now in my case I have to load a SWF (let call it Flash A)
inside another Flash, I used mx.controls.Loader control to do this.
But this internal loaded SWF (Flash A) doesn't display untill it is
completely loaded. Although what is interesting is that if it
contains a sound track I can hear it while it is being loaded.
I wana know is there any way that we can make this Flash
display while being still loaded.
2. Is there anyway to change a Flash playback FPS at runtime?
Thank you so much for any note and help.
- Mdamatrixhasu wrote:
> i want to know how i can load a flash inside another
flash container
go to help - search for 'loadmovie'
Best Regards
Urami
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Controlling a Movie Clip on the Main Timeline from a loaded SWF?
Is it possible to control a MovieClip on the main timelne from another loaded clip?
I see posts that control loaded clips, but most are all from the loader in the main timeline. I have a moviclip on the main timeline that I want to make visible or invisible depending on what keyframe is playing in another loaded swf.
If I try to call the movieClip from the loaded SWF I get "error #1119. Access of possibly undefined property...." because it doesn't exist in the loaded SWF, just the main timeline.
The old AS2 way just used "_root". Since "_root" doesn't exist any more, how do you control items on the main TimeLine from a loaded SWF?I am not clear what you mean because you are saying you are trying to target a movieclip that does not exist where you are trying to target it.
Try using a trace to see what you are targeting when you you target the MovieClip(parent.parent)....
trace(MovieClip(parent.parent));
The other approach I mentioned earlier is the more OOP-correct approach if you would rather try that way. Here's a rough outline of it...
AS3 - Dispatch Event
http://forums.adobe.com/thread/470135?tstart=120
Example:
Add something to trigger the event in the child (your loaded swf):
dispatchEvent(new Event("eventTriggered")); (
if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo. In the complete event handler, add a listener for the event on the loaded swf.
// event handler triggered when external swf is loaded
function loaderCompleteHandler(event:Event) {
MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
function eventHandler(event:Event):void {
trace("event dispatched in loaded swf");
// this is where your main file can set the visible property of your movieclip -
Control main timeline from loaded swf.
Hi,
I'm using a textfield for debug information.
I'm loading an swf on the main timeline and I'm showing the status in the debug textfield.
function swfLoaderCompleteHandler(event:Event)
Debug.text += "Swf loaded.";
That works.
But,
I'm loading a png file in the loaded swf. , I'm trying to show the status of the png file as I showed the status of the swf.
function pngLoaderCompleteHandler(event:Event)
MovieClip(parent).Debug.text += "Png loaded.";
I can't control the main swf from inside the loaded swf. Even gotoAndStop or calling a function doesn't work.
Do I need to add something when I load the swf, saying it's a MovieClip or something?
Here's a fla too. http://flashfocus.nl/forum/attachment.php?attachmentid=9885&d=1282509233Thank you! you're brilliant!
For people with the same problem:
If you use CS5 and you have a TLF text on the stage, it doesnt work... I think it's a bug. But when I converted my TLF textfield to classic and everything works fine! -
Controling a loaded swf with another loaded swf
I have a blank stage with only AS that loads an swf
addChildAt(0) and a second one addChildAt(1). This works. When the
user interacts with (1) it calls another addChild (not indexed) and
possibly that one loads another, depending on the choices made by
the user. How can I get any of these to control that very first
child that was loaded at (0)? I have run out of ideas.
Some of the code:
(on the main swf, nothing on the stage, only code that loads
the next two)
addChildAt(pHolder, 0);
pLoader.load(pURLReq);
pLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
pLoaded);
and for the second:
addChildAt(mHolder, 1);
mLoader.load(mURLReq);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
mLoaded);
On the child of childAt(1), I have:
function replaceSWF(e:MouseEvent):void
pLoader = new Loader();
pLoader.load(new URLRequest("p.swf"));
pLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
placeNewClip);
function placeNewClip(e:Event):void
removeChildAt(0);
addChildAt(e.target.content, 0);
If I use this exact same code from that very first swf, the
one that loads the first two external swfs, it works, but once I
put it on one of hte other loadeds and sub loaded swfs, I can't get
it to work. In the current state (0) it just makes everything on
the stage disappear, so I figured then using the index of (1) would
do it, but that or any other number results in absoluly nothing.
Help! I am really out of ideas here.
(the stacking looks like this) ---
sub second loaded SWF <==== needs to tell first loaded SWF
to unload then load a new swf at same index
second loaded SWF <==== loads the next one above
first loaded SWF <=== needs to be removed and another swf
loaded at the same index
mainSWF (loads two others) <=== code placed here works for
first loaded SWFKglad,
I tried your code and ran into some problems with stopping
the mc's, as the embedded mc's within the loaded swf need to stop
as well. I found the attached code to stop the mc's, but now am
having trouble with the sound objects.
Here's the issue, I used this:
this.soundPosition = currentMovie.loop1.position/1000;
this.currentMovie.loop1.stop();
... for the sound object stop commands and listed a new one
for each loop I was using. On the play button I started them back
up again. This all works, but when I start them up again they all
play, not just the one that is currently paused. Do you mind giving
me some guidance with the for (obj in mc) loop? My loop experience
is nil. What I want to do is have the code cycle through all of the
loops to see which one is playing, then store that information in a
variable, then pause and play the variable. Does that sound right?
Thanks again for the help!
-Sandy -
Load and resize a SWF inside a MC
Hi,
I'm using AS2 to load an SWF inside an MC. The MC measures
800x600, while the SWF (which can vary in size) measures in this
case 14x60, even though, looking at it, it seems to be about half
the size of the hosting MC. This makes me think that the dimension
scales are different. I'm loading the SWF using MovieClipLoader and
I'd like to resize it so that it fits as proportionally snug as
possible within the MC. How can I do this? If I try to resize the
SWF to the MC's dimensions, it become way too large and goes off
screen. If instead I try to rescale the hosting MC to fit around
the SWF, the SWF itself rescales as well. I'm going nuts! How can
accomplish this?
Thank you,
TatianaTo make things simple, I'd like to take an existing SWF (the
picture) and load it into a FIXED SIZED MC (the frame) and I'd like
to rescale the SWF so that it fits perfectly into the frame.
By all means, I know that what you said should work and I
admit my inexperience with AS2, but somehow the SWF's I'm loading
in, have scales that are totally different with respect to my
Stage. I even tried loading the SWF directly onto the stage and
then I loaded the frame separately onto the stage and tried to
resize it to the SWF's _width and _height. The frame became a tiny
dot on the screen, while the SWF filled half of my Stage.
Thanks again for your help.
Maybe you are looking for
-
XML to ABAP Structure transformation
Hi SAP, Can anyone tell how to transform from XML to ABAP structure. The ABAP structure i'm getting in runtime. Please do the needful. Thanks in advance Vinod.
-
I currently have CS6 for PC and I am now switching to be a Mac user. I previously spoke to a representative who said I should be able to transfer my software. Can you please inform me how this would happen? Many thanks for your help. Serena Edwards
-
How to use Translate This! 1.8
I installed Translate This! 1.8, but no icon has appeared in my add-ons toolbar and there is no entry in the Tools menu after restarting Firefox. If I select text and right click, the menu does not list translate either. Under View>Toolbars>Customize
-
Hi, I have a problem with an auto calculation row. One of the columns in the report is a percentage so I don't want the calculation to sum but to calculate with the column formula. Is it possible to achive this? I'm using FR 9.3.1. Thanks
-
Abap routine to NOT to allow only one value
Hello Everyone, I am trying to filter out one PO Number from WBS costs load. I wrote an abap routine as the data selection. The data source does not allow the 'NE'. Any suggestions? Below is the code. read table l_t_range with key f