ActionScript 3.0 :: Loading .JPG's From Server And Reusing Them In .SWF
Feb 25, 2010
Suppose I want to load a .jpg from the server ONCE and then I want to reuse it a dozen times in my .swf... How can I achieve this without adding to the .swf`s file size? I was thinking copying its BitmapData a dozen times, but that adds to the file size, right?
If I use an empty movie clip to load a series of images into,how do I get them to load in the center?The images are all different sizes.I think this is fine, if they loaded with the center of both the target clip and the image aligning.Upper left registration point for the target is not good.
I am having a real problem with understanding something in flash - it doesn't work in the way I expect so I figure I have really misunderstood something.What I want:I am creating a bunch of .swf files and in each one I want multiple instances of an object that when you put the mouse over it the object will play its animation a bit and pop up a tool tip. Each object can look different (i.e. be a different bitmap) and animate differently (shake, pop, rotate etc).What I did:I have tried to create a class (myMouseItem) that creates the necessary listeners to handle the animation and pop up the tool tip.
I create a library item and attach it to the myMouseItem class. I can then put one instance of this inside my .fla and it works. (I still seem to have to put a .stop() in the actionscript for the scene to get it to stop animating for ever but I can probably live with that)What I can't figure out:How do I repeat this with multiple objects all with different bitmaps but reusing the underlying class? When I try to add another instance of my library class and edit the bmp it changes all instances. When I try to create another library item with the same underlying base class I get an error saying that I have to choose a unique identifier, so I don't seem to be able to reuse my .as file.
I am trying to reduce the size of my swf, and I see that I am using a movieclip on each frame on the Timeline, which has to be adding considerable size to my file, since I have placed the movieclip(animation) on every frame. How could I do this more efficiently and still acchieve animation between each frame? I have included a ripped version of the fla. , since the attachment limit here is pretty low. In the file the video - files and the picture files have been removed, but the rotate... mc's(animation) are placed in the interanim Layer and the Menustate Layer, on each frame.
I am doing a web portfolio with thumbnail buttons that change the pictures. What is the best way to avoid having to make a new button for each new picture thumbnail? So resusing the button but changing the thumbnail picture in it and what picture it links to? Using CS4.
I am making a mobile application in as3. I'm optimizing.I have a scroll containing 30 objects (buttons). All buttons are the same except its title.This bucle is inside the container scroll:
for(var a:int=0; a<global.get_A.get_B.length; a++) { b = new ItemList(global.get_A.get_B[a]);[code].....
Out of some curiosity and the use of possible standard key variables so I don't have to create several instances to the same class, I was trying the following:
[Code]...
My question is: Is there a better approach to this on AS3? Something tells me I'm just heading the wrong way there...
I'm doing a filmstrip animation and each frame of the strip has a small pic on it and using TweenLite, I'm making it expand and contract on mouse rollover and rollout. That's not the problem. Since it's basically the same function, I don't want to have to write it for all 16 frames. I thought I'd try 'this' but that doesn't work on AS3. So I'm trying to find a solution that does. Here's my code (for one frame of the movie....in this case, the eighth).:
I need to load an external resource and be able to reuse it (create new objects based on that resource). I need to create multiple objects using that resource and I don't want to load it again over and over every time I need to use it. My question is: How can I load a resource (in my case, it's a collada file ".dae") once and be able to reuse it again?
I'm creating a pacman game and basically I'm having trouble coding the enemies (ghosts), the code works perfectly with just one ghost, as soon as I add another it starts to go wrong.Firstly I've got this function which places the enemies:
Code: //places the enemies function placeEnemies() {
if I have two scenes and on scene 1 I have some code with variables and event listeners in it and I copy that code into Scene 2. When I test the movie I get a duplicate function definition error because the variables/event listeners on both scene 1 and 2 have the same names. To fix this I could just change the names of the variables and event listeners in scene 2 to a different name but what if I have say 10 or 20 scenes then I would need to change the names of all of them on every frame and I don't want to do that.Is there a way of using the same variables/event listeners on different scenes without having to rename them and without getting the duplicate function definition error.
I'd like a movie clip called "following_cursor_mc" to follow the cursor, regardless of which of several different frames the playhead may be on. I've reproduced the code below on each frame in which I would like the cursor to be followed by "following_cursor_mc" but these errors are thrown for each of the frames:
I am trying to reuse the lines of code and it worked fine the first time but when I tried to use the evtObj.target.name it gave me error 1120:Access undefined property evtObj.Here is the code I tried to use:When I test the movies it just runs automatically instaed of waiting for the click.
i was in situation that tree is re-using my custom item-renderer.. is there any method or way around we can stop tree to reuse.. and always create a new item-renderer for new item..
I want to be able to reuse my existing controller logic regardless of whether a request has been sent from a Flex client (using BlazeDS + Spring at the backend), or as a simple HTTP POST/GET request. For simple cases, things work OK, however, there are some occasions when I need to access some session attributes. At first, I almost exclusively used the FlexContext class, but then I realized that when one sends an HTTP request, then the Flex Context is obviously undefined.
My question is, what is the best approach to abstract the session extraction logic,regardless of the type of the request. In other words, I would make a class called SessionManager, which has a method getSession. This class will make a check whether there is a Flex context, if there is, it will return the session of that context. If not, it will simply return the current HTTP session (which I assume is the same as the Flex client session, but I was not sure)
I somehow am able to write bits of code but am still learning how to restructure code so that it is more efficient.I have 15 buttons. Each one, when rolled over, should change the color of 2 movieclips underneath it (and when rolled out, should change back). I have the below code so far but I don't think I have to re-write the functions each time. How do I "re-use" the function code (or, only write the function code once), but specify what movieclips the function should be applied to? These are just 2 of the buttons of the 15:
Code: menu_mc.invis1.addEventListener(MouseEvent.MOUSE_OVER, changeColor); menu_mc.invis1.addEventListener(MouseEvent.MOUSE_OUT, changeBack); function changeColor(event:MouseEvent):void[code].................
I have a datagrid in a flash app. The intial use works fine. The flash has the ability to recalculate the needed data which I then use to repopulate the existing datagrid. What is the best way to clear out a datagrid and repopulate it?I tried:ifxGrid.dataProvider.removeAll();but it does not clear out the previous dataifxGrid.removeAllColumns();this worked a little but not entirely.So what's currently happening is that the new data is appended to the old data. So if I had 50 rows in the 1st calculation and then I have 70 rows in the 2nd calculation I end up with 120 rows of data in my datagrid.
I have a List component using multiple item renderers determined by the itemRendererFunction. When I set the data the first time, it works as expected. Then, when I set the data a second time with new data, it doesn't call the itemRendererFunction and tries to reuse the current renderers even though they don't match the data.Once I scroll, the function is called and the correct renderers are used. I tried calling invalidateDisplayList and such prior to setting the data, but that didn't fix the problem.
Suppose you have a slideshow movie that loads content such as images or Flash movies itself and continually replaces content with new images or movies as a viewer browses through content. Is there a way to store images or movies that have been loaded so that if the same content is selected they do not have to downloaded again? Presumably once content has been unloaded or something has ben loaded into the same level the data is wiped from memory and has to be downloaded if it is displayed again. How could content be stored in Flash or does the content stored in the browser cache take care of this?
I'm putting together a project where I'm loading different images at different times. The first image loads when the app starts. After the user answers some questions, I load a different image, replacing the first. When I try to do that, I get an error:
I embed the swf into a dreamweaver page and tested it in the browser and it works fine. When I uploaded it onto the server the swfs don't load. ??? like nothing is there.I would post code but I don't know what is relevant to post. Here is the link to the site URL... I am not sure if that is going to help. There are supposed to be two swfs(picture Viewers) one under Projects and another under Red Eye Gallery. Can anyone Help.
I have an issue with a script I created that loads text strings from a file on my server.The swf file loads a message from a .txt file, displays it in an animation when the animation finishes it loops back to the start and loads the next message and displays it in the animation.
All works fine. However the script reads the text file from the server on every loop ( 3 seconds ) This will be hard on my server so... Is there a way to read the text file once only and then loop through the eight statements?
I have a flash site, which uses XML to load an image gallery, but it cant find the images on the server even though they are there. It works fine locally.In firebug, each image is listed in the net tab as found, but when you click on it, there is an error message..Plus an error page is listed for each of the images.If you click on one of the other button's in the gallery strip on the site, it tries to find Freeola's (my host) 'crossdomain.xml' file which doesn't seen to be there, could this be a cause?
I have a simple flash banner that is pulling a number from an xml file on a different server. When it gets to the frame where the number should be it just says "transferring data from and will not actually pull in the number. Unfortunately I can't put the files on the same servers.below are the links and the xml code I'm using followed by the action script.[URL]
I have a problem. We have a website www.onlinerealgames.com which hosts the game developed by our company. Recently we wanted to change the template. We are testing the new template in a subdomain of ours which is www.onlinerealgames.in . Everything is fine except that the swfs in the server are not loading. Instead they are showing Movie Not Loaded. If I directly access the swf with the URL it showing the download option window.
We are having seperate database for both sites. Both have same swfs. If we change the source from .in to .com then the swfs are loading properly (in the src property of embed tag)
I just saw that some (only some) flash files (games) aren't loading in my website, but are in other servers. Most of the files do work. For example:(External) [URL] (My Server) [URL] It is the same file, but doesn't load at my server.
I need to loading a PNG file from a server into my flash project. What I want to do it be able to call a PHP page and send it a variable which I can do. Then I want to access a db and get a path for the image, I can do this too. What I'm not sure about is what to do then. What I need to happen is the PHP to return the PNG to flash somehow. Can I just add the PNG to the php page and use a loader somehow? I've been searching around google but most tutorials seem to be getting PNGs out.
I have some little flash graphs I made that pull data from an xml file and also expect a flashVar in the html. The flash checks the flashVar against the data in the xml file and then proceeds to display some numbers.
The problem arises when we put the swfs and xmls on the server. The flash just wont load the xml files. It will however load the xml files if they are placed on the root of the server. Strange right ?
In the flash the xmls are loaded on the same level. If I upload the swf's to a folder with the xmls files and call the flash into an html page (not on the same level) they wont load. For instance in the html I have:
var xmlLoader:URLLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, showXML); xmlLoader.load(new URLRequest("myXML.xml"));
I would have thought as long as the XML and the SWF are together then the above should work right? However if I make a fixed path in the FLA to the XML it will work.
I am using the "loadSound" method to load an external mp3. The problem is I need to load the mp3 from a remoter server (the file is not local to the swf). From my searching, I can't seem to find out if this can be done.
My code follows: this.createEmptyMovieClip("mcSoundHolder", this.getNextHighestDepth()); var sndAudio:Sound = new Sound(mcSoundHolder); sndAudio.loadSound("[URL]", false); sndAudio.onLoad = function(bSuccess:Boolean):Void { if(bSuccess) { this.start(); }};