Load swf and play movieclip inside it
I want to load a swf and play a moveclip inside it, but the SWFLoad.content always is null. Does sombody know how to resolve this problem?
private var SWFLoader:Loader;
public function myApp3()
SWFLoader = new Loader();
var request:URLRequest = new URLRequest("FlashAS3_2Flex.swf");
SWFLoader.load(request);
this.addChild(SWFLoader);
var currentSWF = MovieClip(SWFLoader.content);//SWFLoader.content is null
currentSWF.myClip.gotoAndPlay(1);
The code you show works fine for me. How is btn1 created/named in the second swf file? If you create it dynamically and do not assign a name property to it, it does not have the name you think it does.
Similar Messages
-
Videos do play but are not loading properly and plays choppy.
Videos on websites as www.omesakevideo.nl do play but are not loading properly and plays choppy, I don't have this problem in Safari or Chrome
Try the basics from the manual:
restart.
reset.
restore.
iPod touch User Guide (For iOS 4.3 Software) -
Loading two swfs and playing them sequentially
Hello Team,
I have searched, but can't seem to find an answer to my question. I'm working in Flash cs6 on Windows platform. I do not understand how to load two external swf files into another swf file(Main swf) and have them play sequentially. I certain that this task is extremely small to a lot of members of this forum, but if someone could be so kind to assist me with this inquiry I will be over-joyed.
I am able to load one swf with the following code:
var swf:MovieClip;
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("swf/gallery.swf");
loader.load(defaultSWF);
addChild(loader);AS3 - Dispatch Event
Example:
Add something to trigger the event in the child:
dispatchEvent(new Event("eventTriggered"));
(if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
The listener for this event has to be added to the main file AFTER the external file has been loaded. In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo.
yourLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
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);
Then just create the event handler for the dispatched event listener that was created in the loaderCompleteHandler function.
function eventHandler(event:Event):void {
trace("event dispatched in loaded swf");
// load/play your second swf now -
Load swf AFTER playing to end of root timeline
Don't know if this can be done or not...
I have my Home page - 5 Navigation buttons on the page. Each
button "onRelease" will load an external swf file ( a new page).
The problem i'm having is getting the the buttons to play the rest
of the root timeline (after "Stop) before it loads the external
swf. The rest of the timeline is just a short fade to Alpha 0 of
all buttons before the new page comes in.
any help?
thanks in advance.michaeltowse wrote:
> Could you not assign a variable which is then picked up
at the end of the main
> timeline. This variable could be used within a loadMovie
command. Your buttons
> would have the variable declaration and then a play()
command.
>
What you seem to need is some sort of non unloading loading
of the movie.
You got the level loading method, the movieclip loading
method and the
dedicated loader class. -
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. -
Load swf and get a SimpleButton in it
I load a swf and want to get a button in the swf. But the button I get is NULL. I am sure the button's name is right and exists. Could somebody help me to solve this problem?
package
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.SimpleButton;
import flash.display.LoaderInfo;
public class MyClass1 extends MovieClip
public function MyClass1()
super();
var swfLoader:Loader = new Loader();
addChild(swfLoader);
var bgURL:URLRequest = new URLRequest("secondFlash.swf");
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
swfLoader.load(bgURL);
var currentSWF:MovieClip = new MovieClip();
function loadProdComplete(e:Event):void {
var loaderInfo:LoaderInfo = e.target as LoaderInfo;
var mv:MovieClip= MovieClip(loaderInfo.content);
var btn1 = mv.getChildByName("btn1") as SimpleButton;
trace("mv"+mv);
trace("btn1="+btn1);The code you show works fine for me. How is btn1 created/named in the second swf file? If you create it dynamically and do not assign a name property to it, it does not have the name you think it does.
-
Loading SWFs and setting z-index
I have a project that involves 10 SWFs files. I know how to load them using one container. The problem I have is that when a new SWF loads, it covers the main navigation's drop menus from main container. The navigation bar on main container is a movie clip labeled nav_btns.
Can someone help me set the z-index of main container and other SWFs as they load?
Here is my code, which works when loading SWFs
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
var Xpos:Number=10;
var Ypos:Number=115;
var swf:MovieClip;
var loader:Loader=new Loader();
var loader1:Loader= new Loader();
var defaultSWF:URLRequest = new URLRequest("homePage.swf");
loader.load(defaultSWF);
loader.x=Xpos;
loader.y=Ypos;
addChild(loader);
function buttonClick(event:MouseEvent):void {
removeChild(loader);
var newSWFRequest:URLRequest= new URLRequest("Movies/"+ event.target.name+".swf");
loader.load(newSWFRequest);
loader.x=Xpos;
loader.y=Ypos;
setChildIndex(this, -1);
addChild(loader);
nav_btns.homePage.addEventListener(MouseEvent.CLICK, buttonClick);
nav_btns.homePage.txt.text="HOME";add (or re-add) the menu to the display list after you add the loader.
-
Loading SWF x Embedding MovieClip
Hello there!
Suppose I am making something like a game which has lots (like hundreds) of minigames that the player can choose to play. Each minigame is developed separately by different programmers for instance. This game is going to be running on android.
What is the pros and cons of:
1) making every minigame a separeted SWF and loading it whenever the player chooses to play that minigame
2) Making each minigame a class that can be called as currentMinigame = new MyMinigame(); and then adding it/removing it from stage?
Which one enhances performance and which one enhances memory use?
Hope you can help me hereI'd go with having everything as a separate swf. That way you do not have to edit the main file every time something new gets added.
-
Export animation to SWF and plays as MovieClip
Hi to EveryBody.
We are evaluating the Rome AIR applicaction in order to create presetations and swf animations.
We have made an animation, the Anim Clips Animation, without anything more.
We have exported to SWF (Flash Player Compatible) and everything went ok.
We have a special player made in flex that plays de SWFs Casting it as a MovieClip and when the object is Casted the result is a null object.
We have had this problems with SWFs compiled with flash player in AS2 but if it was compiled in AS3 it works.
Any idea or solutions.
Thanks
The player Code for Flash Builder 4: When you click the button de conversión is realized and the movie variable is null.
<?xml version="1.0"?>
<!-- controls\swfloader\SWFLoaderSimple.mxml-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
function convert():void{
var movie:MovieClip = player.content as MovieClip;
movie.gotoAndPlay(1);
]]>
</fx:Script>
<s:VGroup>
<mx:SWFLoader source="Rome.swf" id="player"/>
<s:Button label="Convert" click="convert()"/>
</s:VGroup>
</s:Application>Fixed Layout EPUB files support most of the animation you can do in InDesign.
https://indesignsecrets.com/lynda-com-course-creating-fixed-layout-epubs-indesign-cc.php -
Sound objects in loaded swfs not playing
I'm working in ActionScript 2. I have a series of swfs with Sound objects. Works just fine when I play the swf. However, when I load them into a loader, no sound. HELP!!!
when you instantiate your sound, instead of using something like:
var s:Sound=new Sound()
use
var s:Sound=new Sount(this); -
Can't Access MovieClips and Functions in Loaded SWF
Hi everybody,
I'm trying to simply access anything inside this loaded SWF and all I get is 'null'.
I have code in the parent SWF that needs to tell the child SWF movieclip what to do but nothing works. This was a piee of cake in AS2 and I can't seem to get anything to crossover in AS3.
Here's my code:
import com.greensock.TweenMax;
import flash.display.MovieClip;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
panel2.addChild(myLoader); // add that instance to the display list, adding it to the Stage at 0,0
panel2 = myLoader.content as MovieClip;
photo_about.alpha = 0;
photo_downloads.alpha = 0;
//panel2.content_about.alpha = 0;
//panel2.content_downloads.alpha = 0;
function closeSection():void
panel2.controlsMC.forcePause();
TweenMax.to(photo_about, .5, {alpha:0});
TweenMax.to(photo_downloads, .5, {alpha:0});
TweenMax.to(photo_home, .5, {alpha:0});
TweenMax.to(panel2.content_about, .5, {alpha:0});
TweenMax.to(panel2.content_downloads, .5, {alpha:0});
TweenMax.to(panel2.controlsMC, .5, {autoAlpha:0});
TweenMax.to(panel2.content_home, .5, {alpha:0});
panel2 traces null and all the clips loaded within pull up undefined property errors.
Can somebody please tell me what I'm doing wrong? I'd be stoked to know what I'm missing and feel like this should be a piece of cake.
Thanks for any help!You are not adding the content to the stage at 0,0, you are adding it to panel2 at 0,0. THen you take panel2 and assign it to be something that likely doesn't exist by the time you assign it. You need to wait until the loader completes loading before you attempt to do anything with its content, otherwise it has no content (null). Similarly, you cannot control anything in the loaded swf until it has finished loading. So assign an event listener to the contentLoaderInfo property of the Loader to determine when loading is complete, and have the event handler function deal with starting the interaction with it.
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf");
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, processLoadedSWF);
myLoader.load(url);
function processLoadedSWF(evt:Event):void {
// deal with the loaded swf here
// but you don't want to be assigning it to the panel2 object that contains the loader
As far as controlling anything inside the swf you load, is it an AS1/2 or an AS3 swf? -
Trying to get a movieclip to display on top of an externally loaded swf
I am trying to ensure that a movieclip named "Incorrect"
displays on top of a swf file that loads with the following:
loadMovieNum("map.swf",1);
I'm sure it's pretty simple, but I couldn't find any good
reference to a movieclip loading on top of an external swf. I tried
loading the map.swf into a placeholder movieclip and doing a
swapDepth, but then the code within the map.swf would no longer
function properly.
thanks.you must load that movieclip into a _level greater than 1.
there is no work-around if you load map.swf into _level1.
you could load map.swf into a target movieclip and then use
the swapDepths() method of movieclips to control the apparent depth
of map.swf and your movieclip. -
Loading External SWF and setting variables
Hello Everyone.
I'm sure you are all a where of the FlashVars attribute for
Flash embeds which holds variables for SWF's when they are
rendered. I'm attempting to load an External SWF dynamically
from within my own SWF and need to provide it with the values
normally stored in the FlashVars. For the example below I
wait until the External SWF is completely loaded using the
onLoadInit event from moviecliploader and then i attempt to
set the required variables that the loaded SWF needs. This works
great in test and debug mode (ie. Test Movie and Debug Movie
from the Control menu), but when i publish my FLA to SWF and run
the SWF the variables will NOT get set in the loaded External SWF.
From my readings ive people have mentioned that the player is only
able to access Methods of an External SWF. If this is the case then
how do they expect people to set the FlashVars of dynamically
loaded SWFs? I investigated the loadVariables procedure as well and
had the same results in test mode and was wasn't reliable because
of timing issues.
The sample source is below... if anyone has any ideas or has
come across this issue before, I would really appreciate some
insight.
Thank you in advance for your time.
var loader_mc:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
loader_mc.addListener(mclListener);
mclListener.onLoadProgress = function(target_mc:MovieClip,
numBytesLoaded:Number, numBytesTotal:Number) {
// DO NOTHING
mclListener.onLoadComplete = function(target_mc:MovieClip) {
// DO NOTHING
mclListener.onLoadInit = function(target_mc:MovieClip) {
// WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
target_mc._root.param1 = "value1";
// WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
_level0.container_mc.param1 = "value1";
this.createEmptyMovieClip("container_mc",
this.getNextHighestDepth());
container_mc._lockroot = true;
loader_mc.loadClip("somecoolflash.swf", container_mc);I've tried that as well and it behaves the same as onLoadInit
... Works when i test but doesnt when i publish to a swf. I think
this is security related and the flash player just cant write to a
loaded swf and set variables. -
Can't load facebook flash games completely, can load and play games anywhere else
I have adobe flash player 10.2 for firefox installed. I've got 3.5.18 Firefox. Up until about February I was able to play flash games just fine, even with an apparently outdated Firefox and flash player 10.
Then I suddenly couldn't completely load games like Frontierville or Treasure Isle. No matter what I would do; including clearing the cache, clearing temporary internet files, reloading the page repeatedly, restarting my computer and uninstalling/reinstalling my flash plugin and my browser, the loading screen would hang at about 98% completion. This is now a common issue across the site for me. No games at all will load.
I can go to any other site however, and play any flash movie or flash game I wish. It will load properly, and play as normal.
Any and all addictinggames.com games and any and all miniclip.com games work just fine, as an example.I have played the facebook games on firefox, they run perfectly fine on firefox. no problem with the games. All the games are working fine. Facebook games, chrome games or be it online games, they work absolutely fine on my firefox. There might be some problem with your computer. Try to fix it yourself. My firefox runs absolutely fine. The favicon on my site is a movable one which keeps sliding. Even the favicon works on my firefox which does not work on Google chrome. Internet explorer completely messes up my website but firefox is absolutely working good. I play games on [[Racing Games|http://www.racinggames9.com/]] and i haven't had any problem with any of the games here. Miniclip is also working fine on my firefox.
-
Can you tell when a loaded SWF has reached its final frame?
I used loadMovie to load an external SWF into the bottom-half
of a main "shell" swf. When that loaded SWF finishes playing (it's
just an animation), I need to populate a text field with the word
"DONE" . The text field resides on the _root, so I need some way to
know when the loaded SWF has reached its last frame...
This would obviously be easy if I had the .FLA of the loaded
SWF because I could just write the actionscript on the last frame
of that SWF to populate the _root textfield. Alas, I do not have
the source FLA of that loaded SWF, so I need some way to have the
main "shell" SWF/FLA know when that loaded SWF has reached its end.
Is this possible???
Thanks!!!DIY_Lobotomy,
> The reality of my situation is that there's a "menu" of
sorts that
> gets loaded into "contentClip". This "menu" has a bunch
of links.
So far, so good.
> When clicked, each link loads a DIFFERENT swf into
"contentClip".
> It is THOSE swfs that I need to note the end of.
That's still okay.
> So, there's actually more than one, and they're not
exactly being
> loaded directly from my main movie, since they're
actually loaded
> based on a link being clicked in the movie that is
currently loaded
> into "containerClip"
The concept is still the same, no matter what. No matter how
deep the
one-clip-loads-another chain goes, you have to keep taps on
each chain link.
When the final link has loaded, you'll be able to make your
object reference
to that movie clip. That movie clip -- because it's an
instance of the
MovieClip class -- will have the _currentframe and
_totalframes properties.
You'll just be checking *that* cliip's properties instead of
the one named
contentClip in my own example.
You can loop using onEnterFrame or, if you prefer, with
setInterva().
That doesn't much matter either, so long as you repeatedly
poll the deepest
clip to test its current frame against its last frame (this
all assumes that
the clip being tested is a linear animation whose end
corresponds to its
last frame; otherwise, you could check _currentframe against
any arbitrary
frame number).
> I hope that wasn't too confusing! Do you still have a
solution???
Not too confusing to understand, but it might be confusing
to route
through in practice. Not confusing, actually, but meticulous
... you'll
have to be careful with your pathing. Nested movie clips are
very much like
nested folders on your hard drive. Their instance names
relate to the
folder names.
Now, if that menu doesn't have an instance name you provided
-- or if
any fork along the path has an instance name you can't
control -- you can
still reference the nested movie clips. If you test your file
in the
Debugger panel, you'll see all the instances laid out in
hierarchical order.
You'll see that automatic instance names are provided
(something like
"instance1", "instance2", etc.).
David Stiller
Contributor, How to Cheat in Flash CS3
http://tinyurl.com/2cp6na
"Luck is the residue of good design."
Maybe you are looking for
-
How can I backup my iPad to another iPad backup I have on my same iCloud account. The old one is totally gone. Both backups are listed on my iCloud account. So is there any way I can backup the one I have now to the other one. I really just want t
-
Screen Distortion w/Quick Time 7.2
I am unable to view .MOV files taken with my Panasonic digital camera's video feature. I get no picture, just a screen full of pink and green irregular patterns (sometimes they are square)that repeat themselves in horizontal rows. When I click the PL
-
Generate a different width pulse using pxi-6542
Hello I want to use the board of PXI-6542 to generate a waveform, and the waveform has different width, but the width is a integer which is less than ten is multiplied by 0.1ms,and the multiply is random. The waveform is output through PXI-6542.Than
-
We have one customer with one ASA and one 3750 switch in headquater. 6 1801 Routers in 6 branches. All connected via MPLS/BGP provided by ATT. And it was terminated at one port on 3750. We plan to replace that with Metro Ethernet Hub/Spoke topology s
-
I need to run Windows...more importantly, I need to run Access. That is the only program I need to run on my Mac So, does this sound correct.... Upgrade to Leopard (to get bootcamp), purchase XP Service pak 2 (to get Windows) and also purchase Micros