Actionscript 3 :: Getting Size/Coordinates From Loader Content?
Mar 23, 2010
i'm attempting to position a textfield to the bottom left of an image that is added to the display list from the Loader() class. i don't know how to access the width/height information of the image.
var dragSprite:Sprite = new Sprite();
this.addChild(dragSprite);
var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest("picture.jpg"));
[code]....
within the displayPic function, i could assign the evt.target.content.height and evt.target.content.width to variables that i could use to position the text field?
How do I get the size of the content area of Container objects? One non generic solution is checking for styles I suppose but I am looking for some code that works generic for all standard flex Container objects. The controls are Flex 3
The title describes the problem: Loader.load() is firing the INIT event, but in my listener it's reporting loader.content as null. The description for INIT event is "Dispatched by the associated LoaderInfo object when the properties and methods of the loaded SWF file are accessible."I'm loading a lot of JPG images, and 95 percent of the time it works fine; the init listener fires and reports valid loader. content.I absolutely need loader.content available because I need to set the bitmap smoothing property to true.I've tried using Event.COMPLETE and it has the exact same problematic behavior.
I'm have made some buttons (movie clip) and when I click on it, I want a file (home.swf) to load in a loader (mx.contents.loader) and I want the other buttons to do the same, all load into the same loader. I have no Idea how to do that. The way I have it set up now, the home.swf will load over the entire screen and that is not what I want. I just want the content to load into the loader and have its content change once I click on the other buttons. Here is a copy and past of that I have at the moment, I'm using Flash 8 to do it all.
How to remove a loader and its content using removeChild or any other way, I had removed the loader but its content still playing in the background i know that from the sound of the content.this is the my code for removing:
I have a main "shell" swf which, by clicking several buttons, will load/unload various external swfs into a Placeholder_mc which resides on the main timeline in Shell.swf In the documentation and tutorials I've seen a couple different methods, and I'm not sure I quite understand the difference, or at least the reason you would use one over the other...In the 1st method, you can just add the Loader object using the addChild() method:
Code:
var myLoader:Loader = new Loader(); var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf"); myLoader.load(myURLRequest); Placeholder_mc.addChild(myLoader);
This will apparently add myLoader to the display list once it has completely loaded.The 2nd method, you supposedly can add the Loader.content; however, it appears you can only do this once the content has completed loading, so you need to incorporate an event handler with the contentLoaderInfo object:
Code:
var myLoader:Loader = new Loader(); var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf"); myLoader.load(myURLRequest);
[code]....
What are the pros/cons of adding the entire Loader object, as opposed to the Loader.content and vice versa?
I've run into something I find very, very odd. Bordering on bug-level odd, even.I load a gif file with a Loader. No fuss there.I then attempt to instantiate two different bitmaps with the loaded content:
I then place them apart on the stage so I can see them both:
image.x = 50; image2.x = 200;
Finally I add the bitmaps to the stage:
addChild(image); addChild(image2);
But only one of them turns up - depending on the order in which I assign the x-values. The bitmap I assign to first, is the one that renders on the stage.I should have two distinct bitmaps after the first two lines.When I examine the values, it's as if there's only one object on the stage, yet debugging info suggests that there are in fact two objects, both referencing the same bit of memory for the image.
How do I force it to make an actual copy of the content, not just the memory reference I think is going on here? I'd really prefer not to load the gif file for every new instance.
I'm building a dynamic content page in flash that consists of using attachMovieClip and createEmptyMovieClip with coordinates to place photos and objects, which are loaded from an external source and scrolling their thumbnails I've run into a problem setting the variables correctly because the scrolling thumbnails required that the thumbnails be nested inside a scrolling controller clip and that has somehow messed up my preloading and sequential text caption loading for the tumbnails.
I have an XML-file which holds some info about picture and text.A designer have made some mc's and I have to load the pictures (which has URL from XML) into this mc-animation. I can only load the images into the loader and then I cant get the image from the loader in memory into the animated timeline mc. how this is done? I have tried addChild but this doesnt help me attach the loaded picture to the anim_mc. or...?The designer also have a textlayer, which is put in a mc and then animated. And the text from XML must go into the textfield and be animated.
I have a flash file for a website section. I inserted a Loader component component to load a .swf file, and set the "scaleContent" property (in the Component Inspector) to True, but the .swf loads tiny, like a thumbnail. I also set the minimum dimensions (400x300), but this seems to have zero effect. I also have the size of the loader component set to 424x350. I have played with both sets of these numbers to no effect.
Here is where I've uploaded the file for testing: [URL] If you click any 1 of the 4 images, it will load 1 of 4 .swf files within (but very small).
Furthermore...the size of the embedded videos is not always consistent. Sometimes, after re-uploading the main file, Some of the 4 videos will be correctly sized, but if visited more than once, they return to being small. Very weird.
P.S. I have attached a screen capture of the Flash program, showing the component inspector and properties.
I have tried to get width of my thumbnail, it is loading and showing jpg image, I stuck to find it's width. ld=new Loader() ld.load(new URLRequest(obj.@thumb)) addChild(ld) ld.contentLoaderInfo.addEventListener(ProgressEvent.PR OGRESS,preload) private function preload(event:ProgressEvent):void{ [Code] .....
I have a URLloader that load an xml file, what i need is to be able to clear whats in the loader once the data of my xml has been loaded, is it possible to use unload in the on complete function? for example[code]...
I am looking to develop a slideshow with images that are loaded from an external source. I am able to write the code for one loader but if I try to duplicate the frame, it says my functions are duplicates.
I have a loader, and it doesn't seem to be loading my content when I am viewing it on my website. However, when I open up my loader.swf in a browser, it loads up my content once it is done loading.
Loader AS3: var loader = new Loader(); loader.load(new URLRequest("slideShow09.swf"));
Im making a main page that will load different content into one loader. I have the loading URLRequest calling a variable for the link and then on a certain button click it will change the swf to be loading.The problem is this: This code is being called in a movieclip inside the main timeline called "loaderHolder"
I have a "master" SWF file into which I load content (other SWFs) via the Loader Class (with code below). var contentLoader:Loader = new Loader();this.contentContainer.addChild(contentLoader);I load the content (these other SWFs) into a MovieClip container on the stage called "contentContainer". The "contentContainer" is much smaller than the "master" SWFs stage and also much smaller than the original size of the SWFs that the Loader is loading in. Also, and this is very important, the "contentContainer" itself is sized -- not scaled -- (see code) and placed on the stage depending on how large the stage is scaled (I am trying to make one of those "liquid stage" flash sites that fills the browser window with flash content regardless of window size).//this resides in a function that is called whenever the stage RESIZE Event is fired
public var loaders:Array = new Array(); public var loaderClip:Array = new Array(); function loadPersonmenu() {
[Code].....
The wierd thing is, my function fileCompleteListener() doesn't even referance any of these Loader instances or swfs, which is why I didn't include it in my code. This isn't a problem in the first conde
I've seen mention of there being some security risk with loading images and leaving them in loaders. A few articles I've run across said that you should always draw them as a bitmap when the loading is done.
Is there any truth to this? I have a few loaders I have left in my project, do I need to hand their content off to a bitmap? What is the advantage of always having a bitmap represent the loaded image?
I am loading a fairly large image file and want to create a bitmap of the loader content. I want to then use this Bitmap and resize it according to the current dimension of the stage. However, I also want to keep the loader content as "originally loaded" as a reference in case the stage is resized and the user wants to view this particular image again. The way my AS is written as of now, I am manipulating the loader content. How do I not do this? How do I "copy" the loader content so I can manipulate the bitmap copy while leaving the loader content unaltered?
<AS> var lightboxImage:Bitmap = new Bitmap(); function resizeLightbox():void{ lightboxImage = myLoader.content; lightboxImage.width = myLoader.content.width; lightboxImage.height = myLoader.content.height; [Code] .....
I have a SWF on another server, it loads the first SWF. Here's my basic code:
Security.allowDomain("my.central.server.com");var loader:Loader=new Loader(); // used to load external SWF.var mcExternal:MovieClip; // used to store the loaded SWF.loader.load(new URLRequest("http://my.central.server.com/data/FSC_Test_Automation/called.swf"));loader.conte
detecting the totalFrames of content loaded into a Loader?
I made a dummy animation just for testing (150 frames of text just tweening across the screen) to load. I load that in and when it's loaded I'm always told it's only 2 frames long.
I just wrote that by hand now as an example so there might be a typo here or there but you get the general idea. I'm using CS5, flash player 10, just testing the movie and every time it traces 2 total frames. how to tell how many frames the loaded content actually has?
I've devised a preloader using the ui loader and progress bar components in flash cs3. The goal being to load an external .swf into the uiloader and that has been achieved. I'm having problems with the scaling now. In my code I have set the content scaling to "true" and that isn't supposed to cause distortion of any type but it does. It squishes my external .swf in width wise.
HTML Code: var imageURL:String = "portfolio.swf"; var imageURLRequest = new URLRequest(imageURL) uiLoader.scaleContent = true; uiLoader.load(imageURLRequest); progressBar.source = uiLoader; [Code] .....
Would like to find out what are the techniques people are using for pre loading multiple dynamic content for example using Loader.load()I understand if i just had one Loader.load() then I can listen to it with contentLoaderInfo.addEventListener(Event.COMPLETE, callback)But when I have multiple Loaders, what technique is used for ensuring all the content is loaded before playing the swf?Currently I use an counter such a that on each Event.COMPLETE from different Loaders, I increment that counter until I have register all the COMPLETE events. But I think this is certainly not a good method?
I have a problem with my New Loader class I use as3 and buttons to load external files into into my main swf file and I resize the external files to match my stage but they always load from the top left at x=0 y=0 The action script i use is
var swfHolder = new Loader(); mybutton_btn.addEventListener(MouseEvent.MOUSE_DOW N, mousedownpresser); function mousedownpresser(event:MouseEvent):void { addChild(swfHolder) swfHolder.load(new URLRequest("myvideo.swf"));
Is there any way I can load the external files into a different position?
I'm trying to keep a fresh copy of my loaded swf's in the loader.content while I use a copied version in my main swf. What I'm trying to do is make a slide show using a master swf to load many other slide swfs. The first time through each swf plays just fine but the second time through there can be problems with eventListeners, etc so I want to trash each slide when I'm done with it and get a fresh copy when the user wants to see it again. I've done this utilizing the cache in the browser but I'd rather use the method below.
I saw this code from: [URL] that allows you to copy movie clips so I should be able to do that with this method but I'm clueless how other then cutting and pasting code and praying that it works.
Security.allowDomain("*"); var myMovie:Sprite; var l:Loader = new Loader();