ActionScript 3.0 :: Fitting Images Perfectly To Pie Slice?
May 20, 2009
1: I have a pie chart which takes values from xml and as per the xml data draw pie chart.
2: I need to add images to some or all pie slices.
3: If I am going clockwise direction and I have reached slice number 3 ,then the image to be added to that slice have similar orientation to that pie slice.
4: I have loaded the pie images and made its bitmaps and then added it to some array say pieBitmapArr.
5: Now I need to add this bitmaps to individual pies.
6: Further the overall dimension of pie image and pie drawn doesn't match.
7: And when I use addChild method to individual slice ,all the picture arrange themselves at the top left i.e. 0,0 position of the stage.
8: I want the image to exaclty fit on pie drawn but I am not able to do it.
9: Further I have used slice.graphics.beginBitmapFill(bitmapData) but also it doesn't yield anything,just blank pie.
At the moment I am using _root.image.loadMovie(photo.jpg);to load a jpeg into a movieclip which results in the picture being loaded at its full size. Whats the best way to get it to fit to the "container" movieclips size.Also is there a way to get it to preserve its proportions so it doesn't stretch?
Is there a way to use 9-slice scaling with images loaded at runtime? To clarify, let's say that I build an application that lets a user skin a button with whatever image they want. This would be an image that's not embedded with the swf. Is there a way to set that runtime image as a background and use 9-scaling?
I know preloader questions abound in this forum, and I am sorry to add to them! I am just having a bit of trouble retro-fitting my preloader into this code.The code below shows the launch button click function... which calls up an external swf. I just want it to preload this work, just for some reason having a hard time understanding how to make that happen. I have a preloader at the front of my site working with no problem, just having trouble figuring out how to add to this code...
stop(); next_btn.addEventListener(MouseEvent.CLICK, NextFrame); function NextFrame (e:MouseEvent):void[code]...........
I have made my flash movie on a really wide screen, and i didnt realize that when I publish my movie, regular monitors cut off part of the movie...is there a way to get the broswer (mozilla/IE) to resize the flash movie so it fits on screen for the user without distorting the movie?
For some reason whenever I post my flash site online it does not fill the entire window properly. The scroll bar is always on the side making it so I have to scroll down to see the tiny bottom part that is cut off. And there is always a grey border surrounding the flash part of the site. Here is a link to the site so you can see what I'm talking about.
[URL]
I don't know if this would effect it, but I have been manually changing the html to make it so that it fits 100%.
i've got 4 coodinates an need to fit a fit movie clip to them, so each corner of the movieclips is on one coordinate.The only thing i could find it tranforming it with a matrix and angles (see example), but these cant be the best solution for my problem to calculate all the angles etc.
var degX:Number = 0; var degY:Number = 0.3; //Get the transform matrix for the object to skew var m:Matrix = bild.transform.matrix;
I'm in a Flash Pro project with my View3D as big as the stage and I'm trying to make a cube of the dimension of the stage which would fit exactly the View. Practically the user shouldn't be aware of the presence of a 3D cube (until I animate it) How can I achieve this?
Wagster kindly posted this code to resize dynamic text, but i'm struggling to get it to work. I've saved the code below that he posted as a '.as' file and i'm trying to call and use the package in the as3 script on my first frame but having no joy?The code i'm trying to use is below wagsters:Wagsters:
After making changes to a perfectly working fla it won't publish correctly,meaning:1. When previewing all the components jump (as usually happens when there isa compile error) but no error is displayed in the log.In this case when used with the whole project, the project doesn't load,even though the corrupted fla is not the first loaded (non of the fla loadsbesides the preloader).2. When previewing and running with the whole project the labels on thebutton components disappear, but only the ones that are dynamically changedby an external as file.*there are other similar bugs as well like unable to enter the table in thegame etc.The changes I make before it happens:- changing the size of a shape inside a movie clip.- changing the size of a movie clip.- changing anything in an already existing code (like changing the size of afont).- adding new basic code anywhere (like trace code).
- changing button skins.Basically, any change I make corrupts the file but not consistently,meaning, I can make the same change twice and the file will break only one of thetimes, or, I can make several changes until it breaks.It also happens on every computer but also, not consistently, I can work fora while, making the same change, deleting, making the change again etc, onlyon the fifth or sixth time the file will break. On a different computer itcan take only two or three times.The corrupted file start working again after I change the name of the foldercontaining my project or move all the files to a different folder anywhereon my computer. After a short while the file crushes again.
a content editor made with Flex SDK 3.5 a content viewer made with Flex SDK 4.1
Both need to work with dynamically loaded fonts as the user can use the fonts he wants.
So we used this approach:
convert the font files with Flash Professional to SWF-files (Creating a Font SWF) editor: load the fonts with Loader (Loading a SWF font) the fonts can then be perfectly used within the application to generate htmlText viewer: the same approach to load the fonts + register them with Font.registerFont (Flex 4 Embed font from swf)
Now the problems: although the loaded fonts are listed when you trace Font.enumerateFonts(false), they are not used in the textarea. There the text is shown with the default font.
Maybe the problem is the fonts are loaded as embedAsCFF for the Text Layout Framework, and that way are not usable in an mx.controls.TextArea? But as I can not change that to a spark TextArea for multiple reasons, I need a solution to use the loaded fonts in that mx.controls.TextArea.
I am unable to play flv from xml though the xml loads perfectly fine. When flv path is hardcoded the video plays fine but when from a node it seems to make the video disappear and it dosent play.I am having the same issue i got the xml loaded and even the url into the video source but it dosen't seems to play the video when reading from xml...
Flash Player 10.1 published with creative new features including filters & effects, text, native device interactions, support for multitouch, gestures, mobile input models, accelerometer input and periodic timer, etc. Among them all, the introduction of periodic timer is the most innovative and significant one. This new feature functions as a double-edged sword which, on one hand, can lower CPU utilization and save battery life, on the other, it may cause troubles for some SWF converters to capture the flash content under such extremely low frame rate.
I have a project that uses video for a chat application, I can get it to work in the flex emulator but when I deploy it to the device the button that initiates the video doesn't change and video never starts. My devices all have 2 cameras except my computer but specifiying Camera.getCamera([1]) didn't change anything except mess up my emulator and cause a NullPointerException. Camera.getCamera([0]) works just the same as not having the ID. I have tried messing with different values quality and nothing makes a difference
private function publishVideo():void{ _publishingVideo = true; _ns = new NetStream(_nc);
I was wondering how "relative alignment" such as on the easybit-site (take the window and resize it) is done? All objects on the stage are positioned always relative to the actual window-size without losing quality, but how???
i been trying to figure out a way to make sure my property values from my xml file are fitting sweetly into my classes.
using 'property is XClassType' pretty much tells me if its an array, boolean, number. But strings are a bit weird. Even though the property is declared public var some:String the below test doesn't trigger it being set to a String. Are Strings different than Boolean, Array, Number, etc.?
Code: if (myTarget[i] is String) { trace("prop is string"); myTarget[i]=String(mySource[i]); }
i have the following problem: when i publish my site (all in flash) with stage.scalemode=exactfit parameter, the page is stretched; while when i use the scalemode=noborder parameter, the page is cropped below;
what i want is the site adapting itself to the width of the screen (with no borders on the sides),maintaining proportions and so allowing down scrolling; I haven't found any answer around the web to this apparently simple issue
Just started learning AS, and have modified some code from a tutorial to put a couple of basic pages together. Each page apart from the loading screen consists of 4 buttons linking to 4 different pages.I have so far changed one word in the code, relating to one navigational button, and as far as I can tell, all the corresponding code, and the Properties and parameters inspectors. The error is apparently a "duplicate function definition" of all the functions in frame 2.Strange how the script worked perfectly with the previous word "About", which was changed to "Animations".The preview of the site just flicks through each page without stopping.[code]
I created a xml driven menu that works perfectly on a html page but would like to use it in a flash site. I loaded the the external menu movie in by using the:loadMovie(); reference but when I try to point the movie link from the menu to the empty movieclip it wont work. below is the code for the button action:[code]
The AS3 getBounds function returns a rectangle that is not fitting tightly to a rotated ellipse. Instead it returns an axis-aligned rectangle based on the bounds of a rectangle whose width/height corresponds to the max/min diameter of the ellipse and follows its rotation.
Stack Overflow Q/A about the math of ellipses and bounding boxes
Based on this I took a stab at coding a solution in AS3. So far I have been able to produce a rectangle that fits perfectly along the x-axis, but as I rotate my ellipse it acts very weird along the y-axis. Rather than alternating between 2*r_min and 2*r_max while rotating, it alternates between 2*r_min and 0. My best guess is that I have done something wrong when solving the differentiated t for gradient -> infinity...
Here is an example from my code:
var r_max:uint = 45; var r_min:uint = 20; var rot:Number = ellipse.rotation * (Math.PI / 180); var t_nil:Number = Math.atan( -r_min * Math.tan(rot) / r_max);
I have a simple sendAndLoad XML request that works perfectly on 95% of the computers I have used. I have check crosssite stuff and everything i can think of. Its not browser specific ,os specific, or flash version specific. On these computers I can run the same flash file on a standalone player and everything works flawlessly but inside of any browser it makes the request for the XML file and stops right there. After a while like 10 minutes flash gets tired of waiting and returns not found. I can navigate to the xml file via the same browser. Upgrading Flash doesn't help.The only thing consistent is it only happens to windows computers. The requested URL is the complete URL. I have changed this and still the same.IE or Firefox still the same. Version 9 player in both. I have montiored network traffic and see the request made and maybe a response but flash has moved.
I'm working with a video in Flash where I am capturing each frame and testing the color of a single pixel. I'm using it to determine when a white/transparent background changes to be a color. The following AS2 code works flawlessly when I preview it in Flash and on my desktop in the browser (the direct SWF and placed inside HTML using SWFObject) but as soon as I upload it to my server it fails and produces "FFFFFF" continuously regardless.
this.onEnterFrame = function()[code]..........
There is no difference in the files; they are both pulling from the same video source (hosted on an Flash FLV server).The only difference is one set of files is hosted on my local computer and the other is hosted on my web server.
I have a movieclip that will rotate by 10 right if the right button is pressed, or 10 left if the left button is pressed.Now, some genius tell me why the right button code works perfectly, but when i press left it doesnt rotate. It moves left, but no rotation to be found .heres the code
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) { xspeed -= power;[code].....
I am trying to use .slice() to copy an Array of Loaders (each with a jpg loaded in it), as follows:
newArray = oldArray.slice();
and it works, but the problem is, any changes I apply to one Array applies to both, as though .slice() had just copied a pointer to the same Array, but I was specifically told that .slice() would not exhibit that pblm. Before I just go back to loading the same images twice, is there something special about Arrays of Loaders or something else I might be missing?
I am trying to use slice to remove an element of an array and it does not seem to be working.I have an array in a class called singleton. It is global and persistent and once instantiated I just get the instance of it
_singletonInstance = Singleton.getInstance();
I also have another class I instantiate when I need to add or remove an element from that array in the singleton object.I can add to the array when I call this function:
public function add():void { _singletonInstance.noDropList.push(_elementToAdd);[code]....
Since the TimeCell0_mc_25 is index 4 it should be removed in the second list after add. but as you can see it is still there.
This may be a bit of an easy question for some, but I'm having difficulty understanding what mc.name.slice(5,9) does. What is this name slice bit about?
I've made a rounded rectangle with a gradient fill and another rounded rectangle over it with a transparency to create kind of a glossy effect. Both objects are part of a symbol in the library of the FLA file. Then, I activated the checkbox to create a scale-9 grid, and the Export for Actionscript checkbox in order to add this symbol from AS3. Next I made sure that every rounded corner was completely included in the slices on the edges of the grid. Well, no matter what, the object is scaled as a normal graph: the rounded corners appear bigger and deformed.
It seems 9-slice scaling in Flash CS5 is a little half-baked. If you create a symbol containing text and vector graphics, only the vector graphics is scaled according to the 9-slice scaling contract. For example, consider the following symbol:
Sure, the vector graphics are scaled according to the 9-slice contract, but what are we supposed to do about text? And just in case you're thinking "convert the text to vectors/raster"... unfortunately no... I don't have the option of converting the text to a set of vectors or a raster because its content will have to be dynamic.