Loaded .swf in wrong place
hello,
i have saved "TestClass2" and "one.swf" in the same folder,
and made TestClass2 the class of a movieClip within "one.swf".
On the last frame of the timeline of "one.swf", I have a
boolean variable called endFrame, which the function onEnter is
listening for.
When endFrame = true, the loader loads in "two.swf", but it
is not directly on top of "one" as I had hoped.
Please, what am I doing wrong? Is my strategy at all correct
in general? Thank you.
Thank you.
I changed addChild(imageLoader);
to stage.addChild(imageLoader);
and it works.
is that the correct way to do it?
also, is function loadTwo within function onEnter? Because
when I write "private", Flash gives me an error. Should it be
within onEnter, or outside of it somehow?
much appreciated.
RW
Similar Messages
-
I have finally figured out how to call an external swf file
(shouldn't have been as hard as I made it) Nonetheless, when I
preview is, besides getting a bunch of errors about sandboxes, the
external swf file is not anywhere close to where I placed the movie
clip loader? Thanks for any help anyone can provide...Well, I guess I can place my movie container somewhere
completely different from where I want it to appear on my final swf
file. I don't think that's the most elegant way to go about it, but
one question I do have is how to I keep the bitmap images that are
off that swf file not to appear, and to make it not scale? Right
now, when the external swf file comes on screen, excess parts of
the image appear and it scales? Thanks. -
Trying to call a root level function from within a loaded swf
I'm not very familiar with AS3... I'm trying to have a loaded swf file call a function from the parent to unload itself when it comes to the end (on the timeline, not as a button). I'm assuming I need to be calling the function (that is used for the close button) from the loaded swf (perhaps I'm mistaken though?).
Here's the code from one of my buttons that loads an swf. I'm guessing I need to call the closeSWF function from the timeline of my loaded movie but having no luck figuring out how to do that.
Any help would be appreciated.
// 01 ------------------------------------------------------
function loadWeaving(ev:MouseEvent):void {
// load SWF
var movieClip:MovieClip = new holder_mc;
//add it to the stage
addChild(holderSWF);
holderSWF.x=0;
holderSWF.y=0;
var requestEN:URLRequest = new URLRequest("WhatIsWeaving_Eng.swf"); // english
holderSWF.load(requestEN);
close_bt.addEventListener(MouseEvent.CLICK, closeSWF);
function closeSWF(infoObject:Object):void {
trace("close SWF");
removeChild(holderSWF);
// reset switch
close_bt.visible = false;
showAllButtons();
infoObject.currentTarget.removeEventListener(infoObject.type, closeSWF);
setChildIndex(close_bt,numChildren - 1);
close_bt.visible = true;
hideAllButtons();
// - start timer last
myTimer.addEventListener(TimerEvent.TIMER, closeSWF);You're exactly right. If you attach an event listener to the Loader before you add it to the stage, you can then use event.currentTarget to refer to the loader. And this is definitely the better way to do it if you're planning to use the loaded swf from multiple places or could ever need to do this in the future.
So:
protected function initLoader():void {
var loader:Loader = new Loader();
loader.addEventListener('closeMe', closeLoader);
loader.load(new URLRequest(...));
addChild(loader);
protected function closeLoader(e:Event):void {
var loader:Loader = e.currentTarget as Loader;
if (loader) {
loader.unloadAnstop(true);
loader.removeEventListener('closeMe', closeLoader);
removeChild(loader); -
Externally loaded swf in second window doesn't display properly?
I have a bitmap based flash game (bitmapdata generated screen) that I'm trying to load in to a secondary nativewindow generated from a main flash (not AJAX/HTML) based AIR app that's a graphical menu. I.E. you click on a selection in the menu, and it pops open a secondary nativewindow with the flash game running in it. The problem is, the game itself gets mangled in the secondary window when it loads in. Keyboard input goes away, the bitmap doesn't draw properly (it streaks like its not drawing the background image each frame), most of the game objects its supposed to draw in to the bitmap are missing, etc.
When I make the game itself in to its own AIR app and run it direct, it works just fine. So I'm puzzled. Is there some kind of special coding considerations in the as3 side that I'm missing with the original game? I.E. if a flash based AIR app launches another nativewindow and loads a swf in to that, does it share some kind of variable set, display list, etc. with the calling window? Something else? Any help would be appreciated.There are a few differences between (A.) letting the AIR runtime load content into the initial window and (B.) loading content into a new NativeWindow.
1. In case A, the stage property is available in the class constructor for the main sprite. In case B, this is not the case. You may have to use an ADDED_TO_STAGE event handler to do some class initialization.
2. In case A, the initial scale is based on the metadata present in the SWF -- this results in the behavior you would expect. In case B, there is no SWF to base the scale on when the window is created, so a default scale is used -- this is rarely results in behavior you would expect (unless the window happens to be created with a size of 72x72 pixels).
If you aren't setting the stage to noScale, then this could account for some of the visual issues. (See http://www.adobe.com/devnet/air/flex/quickstart/launching_windows.html for an explanation of the scaling issues.) The easiest thing to do is to set the Stage scaleMode to noScale and the align property to the top left setting. I'm guessing your drawing code isn't expecting the scaling so things are getting put in the wrong place.
3. In case A, the content is automatically put in the application sandbox. In case B, it depends on the URL.
As for the Keyboard input, this may depend on how you are loading the SWF and from where. This could be related to #3 above, although I would expect to see security errors. How are you adding your keyboard event handlers? -
Loaded SWF file CANNOT be made into button DIRECTLY?
I'm experiencing a problem which may have no solution, but I
would like to know why I cannot do what I want to do.
PROBLEM:
I am attempting to load in an external SWF file and once it
is loaded, I wish to directly make the new Sprite/MovieClip into a
button. However, the newly loaded Sprite/MovieClip seems to be
resistant to be made into a button DIRECTLY. I would like to know
why this is.
WORKAROUNDS:
Here are a couple of workarounds, but again I wish to know
why I cannot do what I want to do.
1) I place the new Sprite/MovieClip into an empty Sprite on
stage and make the once empty sprite into a button.
2) Construct the external SWF in such a way so i can refer to
a MovieClip within the SWF file and make that MovieClip into a
button.
CODE EXAMPLE:
I am loading a SWF file thru a Loader and then taking the
loaded SWF file and adding it to an existing sprite on the stage. I
then attempt to make a button out of the newly loaded swf file, but
it fails to be clickable.
The following is some quick code to illustrate my problem. I
already have workarounds in place, so please let me know WHY the
following code is impossible. thanks!
==============================================================================There should be no problem with what you are trying to do. If
you want someone to look at what you've done, you have to be
careful to show that and not possibly errant code because that is
the substance of your post and what you requested be looked at--we
cannot guess what you may have done wrong in setting things up or
for code that you do not show.
I tried your code before posting my response and it worked
fine except for your error with the COMPLETE aspect. I did not
utilize any objects for loading things into, so I suggest you look
there. -
Moving the timeline from a loaded swf file
Hi,
I have been at this problem for awhile now.
I have a two swf files, whic are loaded using ths code as an example:
stop();
var req:URLRequest = new URLRequest("Enchilada_A.swf");
var loader:Loader = new Loader();
function imageLoaded(event:Event):void {
ldContainerB.addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.load(req);
The first one is triggerrd by a MC button that is on the timeline.
That first swf loads fine.
At the end of that file(which is short animation)
I have code that says:
MovieClip(parent).gotoAndStop("frameThree");
I have also tried:
MovieClip(root) and
if (movie Clip is parent) {
MovieClip(parent).gotoAndStop("frameThree");
and/MovieClip(parent).nextFrame();
I have also tried placing this. or root. into the code.
I am not talking to the timeline from this swf file.
Once the timeline moves to the next Frame the new swf file can load.
My solution was to combine both swf files into one, which loads from the timeline button.
It works and I can gt by but I really woud like to learn how to load a swf and talk to the timeline fro more flexibilty.
I'm out of strategies.
Is my code in the wrong place(at the last frame of the animation?
Should it be written on the timeline by creating a new var that has a function once the animation is completed.
Any suggestions and/or commens would be greatly appreciated.
Thanks.Thanks,
I finally had a chance to get back to this project and used your suggestions, whichare definitiley helpful. I also, created a new and very basic version of the project so I could easily see what was happening.
This is the code that works:
stop();
MovieClip(parent.parent).nextFrame();
trace(container_mc);
I'm still trying to understand how the child parent relationship is working but this will get me going in the right direction. -
I have logic pro, soundtrack pro will not open i get an error message what do i do? i cant find the receipts ive checked my library am i looking in the wrong place?
I get the same kind of thing..
I'm on osx 10.7.2 and once I click the soundtrack pro icon I get an error message. I had problems with logic pro & my digi002r soundcard midi drivers but now is fixed (using a midi adapter).
here is the code:
Process: Soundtrack Pro [1705]
Path: /Applications/Soundtrack Pro.app/Contents/MacOS/Soundtrack Pro
Identifier: com.apple.soundtrackpro
Version: 3.0.1 (960)
Build Info: SoundtrackProProject-9600000~277
Code Type: X86 (Native)
Parent Process: launchd [140]
Date/Time: 2011-10-18 13:12:05.201 +0200
OS Version: Mac OS X 10.7.2 (11C74)
Report Version: 9
Interval Since Last Report: 195725 sec
Crashes Since Last Report: 3
Per-App Crashes Since Last Report: 2
Anonymous UUID: 23728D81-590B-4C3A-8C67-1709945CD132
Crashed Thread: 0
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Application Specific Information:
dyld: launch, loading dependent libraries
Dyld Error Message:
Library not loaded: /Library/Application Support/ProApps/*/ProFX.framework/Versions/A/ProFX
Referenced from: /Applications/Soundtrack Pro.app/Contents/MacOS/Soundtrack Pro
Reason: image not found
Binary Images:
0x1000 - 0x7f7ff8 com.apple.soundtrackpro (3.0.1 - 960) <77CF322B-8BBE-AAEA-173F-75A237035319> /Applications/Soundtrack Pro.app/Contents/MacOS/Soundtrack Pro
0x947000 - 0x94bfe6 +STPInterleave (??? - ???) <E87D1F34-6D97-63DB-454C-CF3D1B03F8E5> /Applications/Soundtrack Pro.app/Contents/Frameworks/STPInterleave.framework/Versions/A/STPInterleave
0x952000 - 0x98ffff com.apple.vmutils (4.2.1 - 107) <43B3BFA5-8362-3EBD-B44B-32DCE9885082> /System/Library/PrivateFrameworks/vmutils.framework/Versions/A/vmutils
0x9a9000 - 0x9f5ffb com.apple.audio.midi.CoreMIDI (1.8 - 42) <CBD34EBC-0FFD-34B4-B55A-BE1F61EF4BD8> /System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI
0xa18000 - 0xc3eff7 com.apple.prokit (7.1.1 - 1511) <498819A4-1BDD-3671-8796-E11865BCFBCE> /System/Library/PrivateFrameworks/ProKit.framework/Versions/A/ProKit
0xd49000 - 0xd49fff com.apple.iokit.dvcomponentglue (2.0.7 - 2.0.7) <1CFA5944-AB33-3A41-B4D2-4A624A514C0D> /System/Library/Frameworks/DVComponentGlue.framework/Versions/A/DVComponentGlue
0xd4d000 - 0xd54fff com.apple.AEProfiling (1.2 - 22) <43A46C32-8E13-82DD-8AF1-2A40690BF810> /Applications/Soundtrack Pro.app/Contents/Frameworks/AEProfiling.framework/Versions/A/AEProfiling
0xd5e000 - 0xd6dfff com.apple.AERegistration (1.2 - 77) <5D18C47F-6F9E-0C4C-8875-24A14A97186D> /Applications/Soundtrack Pro.app/Contents/Frameworks/AERegistration.framework/Versions/A/AERegistration
0xd81000 - 0xd83fff com.apple.ExceptionHandling (1.5 - 10) <6CA9446C-7EF9-35EE-BDF2-AA8D51E93E9E> /System/Library/Frameworks/ExceptionHandling.framework/Versions/A/ExceptionHand ling
0xd89000 - 0xe49fff com.apple.omf_framework (1.1.0 - 1.0) <ED5F21BC-18CD-D7F7-3D2E-F7F856BC0D40> /Applications/Soundtrack Pro.app/Contents/Frameworks/OMF.framework/Versions/A/OMF
0x11000000 - 0x1102afeb com.apple.proapps.ControlSurfaceSupport (2.0 - 68) <BD914236-49D8-9C9A-E8D6-CBC1738850B3> /Applications/Soundtrack Pro.app/Contents/Frameworks/ControlSurfaceSupport.framework/Versions/A/ControlS urfaceSupport
0x8fe88000 - 0x8feba9c7 dyld (195.5 - ???) <134323A7-49DC-3A9D-ACFD-32FAD0FD6BA2> /usr/lib/dyld
0x90840000 - 0x90992fff com.apple.audio.toolbox.AudioToolbox (1.7.1 - 1.7.1) <7646E131-08EE-3D72-ADA2-4A61C562B36E> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x90993000 - 0x90993ff2 com.apple.CoreServices (53 - 53) <7CB7AA95-D5A7-366A-BB8A-035AA9E582F8> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x91e60000 - 0x92036fe3 com.apple.CoreFoundation (6.7.1 - 635.15) <AC9F6462-6315-3D89-8075-D048DB4DBF7E> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x924a8000 - 0x92509ffb com.apple.audio.CoreAudio (4.0.1 - 4.0.1) <089D78E0-46A6-38DB-9545-7F35CC815939> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x93281000 - 0x9328ffff com.apple.opengl (1.7.5 - 1.7.5) <81166D23-DE8E-3938-AAD3-29B1FA5E446E> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x93331000 - 0x93331fff com.apple.vecLib (3.7 - vecLib 3.7) <8CCF99BF-A4B7-3C01-9219-B83D2AE5F82A> /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
0x93332000 - 0x93493ffb com.apple.QuartzCore (1.7 - 270.0) <0916DA83-6400-3FEA-BC53-5F4BA4D126EC> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x94326000 - 0x9436dfff com.apple.SystemConfiguration (1.11.1 - 1.11) <CA6CE2B6-DC18-31FF-9668-70BB2FD8D7BB> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfi guration
0x94420000 - 0x946a5fe3 com.apple.QuickTime (7.7.1 - 2306) <F8C64DC4-3FE4-3A06-B10B-59E7F3BA6FDD> /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
0x97dd0000 - 0x98082ff7 com.apple.security (7.0 - 55010) <BE0350C5-5221-3BFF-B674-646AB1BA0F2E> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x99d12000 - 0x99d76fff com.apple.framework.IOKit (2.0 - ???) <D14460ED-2B6C-375D-B3A4-B8C82E922666> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x9adc8000 - 0x9adc8fff com.apple.audio.units.AudioUnit (1.7.1 - 1.7.1) <2E71E880-25D1-3210-8D26-21EC47ED810C> /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x9aef1000 - 0x9aef1fff com.apple.Carbon (153 - 153) <6FF98F0F-2CDE-3888-A304-4ED447D24CE3> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x9b2ec000 - 0x9b2ecfff com.apple.Cocoa (6.6 - ???) <650273EF-1ABC-334E-B745-B75AF028F9F4> /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
Model: iMac12,1, BootROM IM121.0047.B0A, 4 processors, Intel Core i5, 2.5 GHz, 4 GB, SMC 1.71f21
Graphics: AMD Radeon HD 6750M, AMD Radeon HD 6750M, PCIe, 512 MB
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1333 MHz, 0x02FE, 0x45424A3231554538424655302D444A2D4620
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1333 MHz, 0x02FE, 0x45424A3231554538424655302D444A2D4620
AirPort: spairport_wireless_card_type_airport_extreme (0x168C, 0x9A), Atheros 9380: 4.0.58.4-P2P
Bluetooth: Version 4.0.1f4, 2 service, 18 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en1
Serial ATA Device: WDC WD5000AAKS-402AA0, 500,11 GB
Serial ATA Device: HL-DT-STDVDRW GA32N
USB Device: hub_device, 0x0424 (SMSC), 0x2514, 0xfa100000 / 3
USB Device: USB to Serial-ATA bridge, 0x04fc (SUNPLUS TECHNOLOGY CO., LTD.), 0x0c25, 0xfa120000 / 6
USB Device: iLok, 0x088e, 0x5036, 0xfa130000 / 5
USB Device: BRCM2046 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0xfa110000 / 4
USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x8215, 0xfa111000 / 7
USB Device: FaceTime HD Camera (Built-in), apple_vendor_id, 0x850b, 0xfa200000 / 2
USB Device: hub_device, 0x0424 (SMSC), 0x2514, 0xfd100000 / 2
USB Device: UM-2G, 0x0582 (Roland Corporation), 0x0106, 0xfd140000 / 5
USB Device: IR Receiver, apple_vendor_id, 0x8242, 0xfd120000 / 4
USB Device: Internal Memory Card Reader, apple_vendor_id, 0x8403, 0xfd110000 / 3
FireWire Device: Digi 002Rack, Digidesign, 400mbit_speed
thanks everyone
e -
How to effectively remove a loaded SWF from the stage?
I can not figure out a proper coding to remove a loded SWF from the stage.
Here is my set up.
I have a layout segmented into labeled section. In the section labeled "products" I have a layout consisting of product images acting as buttons which bring a user to another labeled section "prdctsPopUps"
In the "prdctsPopUps" section I have placed an instance of LoaderMax placed into an mc container. Placing LoaderMax into an mc container automatically resolved an issue of clearing loaded SWFs from stage when I come back to "products" section.
I specified the variable in the "products" section with the following set up:
var sourceVar_ProductsPopUps:String;
function onClickSumix1PopUp(event:MouseEvent):void {
sourceVar_ProductsPopUps="prdcts_popups/sumix1-popup_tl.swf";
gotoAndPlay("prdctsPopUps");
So each button has its own "....swf" URL and they all open fine and I can come back to "products" section without any issues.
However inside the swf (which loads through LoaderMax which is placed into an mc) there are other buttons which bring a user to labeled section "xyz". Which also functions properly. It opens as it is supposed to be and without any previously loaded "...swf" on the stage.
At the labeled section "xyz" there is a limited set of buttons repeating from section "products" which has to bring a user back to the same set up in the "prdctsPopUps" labeled section and open a corresponding "...swf" .
However only the last opened "...swf" will appear in that section. Effectively the one which was originally opened from the "prdctsPopUps" section and not the one which was supposed to be opened from the "xyz" section.
I can not understand why it would work from one labeled section and not from another. I can not figure out on which section which code/function needed to be placed.
Here is the set up from a button from the "xyz" section whcih supposed to bring a user to the same "prdctsPopUps" section but to load a different "...swf"
var sourceVar_ProductsPopUps_fromXYZ:String;
function onClick_floralytePopUp_fromXYZ(event:MouseEvent) :void {
sourceVar_ProductsPopUps_fromXYZ="prdcts_popups/floralyte-popup_tl.swf";
gotoAndPlay("prdctsPopUps");
Here is the code set up for the LoaderMax from the "prdctsPopUps" section:
var loaderProductPopUps:SWFLoader = new SWFLoader(sourceVar_ProductsPopUps,
estimatedBytes:5000,
container:holderMovieClip,
onProgress:progressHandler,
onComplete:completeHandler,
centerRegistration:true,
alpha:1,
scaleMode:"none",
width:540,
height:730,
crop:true,
autoPlay:false
function progressHandler(event:LoaderEvent):void{
progressBarPopUp_mc.gradientbarPopUp_mc.scaleX = loaderProductPopUps.progress;
function completeHandler(event:LoaderEvent):void{
var loadedImage:ContentDisplay = event.target.content;
TweenMax.to(progressBarPopUp_mc, 1.5, {alpha:0, scaleX:0.25, scaleY:0.25});
loaderProductPopUps.load();
Is there something which needs to be imported, or specific function needs to be specified in a specific labeled section?actually, i think you'll need to use something like:
var loaderProductPopUps:SWFLoader;
if ((loaderProductPopUps){
if(loaderProductPopUps.content)){
loaderProductPopUps.unload();
loaderProductPopUps= new SWFLoader(sourceVar_ProductsPopUps, //the value of sourceVar_ProductsPopUps allows to load mulitple SWFs from the products page.
estimatedBytes:5000 ,
container:holderMov ieClip,// more convinient and easier to manage if to place the LoaderMax into an empty mc (holderMovieClip)
// if not will work as well. Then the line container:holderMovieClip, has to be replaced with container:this,
// can be any size, can not be scaled as it distorts the content
onProgress:progress Handler,
onComplete:complete Handler,
centerRegistration: true,
//x:-260, y:-320, //no need for this is if used: centerRegistration:true,
alpha:1,
scaleMode:"none",
//scaleX:0, scaleY:0,
//vAlign:"top",
width:540,
height:730,//scales proportionally but I need to cut off the edges
crop:true,
autoPlay:false
function progressHandler(event:LoaderEvent):void{
progressBarPopUp_mc.gradientbarPopUp_mc.scaleX = loaderProductPopUps.progress;
function completeHandler(event:LoaderEvent):void{
var loadedImage:ContentDisplay = event.target.content;
//TweenMax.to(loadedImage, 1.5, {alpha:1, scaleX:1, scaleY:1});//only need this line if corresponding values are changed in SWF loader constructor
TweenMax.to(progressBarPopUp_mc, 1.5, {alpha:0, scaleX:0.25, scaleY:0.25});
loaderProductPopUps.load(); -
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. -
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. -
Loader component loading swf bigger as it is?
Im loading second.swf in main swf using a loader component,
second swf is has a stage size of 800*85, i load it in a
component with the same size, and scaleContent = true
This goes wrong, after investigating second.swf it actualy
has a stage size but some components on the size like a textfield
goes beyond the stage (which is necesarry to be able to load enough
text in it (it starts scrolling then to be visible on stage), when
i test second.swf, i get a 800*85 swf.
But when i include it in an other swf and autoscale it, it
seems like flas includes the objects outside the stage from
second.swf to do the scaling.
Ideas to avoid this fenomenon ?the loaded swf will include objects that are off-stage. it
wouldn't be satisfactory if those objects were "omitted".
if you want second.swf to appear the same in main.swf,
main.swf will need to have the same stage size as second.swf or
you'll need to mask second.swf's target to make it appear the
same. -
Calling functions / setting variables in loaded SWF
You know how you can create a Movieclip object, add a
function or variable to it, then call that function or change that
variable from within the SWF that includes it? I wanna be able to
do that, only with SWFs that are loaded at run time.
My "main" SWF is simply a menu-type thing. The user clicks a
button in my MAIN.SWF, and the MAIN.SWF then loads the SWF that's
associated with that button, using the AS 3.0 prescribed
Loader()-URLRequest()-addChild() method that everyone always asks
about.
This works great. But now I've got some custom objects and
such (ie., not just strings) within my MAIN.SWF that I'd like to be
able to share with the loaded SWFs. Preferably, I'd like to use an
accessor-type function (ie.,
LoadedSWF.GiveMeTheCoolObject(MyCoolObject);), though at this point
I'm willing to hack into the object itself (ie.,
LoadedSWF.CoolObject.CoolField = MyCoolObject.CoolField;) if that's
what it takes.
I've tried just calling the functions and setting the fields,
but the AS 3.0 compiler doesn't care for that sort of nonsense on
it's generically-defined objects. Notice also that, at run time, a
call to LoadedSWF.hasOwnObject("GiveMeTheCoolObject") returns true.
So my big-brained colleagues, what's the magic?
In advance, thanks for the help!
ScottKglad,
quote:
Originally posted by:
kglad
from that error message it appears your function is expecting
a member of the MyCoolObject class, correct?
and MyCoolObject is not an instance of that class. so, you
need to fix that. ie, create a member of that class and use that
class member as the function parameter.
Heh, that's what the error message says all right. But the
object actually IS a MyCoolObject class object. I stared at this
thing for hours, and MyCoolObject IS an instance of that class. I
tried various casting combinations (including casting it to an
Object and passing that) but had no luck whatsoever.
So I googled this particular runtime error message ("Error
#1034: Type Coercion failed: cannot convert ") and found a ton of
links to other people having a similar issue. Typically, the
problem was just as you said, someone passing a button as a string,
that kinda thing. But one guy had a problem with an object he
derived from the Event class. After hours spent trying to get it to
work, he tried overriding the base class' clone() method and got it
to work:
http://www.asserttrue.com/articles/2006/10/14/custom-events-in-actionscript-3-0
As for my project, I took a long hard look at the overall
architecture of my project and decided that it was best if all the
"real work" took place in the MAIN.SWF file. This approach would
solve a couple of other problems, and it just makes sense in a
"separate the display from the data" mentality.
So (and this is the interesting part) I changed the API for
the LOADED.SWF to accept String pairs (ie.,
LoadedSWF.AddToDisplay(Name:String, Data:String) ) instead of
accepting MyCoolObj. Ran it, and Viola, now we're working without
any run time exceptions. After that glorious moment, I created a
couple of other APIs that just accepted base classes (one an int
type, the other a function type) and was happily on my way.
From this, I gather that passing non-base class (ie, derived
class) objects to loaded MovieClips via custom function APIs is...
maybe not as straightforward as we'd expect. In the grand scheme of
things though, not a big deal: As far as I'm concerned AS3 rocks.
Again Kglad, thanks for all the help: Your input on how to do
this was the big push that I needed to get over the last technical
hurdle of this project.
To those who are reading this topic for the "how do I call
functions and/or set variables in a loaded SWF?"
The short answer is to cast the loaded SWF's content object
as a MovieClip and then call the function or alter the variable:
//Load the SWF (you've seen this code a million times)
var LoadedSWFObj:Loader = new Loader();
var MyURL:URLRequest = new URLRequest("LoadThisSWF.SWF");
LoadedSWFObj.load(MyURL);
//This is within your Event.COMPLETE handler:
//Cast it as a MovieClip object and work with that.
var LoadedSWF:MovieClip = LoadedSWFObj.content as MovieClip;
// or another way to cast it is:
var LoadedSWF:MovieClip = MovieClip(LoadedSWFObj.content);
//Call yer function:
LoadedSWF.CallMe(); -
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? -
Loading swf into movieclip object
I am trying to load a swf file into a movieclip object on the
stage. The movieclip object is sized smaller than the screen, and
placed in the middle. I have defined a loader with:
var myMovieClipLoader:MovieClipLoader = new
MovieClipLoader();
then use it like this:
_level0.myMovieClipLoader.loadClip("moviename.swf",
_level5.movieclipinstancename);
(the movieclip object is used in a swf loaded in level5)
When I load the swf like this, the swf loads at the correct
location according to where I have placed the movieclip object,
however it "blows up" to fill the screen from that point down and
across, ignoring the size of the movie clip object (the loading swf
actually expands beyond it's created size to fill the screen,
making all the graphics and text much larger than intended). The
actual pixel size of the swf I'm trying to load matches the size of
the movieclip object (1024x350 in a 1280x1024 screen).
What is the magic setting or property that will tell the
loading swf to honor the size of the movieclip object I'm loading
into?
Thanks for your help!
BarbSomething I've been working on:
Place the following code in a new file <your project
folder>\as\MovieContainer.as
Then open the properties for the symbol you want to be your
movie container
Set the AS 2.0 Class to as.MovieContainer and give it a name
(I named mine 'loader').
To load the movie, simply call:
loader.queueSWF('my.swf');
Hope that makes sense. Basically, it's just a self contained
class for loading into an object on the scene. It draws a simple
progress bar on the center of the symbol when it's loading and it
resizes the loaded object on init to conform to the size of the
object on the stage. Why queueSWF? Well, if it's currently loading
a SWF, it will wait till it's finished and load a new one. The
biggest problem right now is the progress bar, but it's fairly easy
to remove if you don't like it. Hopefully it helps.
If anyone else is reading this. I'm trying to figure out if I
can load these movies into an array of movieclips. So far I've had
no luck. If you know of a way, feel free to drop some input. -
Trigger function when loaded swf finishes
I'm making a site that loads external swfs based on which
button is clicked. When the swf loads it plays an intro and then
stops at a certain point. My goal is that when you click another
button the current swf plays an outro before the next one loads.
The problem I'm having is making the outgoing movie trigger the
function that loads the next.
At first I tried just adding loadNextMovie(); to the last
frame of the loaded swf. But for some reason this causes the two
stops in the file from working so the thing just keeps looping. I
have no idea why adding this function call would prevent stop();
from working.
Is there another way to have the end of movie trigger the
function? Also, why doesn't adding loadNextMovie(); to the last
frame of the loaded swf work?Ok, sure. I have main.swf that loads external.swf. Main.swf
has a function that loads a different movie. Like this:
function loadMovie():void {
trace("movie loaded")
This function is to be called from external.swf by putting
this in the last frame:
stop();
loadMovie();
But when I actually put loadMovie(); into external.swf the
stop no longer works and it just loops. What am I doing wrong? Is
trying to put this function call in the external swf the correct
approach?
Maybe you are looking for
-
I have Windows Vista 64 bit. I click on the bookmark and the address comes up on the bar, but it doesn't open. When I go to Internet Exlporer the website does work. In addition, before I downloadedI loved playing Yahoo gin. But the new Firefox does n
-
Accounting for varying values in Data merging
Hi everyone, I've been asked to create a template for a degree certificate. So far I've created an InDesign document and used data merge to import the data from a .csv file. I've also used GREP styles to resize the name of the degree when it's longer
-
hello all, i have received an Inbound IDOC with Error Status 53. what could be the solution.please help me out santosh
-
How to import a package in UML Class diagram
Hi all, I am new to use Sun Java Studio Enterprise 8 and trying to do a project. In the class diagram, I have to import java.util.Observable (for my Model)and java.util.Observer classes(for my View). How can I do this? When I searched the forums, I s
-
Hi Folks, We are implementing CTM solution for a HTDM client. It is the same APO instance where one company is already live on APO and CTM runs are taken on Sunday, Monday, Tuesday, Thursday and Friday on a weekly basis. Now for this new company impl