ActionScript 3.0 :: Use Multiple Instances Of The Loader Class With One URLRequest?
Apr 21, 2010
I'm creating an image loader with a specific effects that requires layering multiple masks over the same movieclip. in the timeline it looks like this:
What I want to do is add an instance of the loaded image into each of these masked movieclips. I'm trying this:
create a new instance of the loader and store it in an Array
Code:
for (var j=0; j<allThumbs.length(); j++) {
imgLoader = new Loader();
img_arr.push(imgLoader);
[Code]....
The only way I've been able to get this to work is to create an entirely new Loader object for each movieclip instance. Doing it this way loads the same image 4 times... that's not acceptable.
how I can store the image that is loaded and reuse it in the different movieclip instances?
View 1 Replies
Similar Posts:
May 25, 2009
I am trying to load in 5 pictures but 2 of those pictures need to be added multiple times to the same scene. For example you would use Loader to load one tree but would show that tree 9 times. The problem I am experiencing is that each object loads fine once but objects that are the same with different x and y values are placed at the last location that was set in the loop.
for(var i=0; i < LoadedXml.resources.resource.(@type==LoadedXml.resources.resource.@ty pe[fileCount]).@count; i++) sprite.name = LoadedXml.resources.resource.@type[fileCount] + i; sprite.x = LoadedXml.objects.object.
[code]........
View 1 Replies
Jun 11, 2009
I am making an AS 2.0 Class for polygons called "Shapes2". Shape2 is basically an array of Vectors (another Class I made) and is built using the function addPoint(x1,y1) to build the shape from a series of points. The points are then converted to vector-edges, etc etc.Here's the long and complicated construction:
Code:
var pent:Shape2 = new Shape2();
var rect:Shape2 = new Shape2();
if I comment out either instance, the other is functional when I test it. Trying to do two instances makes rect and pent point to the same array of vectors, but they keep other variables and properties separate, which means rect isn't just pointing directly to pent or visa versa.
View 1 Replies
Apr 14, 2011
new a class [code]Now ,I want call function newCourse many times and don`t new class again.
View 2 Replies
May 22, 2010
I have a "Window" class, which will create a window with the parameters you specify. One of the functions inside of that class is to place an element inside the window - something such as a text field, button, etc.
Now my issue. I've created two windows with different names, slightly different parameters, etc. I am adding a text field to each one. On the screen, both text fields show up (have borders enabled). I can refer to both windows using getChildByName(), but for one reason or another I can only find one text field using the getChildByName method. The other one will give me an error.... "Cannot access a property or method of a null object reference."This is the code that I use to add a Text Field, keep in mind this is inside the window class:
ActionScript Code:
public function element(builder:Object) {
switch (builder.type) {
case "static_text" :
[code]....
This code is repeated twice, for different windows. The only thing that's different about them is their names, which are slightly different. It seems that whichever text field I add first gets to stay, while an subsequent ones appear on the screen, but I cannot refer to them. I've tried switching around the window definitions and that does seem to be the case.
View 7 Replies
May 27, 2009
This is how I create a Class instance of Container_, called "wall0":
var wall0:Container_ = new Container_();
I need dozens of these, numbered sequentially. Is there a syntax available that would plug into a while statement? Like:
var w:Number = -1; while(w < 100){var (wall+[w]):Container_ = new Container_();}
View 12 Replies
Sep 3, 2009
I am creating multiple instances of a movie class with the same variable name. The movie is then added random on the stage with a tween. On a mouse handler click, i want to remove the movie from the stage.
I am getting error -
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at Untitled_fla::MainTimeline/removeBlock()
Code:
import gs.TweenLite;
import flash.utils.*;
var block:block_mc;
var myTimer:Timer = new Timer(1000, 15);
myTimer.start();
[Code] .....
View 4 Replies
Jan 23, 2012
So I know how to target a specific instance using MovieClip(root).objectName which I think is nasty way of referring to it anyways, but right now I'm trying to make a fighting stick-figure game and I can only refer my code to one NPC right now using an "enemy" class but I would like it if I could spawn multiple NPC's at once using the enemy class and instead target the enemy class instead of the instance itself while still having the NPC instances being unique so when I hit one they don't all get hit.
View 1 Replies
Jul 7, 2009
The code works fine, but I am getting unexpected results; the array seems to be shared across multiple instances of the same class? I've coded an example to highlight what is happening:
Code:
import myClass;
var instance:Array = new Array();
instance[0] = new myClass;
[Code].....
keep all objects/arrays separate across multiple instances of the class.
View 5 Replies
Mar 9, 2009
In AS3 i am using the Loader class to load in multiple external SWFs (AVM1), each of which has a short animation which automatically plays when the swf is I obviously cannot control the timeline of these (i can't use local connection etc) but would like to load in the *.swf files, so they're in memory then add them to the stage when requested. the problem is that if i load them enmass. then use addChild when they are called, they have already played through and animated pre the addChild command.
(I cannot edit the swfs at all, and would rather not load them on demand at runtime)
View 5 Replies
Mar 22, 2009
I've been loading multiple SWF using the loader class and Frame Labels. I get this error script when clicking my drop down menu buttons:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ZimIndex7_fla::mcMenu_5/buttonClick()[ZimIndex7_fla.mcMenu_5::frame1: 6]
View 1 Replies
Dec 28, 2009
I want to move my multiple externally loaded images a little each time they are added to the stage along the x axis via the Loader class. It all works - But HOW do I access the added graphic synatically, so i can change its x pos?! Ive tried picLoader.x ... but that's the Loader - NOT the image...??
Code:
private function setPics():void
{
for(var i:int = 0; i < xItems; i++)
[Code].....
View 2 Replies
Mar 27, 2012
I am loading an image using Loader class and with URLRequest, but for some reason I am struggling to reference a file in a sub folder of the root (where the SWF is exporting to) this is local testing and I am assuming that if I refer using an absolute path on a web server it would work - but I do prefer to use relative paths for simplicity.I get the above error, but I know that the file name is correct as moving it to the same folder as the SWF works fine - but in implementation should I wish to organise hundreds of JPGs and create a gallery it would be a bit messy to store them at root level. As mentioned previously I am working on a local drive at present, and have no plans to move to a web server as this is just a test file for my own learning purposes.i have tried "folder/filename.jpg" and even on the unlikely side "folderfilename.jpg" and even further far-fetched "../rootfolder/folder/filename.jpg".The only issue is the path, I am sure of it - but the filename is correct.
View 1 Replies
Aug 19, 2011
I am trying to get my Actionscript program to turn in a key-value (more specifically: a key, value1, value2) object into a server. I am doing the html request properly, but I'm not sure what kind of object to send;
View 1 Replies
Aug 24, 2010
So my problem may be a little bigger than that, but I'm not certain. I'm creating a custom flash photo viewer for a client that dynamically loads the images with Loader objects. It takes a folder name in a specified directory on the server and calls a php page (using URLRequest) to get the workable contents of the folder. And then it loads it up from that array.
Here's the problem: it works FINE on my machine and every machine I've tested it on, but it DOESN'T work on my client's machine or some of his customer's machines. The loader bar that's at the bottom of the screen doesn't start to fill, which means that the images aren't starting to even load, and the status bar indicates that it continues to wait for a the server, yet never finishes waiting. This is consistent on a single machine, but varies across machines.
I've added diagnostics (a custom class I made to track certain vars and collect errors) to the thing to catch any errors, but it reports nothing on my client's machine. I've added flash version checking code, so the possibility of a lower version messing it up is gone... I guess my question is, is there anything (security, environment, etc) that I could have overlooked that doesn't allow request objects or something to work on certain machines?? I've been ripping my hair out trying to figure this out!
[Code]....
View 2 Replies
Dec 17, 2010
I'm loading images via a URLRequest and Loader classes and I want to manage the image when the request is complete. The example below doesn't fire the event when it is complete. The same code would work find for a URLLoader, but not a Loader object. Basically the image loads and the event listener is never fired. Can anyone tell me how to get an event to fire when Loader finishes loading an image.
var imageReq:URLRequest = new URLRequest("http://www.google.com/images/nav_logo29.png");
var imageLoader:Loader = new Loader();
[Code].....
View 1 Replies
Mar 11, 2010
I am attempting to load multiple images in AS3 and I'm exploring different options on how this can be done.I would like to have to only use one Load() instance and handle the various image assignments in the onComplete handler...here is my first attempt:
var buttonLdr:Loader = new Loader();
buttonLdr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
buttonLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCo
[code]....
View 1 Replies
Dec 8, 2009
I have run into a problem when trying to reuse SWF/Bitmap file loaded by Loader object. As far as I know there is only one way to do this - by using something like this. However it`s not working for me. My code:
Code:
var loader2:Loader = Loader(duplicateDisplayObject(loader1, false));
Even though I addChild() duplicate loader to stage afterwards, it doesn`t appear.
View 5 Replies
Sep 8, 2009
Ok so here is my XML slideshow Actionscript:
ActionScript Code:
stop();
var xmlRequest:URLRequest= new URLRequest("graphicImages.xml");
var xmlLoader:URLLoader = new URLLoader(xmlRequest);
[Code]....
So I figured that the coding of separate scenes would work independently of one another, but I guess I was dead wrong, because when I apply this to a different scene and change the XML path for a different set of images, I get all sorts of conflict errors when I test the entire movie. I have my flash film set up so that each link send the user to a different scene, which plays a unique intro for each, and then the slideshow appears on screen and the viewer can navigate the images.
Is there a work around for this? Or am I going to have to break my flash movie into separate movies? Or should I just add a suffix to all my vars and functions so that they are unique for each scene?
View 1 Replies
Jun 28, 2010
I have a flash file that counts and displays the number of images in a particular folder, that part appears to work fine. I require a reset button so that the alternate directory for the images can be tested as well. For this I need to delete all the instances of the loader I created for each image, but am unable to do so.
ActionScript Code:
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.IOErrorEvent;
[Code].....
View 2 Replies
May 17, 2011
I'm using the weather.com XML service to retrieve forecast data. I created an instance of UrlLoader and passed the entire HTTP address including credentials, location and other parameters to it. This works very well in tandem with the XML(urlLoader.data) functionality in that I get the result for the specified location ID. I then use E4X to trace just the nodes needed.
The tricky part is that I have to do this for 19 additional cities. I've done the initial work in the Main class, Main function, private function onXmlLoaded. I tried creating a new public function getCityName making the new URLRequest, tracing XML and adding values to my components. However, when I attempt this, I receive
Error 5006: An ActionScript file cannot have more than one externally visible definition.
How can I easily setup the URLRequest to request data for all 20 cities, and parse the results thereafter? Do I pass an array of location IDs to URLRequest, because that's the only part of the HTTP request that's different. Do I create separate ActionScript files with their own class and functions for each of the 20 queries?[code]...
View 2 Replies
Aug 18, 2009
Hi guys, I'm wondering whether any of you have any opinions on whether you instantiate a Loader into an instance variable, or whether you declare a local variable to hold the Loader object.
I'm coming at this from a memory management / garbage collection perspective.
I only need the Loader object to load the file and register the event listeners. So I don't really want an object-wide instance variable to hold this loader object (which is what Adobe does in most of their examples), since I can always access the loader.data through the event's target property.
[Code]...
View 2 Replies
Jun 2, 2009
I am having trouble loading multiple xml files when the button is clicked.
View 5 Replies
Jul 30, 2009
I have a number of loader instances (loader1, loader2, loader) which I will use to load pictures. I tried to create a loop and run the command
for(var st=1,st<4,st++) {
_root.movie_clip.loader+st.load("picture.jpg");
}
The concatenation "loader+st" doesn't seem to work. Is it not supported in AS2.0?
View 2 Replies
Aug 19, 2009
I am calling java servlets from flash using the following code[below is a sample Flash code for calling a java servlet in Flash which I am using]:
...bla ...bla
String url_String="http://localhost:8080/servlet/getViews";
var req:URLRequest = new URLRequest(url_String);
[code].....
View 6 Replies
Nov 29, 2009
Is it possible to place two or more instances of the same loaded from a loader Bitmap in one container?
View 1 Replies
Jan 8, 2011
I'm new to AS3 and I'm having a problem with an extended class that uses a URLRequest. I have a basic class called 'imageLoader' that I use for loading in external images
[Code]...
View 2 Replies
Jul 8, 2007
I want to know how to make class instances into listeners and broadcasters, from inside each class. Here is what I am trying specifically... part of the Proj class... (projectiles, as a matter of fact)
Code:
private function listen():Void {
u.register(this);
onUpdate = function(){
step(); // a function I have which makes the projectile move (not shown)
}
}
where "u" is another class, the Updater class with this code...
Code:
class Updater {
// const. --- make this a broadcaster
public function Updater(){
[code]....
PS: What is the syntax for using AS2 code tags instead of just "[CODE|"?
View 2 Replies
Jul 16, 2009
I'm slightly new to Flash CS3 + AS3 combo, so its more of a lack of practice question. My question stems from the problem described here http:[url].... . Note, its not the same problem, its a new one.The Problem ,So I have multiple library assets (which are on teh stage) and I want to assign similar functionality to all of them.
Attempt 1: So I create the n assets, create a custom class in AS3, link them to Flash CS3 and obviously enough it gives me the error that multiple assets can't be linked to the same class.Obvious enough to understand (well not completely, because from a programmers background it doesn't make sense).
Attempt 2: Same as attempt 1, but instead of linking all the assets to the same class I make the base class the same class, and let the derived class be dynamically created by Flash on compile time.So the linking works, but the problem is, in my base class I have a method which does something (say an tween) on a child of the library asset. So if the assets on the stage/library are called asset1, asset2, asset3 (same name for asset name, class name, id name), each of them has a sub-movieclip called ... say 'foo'. now if I manually wrote a class for each asset, I could do 'this.foo' to play with the sub-movieclip. However since this functionality is in the parent class, I'm unable to do it.
P.S. If you're form a programming/OOP background, its basically a abstract class problem. My Base class knows how to doSomething(), but it needs aSomething, which is defined in the Derived classes. However I found out that AS3 classes don't support virtual(C++ )/abstract (Java) in the true sense of the word (unless I missed some obvious documentation).
View 3 Replies
Aug 12, 2009
In my movie i have a link button with following, simple, function creating a link:
[Code]...
lately i've associated a class file (.as) to my movie and immediately after, when publishing the movie i got the following error message: 1046: Type was not found or was not a compile-time constant: URLRequest. as well as a couple of other related error messages: 1180: Call to a possibly undefined method URLRequest. 1180: Call to a possibly undefined method navigateToURL. when i remove the link to the class file, the problem goes away. also, i have checked the class file for mentioning of "URLRequest" and nothing is there.
View 9 Replies