Arranging Layer Position of Loaded SWF or Mc in ActionScript3
Hi All
I would like to RUN/LOAD my loaded SWF or Movie Clips BEHIND some existing Masks already designed in a scene or simply arrange their
visibility position in ActionScript 3 while loading them with CODING only
is there any command to define, something similar to "Layers", "send to back", "bring to front " ?
Thank You .
You can use the addChildAt() method to place things behind other things. You can also use the setChildIndex() method. Both are explained in the Help documentation.
Similar Messages
-
Set X,Y Position for loaded SWF file
I'm sure this question has been asked before, but I have been
reading the forum and get seem to find the answer. (Yes I looked at
the AS2 dictionary before I posted.) I'm trying to load an external
SWF into my stage. I have entered X,Y, coordinates, but the
external SWF loads at 0,0 I have attached the code I was trying.
Any help would be appreciated. This code is on the button, should
it be on the timeline? Thanks!Glad you took that in the good spirit it was offered. After I
posted it I was worried that I sounded too mean. Your new code is a
big improvment IMHO! I've made a few changes and attached that and
I'll go through them with ya.
The first cool thing you did and you might not even be aware
of all of it is that you were using the return type of
createEmptyMovieClip. Whenever you checkout something in the help
files, notice the return type. That tells you that cEMC returns a
reference to the newly created clip. If you capture it and assign
it to a variable you can then use that variable as a
"short cut" of sorts. So even though you named
the new clip roscoe, I'm refering to it as container. Not such a
big deal for this example, but in the future you might attach a
bunch of clips with names/paths like:
myContainer.backgroundArt.button1
myContainer.backgroundArt.button2
etc.
So remember that trick. I've also added a this to the cEMC.
It is a good habit to always prefix methods with an instance of the
class they belong too. For example there might be times when the
scope isn't clear and your clip will not get attached where you
think. Of course using this inside a function is one of those
times! So sometimes I would create a variable called home (outside
of any functions) which refered to my main timeline. Then I could
use home.createEmptyMovieClip() inside pretty much any function or
handler and not worry about where my clip was being created.
Next, setProperty is also the old style. I find it much
easier just to set the property with the assignment operator (that
would be the equal sign) and the dot. So:
setProperty("someObject",someproperty,somevalue)
becomes
someObject.someproperty = somevalue;
I think most people find that easier to read.
I'm not sure, but generally I don't think I would create my
MCL instance inside the onRelease handler. No real reason I could
give for that, except perhaps if you have several buttons and each
one will load a different clip. In that case they could all use the
same loader and you wouldn't need to repeat the code over an over.
Hey! that seems to be a pretty good reason to me.
Finally. The way you handled the onLoadInit will work, but
for some reason it isn't the prefered way. It has never really been
clear to me why, but they prefer to have you create an object, add
your event handlers to the object, and then add the object as a
listener. I've shown you how here.
BTW, if you hadn't figured it out, the onLoadComplete is
pretty useless. Several of the properties, like _width and _height
are not yet available at that event, so you picked the right one
(onLoadInit) if you want to scale the content after it loaded.
Good luck and let me know if you need to figure out something
else. -
Loading swf into swf in exact position
It's very simple to load an external swf into a main swf with
loadMovieNum("name.swf", 50);
But how do I control the position of the loaded swf?
Currently it just pops in the top left.Try loading your external .swf into a pre-positioned
movieClip, for example myMovie.loadMovie("name.swf). If you do not
want to do this you can position the loaded movie later in your
application or onload by setting the x and y pos with some
AS. -
How to unload externally loaded swf which contains 3D Carousel?
Hello to all
I am learning AS3 and have been taking on various tutorials found on the net. While learning about AS3 I came across a lesson on http://tutorials.flashmymind.com/2009/05/vertical-3d-carousel-with-actionscript-3-and-xml/ titled "Vertical 3D Carousel with AS3 and XML".
I completed the tutorial and all worked fine so I then wanted to load the swf into a existing project. The loading of the swf goes fine and when I unload my loader it is removed but only visually as in my output panel in flash CS5 I get an error as follows
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at carousel_c_fla::MainTimeline/moveCarousel()
this error repeats over and over again slowing my swf movie.
So does this mean my main flash movie trying to still play / find my unloaded 3D Carousel?
If so how do I unload remove all the AS3 that is trying to run from the 3D Carousel?
I have included the AS3 below from the tutorial page and I understand that this is what I have to remove to "break free" from the 3D Carousel swf when it is unloaded. This is where I am stuck as my knowledge of AS3 is limited - Can you guys / girls help?
//Import TweenMax
import com.greensock.*;
//The path to the XML file (use your own here)
// old var from tutorial - var xmlPath:String = "http://tutorials.flashmymind.com/XML/carousel-menu.xml";
var xmlPath:String = "carousel-menu.xml";
//We'll store the loaded XML to this variable
var xml:XML;
//Create a loader and load the XML. Call the function "xmlLoaded" when done.
var loader = new URLLoader();
loader.load(new URLRequest(xmlPath));
loader.addEventListener(Event.COMPLETE, xmlLoaded);
//This function is called when the XML file is loaded
function xmlLoaded(e:Event):void {
//Make sure that we are not working with a null variable
if ((e.target as URLLoader) != null ) {
//Create a new XML object with the loaded XML data
xml = new XML(loader.data);
//Call the function that creates the menu
createMenu();
//We need to know how many items we have on the stage
var numberOfItems:uint = 0;
//This array will contain all the menu items
var menuItems:Array = new Array();
//Set the focal length
var focalLength:Number = 350;
//Set the vanishing point
var vanishingPointX:Number = stage.stageWidth / 2;
var vanishingPointY:Number = stage.stageHeight / 2;
//We calculate the angleSpeed in the ENTER_FRAME listener
var angleSpeed:Number = 0;
//Radius of the circle
var radius:Number = 128;
//This function creates the menu
function createMenu():void {
//Get the number of menu items we will have
numberOfItems = xml.items.item.length();
//Calculate the angle difference between the menu items (in radians)
var angleDifference:Number = Math.PI * (360 / numberOfItems) / 180;
//We use a counter so we know how many menu items have been created
var count:uint = 0;
//Loop through all the <button></button> nodes in the XML
for each (var item:XML in xml.items.item) {
//Create a new menu item
var menuItem:MenuItem = new MenuItem();
//Calculate the starting angle for the menu item
var startingAngle:Number = angleDifference * count;
//Set a "currentAngle" attribute for the menu item
menuItem.currentAngle = startingAngle;
//Position the menu item
menuItem.xpos3D = 0;
menuItem.ypos3D = radius * Math.sin(startingAngle);
menuItem.zpos3D = radius * Math.cos(startingAngle);
//Calculate the scale ratio for the menu item (the further the item -> the smaller the scale ratio)
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the menu item according to the scale ratio
menuItem.scaleX = menuItem.scaleY = scaleRatio;
//Position the menu item to the stage (from 3D to 2D coordinates)
menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;
menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;
//Add a text to the menu item
menuItem.menuText.text = item.label;
//Add a "linkTo" variable for the URL
menuItem.linkTo = item.linkTo;
//We don't want the text field to catch mouse events
menuItem.mouseChildren = false;
//Assign MOUSE_OVER, MOUSE_OUT and CLICK listeners for the menu item
menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
//Add the menu item to the menu items array
menuItems.push(menuItem);
//Add the menu item to the stage
addChild(menuItem);
//Assign an initial alpha
menuItem.alpha = 0.3;
//Add some blur to the item
TweenMax.to(menuItem,0, {blurFilter:{blurX:1, blurY:1}});
//Update the count
count++;
//Add an ENTER_FRAME listener for the animation
addEventListener(Event.ENTER_FRAME, moveCarousel);
//This function is called in each frame
function moveCarousel(e:Event):void {
//Calculate the angle speed according to mouseY position
angleSpeed = (mouseY - stage.stageHeight / 2) * 0.0002;
//Loop through the menu items
for (var i:uint = 0; i < menuItems.length; i++) {
//Store the menu item to a local variable
var menuItem:MenuItem = menuItems[i] as MenuItem;
//Update the current angle of the item
menuItem.currentAngle += angleSpeed;
//Calculate a scale ratio
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the item according to the scale ratio
menuItem.scaleX=menuItem.scaleY=scaleRatio;
//Set new 3D coordinates
menuItem.xpos3D=0;
menuItem.ypos3D=radius*Math.sin(menuItem.currentAngle);
menuItem.zpos3D=radius*Math.cos(menuItem.currentAngle);
//Update the item's coordinates.
menuItem.x=vanishingPointX+menuItem.xpos3D*scaleRatio;
menuItem.y=vanishingPointY+menuItem.ypos3D*scaleRatio;
//Call the function that sorts the items so they overlap each other correctly
sortZ();
//This function sorts the items so they overlap each other correctly
function sortZ():void {
//Sort the array so that the item which has the highest
//z position (= furthest away) is first in the array
menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
//Set new child indexes for the item
for (var i:uint = 0; i < menuItems.length; i++) {
setChildIndex(menuItems[i], i);
//This function is called when a mouse is over an item
function mouseOverItem(e:Event):void {
//Tween the item's properties
TweenMax.to(e.target, 0.1, {alpha: 1, glowFilter:{color:0xffffff, alpha:1, blurX:60, blurY:60},blurFilter:{blurX:0, blurY:0}});
//This function is called when a mouse is out of an item
function mouseOutItem(e:Event):void {
//Tween the item's properties
TweenMax.to(e.target, 1, {alpha: 0.3, glowFilter:{color:0xffffff, alpha:1, blurX:0, blurY:0},blurFilter:{blurX:1, blurY:1}});
//This function is called when an item is clicked
function itemClicked(e:Event):void {
//Navigate to the URL that's assigned to the menu item
var urlRequest:URLRequest=new URLRequest(e.target.linkTo);
navigateToURL(urlRequest);Hi Ned thanks for the reply,
Ok so I have a button in my main movie that loads the external swf
stop();
var my_loader:Loader = new Loader();
var my_btn:Button = new Button();
var my_pb:ProgressBar = new ProgressBar();
my_pb.source = my_loader.contentLoaderInfo;
my_btn.addEventListener(MouseEvent.CLICK,startLoading);
function startLoading(e:MouseEvent):void{
my_loader.load(new URLRequest("carousel.swf"));
addChild(my_pb);
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishloading);
function finishloading(e:Event):void{
addChild(my_loader);
my_loader.addEventListener("killMe",
killLoadedClip);
removeChild(my_pb);
function killLoadedClip(e:Event):void {
my_loader.removeEventListener("killMe",
killLoadedClip);
my_loader.unloadAndStop();
removeChild(my_loader);
Then I have a button in my loaded swf that closes the loader
This is spread over 2 frames
Frame1
function closeIt(e:MouseEvent):void {
parent.dispatchEvent(newEvent("killMe"));
Frame 2
back_btn.addEventListener(MouseEvent.CLICK, closeIt);
Frame 2 also holds all the code for the carousel
Thanks for your time and help in advance people ; ) -
Map and externally loaded swf working together
Here's the setup:
I have a panoramic viewer, and i'd like to have a map go
along side it. The panoramas are loaded externally into the player.
Inside these external swf files are "hotspots" that link to other
panoramic swf files that load and take the previous swf's place. I
have all of this set up, and you can see how I did it in my
previous post:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1274410&enterthread=y
So now my new question is... how can I have a map with points
on it, that when you click on a point, it will load a corresponding
swf file into the player. I believe that part is easy. My big
problem is if someone clicks on a hotspot in the external swf file
first, which in turn loads another swf file, and if that person
goes back to the map, I want the map to change the position of lets
say, a marker or a pin to indicate the new position on the map that
correllates to the new external swf that was loaded.
make sense? Any ideas? I was thinking maybe it would be some
kind of listener or something so that should a specific swf load,
it will recognize it and automatically change the location of the
marker on the map to the point that relates to the loaded swf or
something...Hi Thanks for your reply, I tried with a small AS3 file as
well and I get the same ERROR. -
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. -
Control the property of an object in main stage from a loaded swf timeline
please someone help me here, im loosing my mind
i have a UILoader that loads an image from an xml list when you click its thumbnail ( in its thumbnails mc on mainstage aswell)
thing is, i have another UILoader on the layer above that loads in a swf ( a slideshow that fades in and out the pictures when they change to the next,
with all the coding on frame 1, frame 2 only has a stop and some code for when the mouse is idle for 5 secs it goes back to frame 1)
so when you go to "portraits" it takes you to frame "x" where the slideshow ( loaded external swf ) starts playing automaticly right,
if i click any thumbnail the slideshow goes to frame 2 ( wich is perfect and the mouse idle thing i wanted works great ) the ONLY THING IS
after the slideshow runs by default for the first time ( i enter the category portraits )
and i click any thumbnail ( moving slideshow swf to frame 2 enabling mouse idle event )
and the mouse is idle ( so it does the event and starts playing the slideshow again ( goes back to frame 1 ) )
I CANT MAKE THE UILOADER OF THE THUMBS IMAGE TO DISSAPPEAR!!!
i have tried everything i can think of and everything i have read trying to adapt it with what i know,
im no guru at this i reeeeally need some help
THANK YOU SO VERY MUCH !and where would i put the remove.simpleScreen ( simpleScreen is the loader i would want to remove )
would it be on the external swf on frame 1 where the slideshow plays?
or in the main timeline's category's frame?
the problem ( that i see ) is that both loaders are on the same frame ( different layers tho )
so if i put a the remove simplescreen there it wont show me the pictures when i click the thumbs
or could i make it so that it removes it BECAUSE its playing on frame 1 ? -
How to access properties of symbols in loaded SWF?
I'm making the migration from Flash to Flex, but I'm running
into a dead end on one particular area: accessing and manipulating
properties of symbols in a loaded SWF.
The SWF is actually a simple library of a detailed parts
illustration. I would like to load the entire SWF in position, and
be able to change the attributes (i.e. colors) of individual
symbols (or parts of the illustration). I can load, display and
manipulate each symbol separately, but I need the parts to remain
in place.
The original art was created in Illustrator and exported as
SWF using the symbols palette.
I can always go back to Flash, but I'm forcing myself to move
forward and do this project in Flex (baptism by fire!!).
Is there some sort of dot notation to access the symbols from
within the SWF, without loading them all separately?
Let me put this another way: it appears that I can load an
SWF and then instantiate each symbol in that SWF, and then load
each symbol to the 'stage' (or whatever it's called in Flex)
separately.
I can certainly instantiate each symbol separately, and then
align it on stage, but it seems to me to be bass-ackward to do it
that way, expecially since I created the original SWF with
everything in position.
Is there no way to access the attributes of the individual
symbols within an SWF without separately instantiating them?
I'm just having trouble getting my head around this. Any help
is greatly appreciated.Okay, I took a look at this info and it's what I was already
doing.
Here's a simplified example of what I'm trying to do, using
the example in the swf9.pdf file.
Let's assume I've created a SWF with a "BlueSquare" movieclip
(in the symbols panel in Flash, exported for AS). In that clip,
there is another symbol called "Star". I import the SWF and
BlueSquare symbols in with the following code:
<mx:Script>
<![CDATA[
[Embed(source=”../assets/circlesquare.swf”)]
[Bindable]
public var LogoCls:Class;
[Embed(source=”../assets/circlesquare.swf”,
symbol=”BlueSquare”)]
[Bindable]
public var LogoClsBlueSquare:Class;
</mx:Script>
If I instantiate the BlueSquare on stage, it includes the
Star symbol when previewed, but I can't figure out how to get at
the Star symbol to change color. If I apply a color change to the
symbol, it changes the entire BlueSquare symbol.
If I instantiate the Star symbol separately, I can then
position it on the stage and make changes, but that requires
positioning it with actionscript. I'm trying to not have to
position a sub-element of my actual artwork because of it's
complexity.
I'd like to display the main movieclip (or sprite) with the
ability to access the attributes of a sub-movieclip or
sprite. -
Small Bug in Flash 8: loading swf that´s a vectorized image in many layers
Hi! There´s a small bug in flash 8. If you load a swf
that it´s a vectorized image in many layers, when you give it
an action in onLoadInit, like mc.onRelease, the mc don´t
"catch" that action. You can try loading an image (it works), a lot
of swf (it works), but with this kind of swf the actions onRelease,
onPress, etc... don´t work.
The
swf
I´ll make a different vectorized image to make it works
(if there is only one layer it works)Seems odd it will only run once. Usually if a cache problem
you get the same
results even when you update the movie or server scripts.
If it is
http:// it is not local even if from the browser
cache.
Verify the html is validated.
Check to see if this applies to all swfs. Create a simple
hello world swf
that connects to a JSP script that returns a simple value to
Flash. If that
seems to work, then the problem is in the JSP or
Actionscripting coding.
Check you can load the JSP script repeatedly using a direct
call to it on
the browser line using
http://.
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"srikanth_s_india" <[email protected]> wrote
in message
news:e6obld$lfb$[email protected]..
> Thanks for the article link.
>
> I can't provide the URL as it is within our application
which requires
> logging
> in. However, one more interesting thing about it is that
it always works
> for
> the first time (in the browser/machine) but not from the
next time.
>
> My doubt is whether it is because of the caching? When
it loads for the
> first
> time, the HTML and SWF files load from our server and
hence are allowed to
> communicate with our JSP. However, when it loads the
subsequent times, it
> probably loads from the cache and hence considered as a
local file and not
> allowed to communicate with our JSP file which is on the
Internet.
>
> Can anybody tell me how to enable a local SWF file to
load SWF files from
> the
> Internet & access URLs from the Internet in Flash 8
pluggin?
> -
TypeError: Error #1009 (loaded SWF)
I'm pulling out my hair on this one!
I'm just starting a site (full-Flash site) using CS3 and AS3.
I'm pretty much accustom to the new AS3 changes. I built a rough
structure to make sure the way I wanted to set the site up would
work (loading in external SWFs, etc.). The tests worked.
Now, I'm going in to make some things real, and I'm getting
this error as soon as an external SWF loads in:
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at test_fla::MainTimeline/test_fla::frame2()
I've tried narrowing it down, couldn't find the exact culprit
(had to remove every ounce of ActionScript before it started to
function again). So I started to rebuild that movie entirely --
cleared out the Library and deleted every layer. Didn't work.
Couldn't even add a stop(); action in Frame 1.
Then I started completely fresh File > New, rebuilt again.
I tested after every single change. I finally built it up to the
point where I first tested the original, and it worked. So, then I
added a couple more things tested again, and got the error again.
Ahh, so I removed EXACTLY what I had just added. Tested again. SAME
ERROR -- now it won't go away no matter what I remove!
Crazier yet is that I can still load in my other test SWF
files and they have actions in them, and they're set up the exact
same way -- but they work...
The whole site is new, so every SWF is CS3/AS3. I'm not even
doing anything crazy, so I'm getting pretty frustrated trying to
build an all AS3 site and I can't even do basic stuff....
I can upload/email the FLA files in question if anyone has
time to look...
Thanks,
BrandonWell, when I test the loaded SWF within the Flash environment
(by itself), it plays just fine.
Then, I try to play the root containing movie (both within
Flash and on the web server) and as soon as that section loads, is
when the error occurs.
I've tried tracing everything. even down to putting trace()
actions between every layer. Can't determine what causes it...
One thing I noticed (but I assume is a naming convention that
Flash uses), is in the error above you see "test_fla", well, lets
say I have these files:
test-container.fla
test-home.fla
I don't have a test_fla, but the error code refers to it
anyway... -
Setting External Loaded SWF dimension
hi guys...,
i'll be straight to point,well i'm now working on a project using action script 3 now what i'm trying to make is a Main SWF that load whatever other swf into it the tricky thing is that i used 1 xml document read the external swf source and it's setting(such as it's x,y position and it's width and height) and i'm having problem setting the loaded swf width and height btw it's an desktop application and not a website application.,
here is my code:
//variable list
var swfList:XMLList; //hold all the zone list from the xml
var totalZone:uint; //total of zone there is in the xml
var myURLLoader:URLLoader = new URLLoader();
var swf:Movie Clip;//hold the loaded swf
var swfLoader:Loader = new Loader();//loader instance used to load the external swf
var myCounter:uint = 0;
//load the xml file
myURLLoader.load(new URLRequest('myXMLFile.xml'));
myURLLoader.addEventListener(Event.COMPLETE, processXML, false, 0, true);
function processXML(e:Event):void
removeEventListener(Event.COMPLETE, processXML);
XML.ignoreWhitespace= true;
var myXML:XML = new XML(e.target.data);
swfList = myXML.SWF;
totalSWF = myXML.SWF.length();
loadSWF();
function loadSWF():void
swfLoader.contentLoaderInfo.addEventListener(Event.INIT, swfSetting);
swfLoader.load(new URLRequest(swfList[myCounter].@source));
function swfSetting(e:Event):void
//making new instance of sprite to hold the new loaded swf
swf = new MovieClip();
//casting the loader content into a movieclip
swf = e.target.content;
addChild(swf);
swfLoader.unload();
swf.x = swfList[myCounter].@left;
swf.y = swfList[myCounter].@top;
swf.width= swfList[myCounter].@width;
swf.height= swfList[myCounter].@height;
addChild(swf);
if(myCounter < totalSWF)
myCounter++;
trace('myCounter: ' + myCounter );
loadSWF();
and here is what the result ( it make the width and height of the loaded swf to 0):
swfLoader.contentLoaderInfo.width : 320
swfLoader.contentLoaderInfo.height : 240
module: MyVideo/flvplayer.swf
x:0
x container:0
y:0
y container:0
xml width:550
width container:0
xml height:400
height container:0
myCounter: 1
swfLoader.contentLoaderInfo.width : 550
swfLoader.contentLoaderInfo.height : 400
module: AnalogueClock.swf
x:50
x container:50
y:0
y container:0
xml width:250
width container:250
xml height:200
height container:200
myCounter: 2
swfLoader.contentLoaderInfo.width : 800
swfLoader.contentLoaderInfo.height : 30
module: MyNewsticker/newsticker.swf
x:0
x container:0
y:0
y container:0
xml width:300
width container:0
xml height:50
height container:0
most of my loaded swf beside the analouge clock is full action script code and in case of the analouge clock it is a swf that has a movie clip on it's stage (the other are fully created from action script 3.0)
please do help me..,
cause i'm already really desperate and going crazy by this problem..,sorry i copied the code from the other swf i used to do try and error test..,
basically the container is the same as swf varibale
here the code so you would'nt get confused:
//variable list
var swfList:XMLList; //hold all the zone list from the xml
var totalZone:uint; //total of zone there is in the xml
var myURLLoader:URLLoader = new URLLoader();
var swf:Movie Clip;//hold the loaded swf
var swfLoader:Loader = new Loader();//loader instance used to load the external swf
var myCounter:uint = 0;
//load the xml file
myURLLoader.load(new URLRequest('myXMLFile.xml'));
myURLLoader.addEventListener(Event.COMPLETE, processXML, false, 0, true);
function processXML(e:Event):void
removeEventListener(Event.COMPLETE, processXML);
XML.ignoreWhitespace= true;
var myXML:XML = new XML(e.target.data);
swfList = myXML.SWF;
totalSWF = myXML.SWF.length();
loadSWF();
function loadSWF():void
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfSetting);
swfLoader.load(new URLRequest(swfList[myCounter].@source));
function swfSetting(e:Event):void
//making new instance of sprite to hold the new loaded swf
swf = new MovieClip();
//casting the loader content into a movieclip
swf = e.target.content;
addChild(swf);
swfLoader.unload();
swf.x = swfList[myCounter].@left;
swf.y = swfList[myCounter].@top;
swf.width= swfList[myCounter].@width;
swf.height= swfList[myCounter].@height;
addChild(swf);
if(myCounter < totalSWF)
myCounter++;
trace('myCounter: ' + myCounter );
loadSWF();
well in my code i did cast the loader into a movie clip and then set it's width and heigt,right???
wouldn't it just give me the same result??
if it's not can u describe what u mean in more detail??
some example about accessing the loader content would be really appreciated -
(MX04) Pausing a loaded swf with sound objects within it
Hi,
I'm working on a PowerPoint-esque presentation where a user
watches and listens to a loaded swf in the main movie, clicks the
next button (which unloads the swf, advances to the next frame and
loads the next swf), and watches the next one. Lather, rinse,
repeat. Some of the sections are rather long, and I'd like to give
the user the ability to pause and play by button click.
I know how to stop and start the container MC, but that
doesn't stop the sound object (and the embedded MCs). I also know
how to pause and start a sound object using the object's instance
name. Is there a way to pause everything from the main timeline,
and keep the AS general enough so that any sound object pauses when
clicked?
Any help is most appreciated! MX04 and AS2.0.
Thanks!Kglad,
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 swf into movieclip // play pause buttons
I am going out of my mind trying to get this to work. I can do it in AS2 without a hitch - but not AS3.
I just need to load an external swf file into an empty movieclip. Then I have 2 buttons play and pause that need to be on the top layer of the new movie and they need to play and pause the loaded swf file.
I have tried a number of things and nothing is working. Please help.
Thank you in advance.
Shawnayou can use:
var ldr:Loader=new Loader();
addChild(ldr);
ldr.load(new URLRequest("yourswfthatyouwanttoload.swf"));
addChild(yourplaybtn);
addChild(yourpausebtn);
yourplaybtn.addEventListener(MouseEvent.CLICK,playF);
yourpausebtn.addEventListener(MouseEvent.CLICK.pauseF);
function playF(e:Event){
MovieClip(ldr.content).play();
function pauseF(e:Event){
MovieClip(ldr.content).stop(); -
Hallo everybody,
I am a new Flash user so please forgive me if my question is
a bit "simple". I want to obtain a flash button that can load SWF
file on stage in a precise position without taking tha button
place. As example please click www.suit-e.de . I have read about
loadMovie e loadMovieNum but I do not not if I am in the right
place. Thank youTo do that you need to design the whole website using the
keyframes and some tweening technics, you dont really need much
complicated actionscript/loadmovie etc. Get to know alittle more
about tweening and using the keyframes plus imagination.
Good luck. -
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
Maybe you are looking for
-
Error while creating presentation variable in Dashboard prompts.
Hi Team I have been going through the guidelines and procedures to create a presentation variable to use it in the dashboard prompt ( mentioned in the previous blogs ) .I followed the below link : http://oraclebi.blog.com/example-of-presentation-vari
-
Using quicktime 7.6.9 h264 compression_flicker is introduced
Using quicktime 7.6.9 h264 compression_ a flicker is introduced into one scene in my film -- tried multiple settings, and getting the same issue. Color and brightness shift between frames -- but only in 1 shot/scene. Using quicktime version 10.1 (
-
Hi all! How can I define message time-to-live in queue? I've got some messages in queue with expiraton date by the year 2038.
-
Opening a link in a specific window size - RH7, WebHelp
I was given the answer to this recently, but I accidentally erased it and now can't find it again. If someone can give it to me again, I promise to save it somewhere safe! I have a link that opens a new window that needs to be a specific size, witho
-
TS1398 my wi fi on my i touch 3rd gen will not respond any suggentions as what to do?
need help with i touch 3rd generation wi fi is grey and will not respond, any suggestion?