I want to rotate images on refresh

I work for a newspaper, we want to rotate ads on refresh at random. We are looking to stop using our current programmer. We just need to figure this out. I want it to rotate like THIS. Is there a fairly simple way to do it in dreamweaver?

In the following example let's assume you have 4 images in your root directory sequentially numbered 1.jpg, 2.jpg, 3.jpg, 4.jpg
Use php to create an array of the file names and then randomize the array. Then simply echo the results of the random array.
On page.php put this:
<?php
$input = array("1", "2", "3", "4");
$rand_banner = array_rand($input, 4);
?>
<!-- Start Banners -->
<img src="<?php echo $input[$rand_banner[0]]; ?>.jpg" /><br />
<img src="<?php echo $input[$rand_banner[1]]; ?>.jpg" /><br />
<img src="<?php echo $input[$rand_banner[2]]; ?>.jpg" /><br />
<img src="<?php echo $input[$rand_banner[3]]; ?>.jpg" />
<!-- End Banners -->
If you have more images but you'd like to limit the number that's rotated on pageload then change the limiting number in the array_rand function to correspond to the number of random images you'd like displayed. Let's say you want to only display 5 random images out of 10 possibilitites...
Change this:
<?php
$input = array("1", "2", "3", "4");
$rand_banner = array_rand($input, 4);
?>
To this:
<?php
$input = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
$rand_banner = array_rand($input, 5);
?>

Similar Messages

  • Rotating image when refreshed

    Hi, I have a table with a background image inside one of the
    cells, I would like to change this background image when the page
    refreshes. i cant figure out how to do it!
    It is here: www.morgansilva.com
    THanks!

    I should say that I would like text over the images, so I
    want the rotating image to be the BACKGROUND of the cell. Hope that
    helps explain it more.

  • How to rotate image of picture ring

    Hi,
      I want to rotate image of picture ring (in particular angle). In my application I want to move a object(in circular form). Please tell me how to do it?
                                            - Thank you

    Hi,       I'm attaching one Jpg file; I need to move the train as per image route. I have tried position property node to change its position but problem is at turn, I can not rotate image of train smoothly through 900.                              - Thank you 
    Attachments:
    train.jpg ‏395 KB

  • New to Dreamweaver - need new-image-on-refresh code

    Hi everyone,
    I hope this is the appropriate place to post this request, if not, please redirect me. Thanks.
    I have extremely limited knowledge using Dreamweaver and coding (ie: I know basic html), but I am attempting to build a page where the image I have sitting in a table cell changes randomly to another when I refresh the page. I have looked on the net for simple copy/paste solutions, but it is boggling my brain, and the attempts I've tried don't seem to be successful.
    Does anyone perhaps have some reliable code and mind talking me through it?
    Thanks in advance.

    aphasia2008 wrote:
    Although my web design vocabulary is rather poor, it would seem that the google results for the term "Javascript image rotator" seem to provide code which will rotate images with a timed transition.
    Yes, an image rotator changes the images on a timed basis. For a static image that changes just on page load, the term to search for would be JavaScript random image. But I see you have found a solution. You can often find a lot of help just by typing a brief description of what you want into a search engine. Dreamweaver doesn't have a behavior for random images.

  • Rotating images

    Hello,
    I have created a website which displays an image and have added a button which when is clicked will rotate the image. The problem I am having is that the page seems to be loading before the image is updated and the non rotated image is still displayed on the page. I don't think this is a caching problem because I tried appending a unique name to the image source for each page refresh and the old image still appears.
    The reason why I think that the page is refreshed before the image updated is because if I have a popup window to display before the page is refreshed and let it sit there for a short period of time the page refreshes correctly displaying the rotated image.
    Is there any way to halt the browser from refreshing before my java class is completely done writing out the image? My java class that does the rotation is called from a javaservlet if that helps...
    Thanks,
    -- George

    Ok, thats a little more info.
    Funny, your the first person I ever heard of that is using velocity rather than a real web langauge.
    Anyway, I think what your doing is confusing where and when what code should executed. Its a tremendously common misunderstanding.
    If you use a java servlet to get your image names, your going to have to have the page (or part of the page in a frame, iframe or somthing equally lame ) reload.
    If you want your page to have a different image load when somone hits a new link, then you can worry about vm code and getting servlet names, and you *wont use javascript.
    If you want to have an image appear when you highlight a link or have time pass or somthing, then you will use javascript completely to do this, and you will only use VM to write the names and populate the javascript array.
    ~kullgen

  • Rotated image overlaps other controls

    Hi, I am working on an AIR app involving images. One of the functionalities is viewing as well as rotating images. I made a simple test app to illustrate this portion:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
        <mx:Script>
            <![CDATA[
                private function rotate():void
                    var bitmap:Bitmap = Bitmap(img.content);
                    var matrix:Matrix = bitmap.transform.matrix;
                    var centerX:Number = bitmap.width/2;
                    var centerY:Number = bitmap.height/2;
                    matrix.translate(-centerX, -centerY);
                    matrix.rotate(90*Math.PI/180);
                    matrix.translate(centerY, centerX);
                    bitmap.transform.matrix = matrix;
            ]]>
        </mx:Script>
        <mx:Text width="100%" text="Some text"/>
        <mx:Image id="img" width="100%" height="100%" source="test.jpg" horizontalAlign="center" verticalAlign="middle"/>
        <mx:Button label="rotate 90" click="rotate()"/>
    </mx:WindowedApplication>
    The application window has text on the top and a button on the bottom, with the image in the middle. Each click of the button rotates the image by 90 degrees.
    On launch, the app works great. It fetches the image file and fits it to the Image container. As I resize the application, the image also resizes and maintains the position relative to the other controls. Top text and bottom button are where they should be. All good. Let's assume the image is landscape/wide. After I perform the rotate 90 degrees by clicking the button, although the image is rotated and now in portrait orientation, the bottom portion of the image is now out of the image boundary and overlapping the button.
    Is there a way to tell the image to fit the content to the container again? Basically, re-layout the whole thing as if the image is in this new orientation.
    I suppose I can try to figure out a change in scale and resize the image, but I am not sure if this will hold when the user resizes the application. Also, the rotated image is now rather far to the left, as the "top left" corner is where a landscape image would be. For a portait orientation that's centered horizontally, it should be further to the right. I suppose I can also come up with some formula to center the rotated image. It just seems that the application already has all this logic built in, as it did exactly what I wanted when the image was loaded initially. If I can just ask the application to do it again. Note that similar issue occurs if the image starts out in portrait orientation and is rotated to landscape (too far to the right).
    Thanks in advance for the help.
    Will

    Thanks Sheila and Arnis,
    Today I opened the project to try different zoom settings and the problem has vanished; I get the correct arrow at zooms of 100, 120 and 140%.
    Likely a bug somewhere deep in Frame's innards. Anyway we've ordered TCS3 so soon I'll be using FM10. Thanks anyway.
    --- Derek

  • I have a Flash Sample to rotate images and text but I not find a way to display special characters

    Hello everyone.
    I bought a very nice Flash application that rotate images, and text of any color and size. It use an XML input file.
    I've posted here, a complete copy, so any of you can download, view and use it freely.
    I would appreciate if any of you know how to do, so that the text displayed, including the characters I use in my language (Spanish), such as á, é, í, ó, ú, ñ, and other special characters.
    In fact, I could not find a way to do it, because I'm not expert Flash, and less in ActionScript.
    If any of you would help me on that, I thank you implement the appropriate adjustments and compressed into a. zip file, and let me know where to download it, or if you prefer you can send it to my email: [email protected]
    After all compressed in .zip format is a very small file: 430K.
    Click here to download the complete sample.
    Thanks.
    =====================================
    Translated using http://translate.google.es
    =====================================

    Hello Rinus,
    If I understood your last post correctly, then problem 2 is resolved, right?
    Regarding problem 3:
    I'm not asking you to share exact VIs.
    I just want to see a very simple VI that explains the concept of what you're trying to do, what should happen (this can be in words that refer to the front panel elements) and what you've tried.
    The terminology you're using isn't clear to me without an extra explanation.
    This could even be only a Front Panel with a few buttons on where you just describe what should happen with specific controls/indicators.
    Based on the first post it is not clear to me what you mean with:
    - A "button element":
      Are you talking about a control, an indicator, a cluster that contains multiple control?
    - The structure:
      Is this an event structure, case structure, for loop, ...?
    Is it seems like you want to programmatically control Front Panel objects, which on itself is no problem at all independent of how many objects you want to control.
    Please share with me simple example of what goes wrong and explain which things should happen on that specific Front Panel.
    This will allow me to help you and also allow me to guide you along the right path.
    Kind Regards,
    Thierry C - Applications Engineering Specialist Northern European Region - National Instruments
    CLD, CTA
    If someone helped you, let them know. Mark as solved and/or give a kudo.

  • Rotating Image with Fade Effect

    Ok looking to rotate an image with a fade effect; below is a rotating image code.
    (Wanting this effect to be transitional and smooth. Transparency? Opacity?)
    <script language="JavaScript">
    <!--
    function adArray() {
    for (i=0; i*2<adArray.arguments.length; i++) {
    this[i] = new Object();
    this[i].src = adArray.arguments[i*2];
    this[i].href = adArray.arguments[i*2+1];
    this.length = i;
    function getAdNum() {
    dat = new Date();
    dat = (dat.getTime()+"").charAt(8);
    if (dat.length == 1)
    ad_num = dat%ads.length;
    else
    ad_num = 0;
    return ad_num;
    var ads = new adArray(
    "img1.jpg","http://www.domain.com",
    "img2.jpg","http://www.domain.com",
    "img3.jpg","http://www.domain.com");
    var ad_num = getAdNum();
    document.write('<div align="center"><A HREF="'+ads[ad_num].href+'" target="_blank"><IMG SRC="'+ads[ad_num].src+'" '
    +'BORDER=0 name=js_ad></A></div>');
    link_num = document.links.length-1;
    function rotateSponsor() {
    if (document.images) {
    ad_num = (ad_num+1)%ads.length;
    document.js_ad.src = ads[ad_num].src;
    document.links[link_num].href = ads[ad_num].href;
    setTimeout("rotateSponsor()",4000);
    setTimeout("rotateSponsor()",4000);
    // -->
    </script>
    Any ideas?

    Here is the script I finally got working! It would have not came to me without your help guys!
    <script>
    var pictureWebPartName="Pictures"; // name of the picture library web part
    var showThumbnails = true; //otherwise show full sized images
    var randomImg = true; //set to true to show in random order
    var useCustomLinks = false; //true to use second column as URL for picture clicks
    var RotatingPicturesLoopTime = 5000; //2000 = 2 seconds
    var imgToImgTransition = 1.0; //2 = 2 seconds
    // don't change these
    var selectedImg = 0;
    var imgCache = [];
    var imgTag;
    function RotatingPictures()
    imgTag = document.getElementById("RotatingImage");
    //Find the picture web part and hide it
    var Imgs = [];
    var x = document.getElementsByTagName("TD"); // find all of the table cells
    var LinkList;
    var i=0;
    for (i=0;i<x.length;i++)
    if (x[i].title == pictureWebPartName)
    // tables in tables in tables... ah SharePoint!
    LinkList = x[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
    // hide the links list web part
    LinkList.style.display="none";
    break;
    if (!LinkList)
    document.all("RotatingImageMsg").innerHTML="Web Part '" + pictureWebPartName + "' not found!";
    //Copy all of the links from the web part to our array
    var links = LinkList.getElementsByTagName("TR") // find all of the rows
    var url;
    var len;
    for (i=0;i<links.length;i++)
    //if (links(i).id.match("row")!=null)
    if (links[i].childNodes[0].className=="ms-vb2")
    len=Imgs.length
    Imgs[len]=[]
    Imgs[len][0] = links[i].childNodes[0].childNodes[0].href;
    if (useCustomLinks)
    if (links[i].childNodes[1].childNodes.length>0)
    { Imgs[len][1] = links[i].childNodes[1].childNodes[0].href; }
    else
    { Imgs[len][1] = "" }
    if (Imgs.length==0)
    document.all("RotatingImageMsg").innerHTML="No images found in web part '" + pictureWebPartName + "'!";
    for (i = 0; i < Imgs.length; i++)
    imgCache[i] = new Image();
    imgCache[i].src = Imgs[i][0];
    if (useCustomLinks)
    imgCache[i].customlink=Imgs[i][1];
    RotatingPicturesLoop();
    // now show the pictures...
    function RotatingPicturesLoop()
    if (randomImg)
    selectedImg=Math.floor(Math.random()*imgCache.length);
    if (document.all){
    imgTag.style.filter="blendTrans(duration=" + imgToImgTransition + ")";
    imgTag.filters.blendTrans.Apply();
    url=imgCache[selectedImg].src
    if (useCustomLinks)
    { RotatingImageLnk.href=imgCache[selectedImg].customlink; }
    else
    { RotatingImageLnk.href = url; }
    if (showThumbnails)
    // convert URLs to point to the thumbnails...
    // from airshow%20pictures/helicopter.jpg
    // to airshow%20pictures/_t/helicopter_jpg.jpg
    url = revString(url);
    c = url.indexOf(".");
    url = url.substring(0,c) + "_" + url.substring(c+1,url.length);
    c = url.indexOf("/");
    url = url.substring(0,c) + "/t_" + url.substring(c,url.length);
    url = revString(url) + ".jpg";
    imgTag.src = url;
    if (document.all){
    imgTag.filters.blendTrans.Play();
    selectedImg += 1;
    if (selectedImg > (imgCache.length-1)) selectedImg=0;
    setTimeout(RotatingPicturesLoop, RotatingPicturesLoopTime);
    // utility function revString found here:
    // http://www.java2s.com/Code/JavaScript/Language-Basics/PlayingwithStrings.htm
    function revString(str) {
    var retStr = "";
    for (i=str.length - 1 ; i > - 1 ; i--){
    retStr += str.substr(i,1);
    return retStr;
    // add our function to the SharePoint OnLoad event
    _spBodyOnLoadFunctionNames.push("RotatingPictures");
    </script>
    <!-- add your own formatting here... -->
    <center>
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td id="VU" height="125" width="160" align="center" valign="middle">
    <a name="RotatingImageLnk" id="RotatingImageLnk" alt="click for larger picture">
    <img src="/_layouts/images/dot.gif" name="RotatingImage" id="RotatingImage" border=0>
    </a>
    <span name="RotatingImageMsg" id="RotatingImageMsg"></span>
    </td>
    </tr>
    </table>
    </center>
    Thanks again guys!

  • How to auto rotate Images on Full Screen Slideshow if pictures were taken mixed Portrait and Landsca

    In Muse: How to auto rotate Images on Full Screen Slideshow if pictures were taken mixed Portrait and Landscape

    There is no way that Muse would automatically rotate the images. What you can instruct Muse to do is whether you want to show all image content and leave blank space in either direction OR scale the image to fill the frame resulting in some cropping, but filling the otherwise blank space.
    The options are Fit Content Proportionally and Fill Frame Proportionally respectively.
    Cheers,
    Vikas

  • Rotating Images in a grid or canvas

    I want to build a component somewhat similar with the
    rotating images that you can see below.
    http://www.istockphoto.com/index.php
    Thanks in advance,
    Q

    Here is a place to start:
    http://weblogs.macromedia.com/pent/archives/2007/10/component_class_2.cfm
    Tracy

  • Rotating images in separate htm document (DW CS4)

    Hi all,
    A few questions:
    1. I created a rotating images htm document by using the swap image function and then changing the code a bit (found this on internet). This works just fine on my PC (LiveView) and the htm document is switching between 3 images. I have placed the document in the images folder. However, when uploaded it doesnt work:
    http://www.competenciagroup.com/images/RotatingImages.htm
    2. If i get this htm document to work on the net I would like to input the htm document with the rotating images into the heading of my main document:
    http://www.competenciagroup.com/ColombiaTravel/index.html
    (just above the menu)
    I could not though figure out how to input the htm document into the existing html document.
    Anybody have any clue on the 2 questions above?
    Thanks in advance,
    Ingvar Malde

    I know plenty of people run into the issue of not being able to see their images while in design view, but mine is the exact opposite.
    My images show up as a tiny blue question mark box in Live View... As well as when I preview it in a browser localy on my machine.
    I think I know why it might be happening but dont know how to fix it...
    When I insert an image DW codes it as such:
    <img src="/images/madintro.jpg" width="470" height="267" />
    The problem seems to lie in DW adding the "/" in front of "images"
    when I manually go in and take out the "/" the image shows magically shows up as it should.
    Why has dreamweaver suddenly defaulted to making bad code? what did I do to cause this issue? And obviously how can I change it back to work again and make the image show in my DW workspace?
    Yes, the slash is exactly the problem. That is known as a Site-root relative link.These types of link are good to use in Templates because they are always the same. They don't need to be "fixed' when you generate a page from your Template into a different folder.
    The downside of using Site-root reltive links, is that you can't access the files locally. You must get the page from a web server. One exception to that is using Preview in Browser (PIB) "Temp" files.
    Read this Tech Note about setting up a Testing Server so you can see these files in Live View and PIB:
    http://blogs.adobe.com/dreamweaver/2008/12/live_view_and_siteroot_relativ.html
    If you want to switch back to using Document relative links, then setthe Relative to: field to be "Document" in the "Browse for file" dialog (folder button next to Link field in PI). This setting is sticky, so all future link will use the same setting.
    Hope this helps,
    Randy

  • Rotate images DURING import

    To be able to rotate images DURING import would be a nice feature. I can do this with Apple's Image Capture. They are imported wih the rotation I have requested, and this show in the icons too.
    I like popping a folder open and view my images in icon view. I don't have to open a program at all. It's quick and efficent way to view my images, but also the orientation is correct right from the beginning with the original. Maybe one more step in the import process, for those of us who don't mind it, BUT it's also one more step I DON"T have to do in Lightroom, Photoshop, or any other program. And the rotataion in Lightroom are temporary to the eye anyway.
    This is good feature/option to add to the import. Lightroom ROCKS. It just elimanted a multi-step, multi-software import process. Almost. The "rotate during import" feature would seal the deal. It's a big deal to me. Like the Apple Image Capture, you could place rotation icons on each image in the preview window. If you added that, man, solid gold!
    thanks,
    Craig

    DW Harrison:
    Sure, I get that, but I can understand how non-destructive editing is useful in image adjustments where later you may regret having added too much saturation in the reds, so you're glad you can go back to the original. But who wants a portrait image rotated in landscape orientation EVER? It's a personal preference, and, no, not a priority in my opinion.
    Ian:
    You may think your post was enlightening, but, perhaps to someone else. Surely not me. I've always known what the 'real cause' is -- some software, i.e. WEB BROWSWERS, ignore the EXIF tag. Hence, my question was more of a philosophical one: why have portrait images rotated sideways, only to have aware applications ON-THE-FLY rotate them according to the EXIF tag? Why not just have the original file re-written in different dimensions?
    For that matter, I specifically spelled out 'why can't... [the file be] rewritten from 800x600 to 600x800'. Hence I find your response 'They will be if the rotation tag is set in the camera' pretty darn irrelevant. No, they WON'T be rewritten rotated. Only by Graphic Converter if you have the option selected, or other applications that don't come to mind right now.

  • Need Help In Solving Rotation Image Problem

    1 down vote favorite
    Hi guys ,
    I need your help please. I have spent hours trying to solve it but not working.
    I have an image i am rotating when the user clicks on a button. But it is not working.
    I would like to see the image rotating gradually till it stops but it doesn't. This it what it does. After i click the button, i don't see it rotating. But when i minimize and maximize the main window, i see the image just rotate(flip) fast like that. It does the rotation but i don't see it as it is doing. It just rotate in a second after minimize and maximize the main window.
    I thimk the problem deals with updating the GUI as it is rotating but i don't know how to fix it.
    these are the code . Please i have trimed down the code for easy reading.
    public class KrusPanel extends JPanel{
         private Image crossingImage;
         private int currentRotationAngle;
         private int imageWidth;
         private int imageHeight;
         private AffineTransform affineTransform;
         private boolean clockwise;
         private static int ROTATE_ANGLE_OFFSET = 2;
         private int xCoordinate;
         private int yCoordinate;
         private javax.swing.Timer timer;
         private void initialize(){
          this.crossingImage = Toolkit.getDefaultToolkit().getImage("images/railCrossing3.JPG");
          this.imageWidth = this.getCrossingImage().getWidth(this);
          this.imageHeight = this.getCrossingImage().getHeight(this);
          this.affineTransform = new AffineTransform();
          this.setCurrentRotationAngle(90);
          timer = new javax.swing.Timer(20, new MoveListener());
    public KrusPanel (int x, int y) {
      this.setxCoordinate(x);
      this.setyCoordinate(y);
      this.setPreferredSize(new Dimension(50, 50));
      this.setBackground(Color.red);
      TitledBorder border = BorderFactory.createTitledBorder("image");
      this.setLayout(new FlowLayout());
      this.initialize();
    public void paintComponent(Graphics grp){
               Rectangle rect = this.getBounds();
               Graphics2D g2d = (Graphics2D)grp;
               g2d.setColor(Color.BLACK);
               this.getAffineTransform().setToTranslation(this.getxCoordinate(), this.getyCoordinate());
               this.getAffineTransform().rotate(Math.toRadians(this.getCurrentRotationAngle()), this.getCrossingImage().getWidth(this) /2,
                                       this.getCrossingImage().getHeight(this)/2);
              g2d.drawImage(this.getCrossingImage(), this.getAffineTransform(), this);
    public void rotateCrossing(){
                 this.currentRotationAngle += ROTATE_ANGLE_OFFSET;
                 int test = this.currentRotationAngle % 90;
                 if(test == 0){
                  this.setCurrentRotationAngle(this.currentRotationAngle);
                  timer.stop();
             repaint();
      private class MoveListener implements ActionListener {
             public void actionPerformed(ActionEvent e) {
                rotateCrossing();
                repaint();
    //  There are getters and setters method here but i have removed them to make the code shorter.
    }Next 2 Classes
    // I have removed many thins in this class so simplicity. This class is consists of Tiles of BufferdImage and the
    // KrusPanel class is at the array position [2][2]. It is the KrusPanel class that i want to rotate.
    public class SeePanel extends JPanel{
          private static KrusPanel crossing;
          private void initializeComponents(){
       timer = new javax.swing.Timer(70, new MoveListener());
       this.crossing = new CrossingPanel(261,261);
        public SeePanel(){
      this.initializeComponents();
         public void paintComponent(Graphics comp){
       super.paintComponent(comp);
      comp2D = (Graphics2D)comp;
      BasicStroke pen = new BasicStroke(15.0F, BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND);
         comp2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                 RenderingHints.VALUE_ANTIALIAS_ON);
         comp2D.setPaint(Color.red);
         comp2D.setBackground(Color.WHITE);
         comp2D.drawImage(img, 0, 0, null);
         comp2D.draw(this.horizontalRail);
         this.crossing.paintComponent(comp2D);
         this.rob.drawRobot(comp2D);
      public static void rotateCrossing(){
       this.crossing.getTimer().start();
       repaint();
    // i tried below code also it didn't work. so i put them in comments
       Runnable rotateCrossing1 = new Runnable(){  // to be removed
             public void run() {
            crossing.getTimer().start();
          SwingUtilities.invokeLater(rotateCrossing1);
    // MAIN CLASS
    // This is the GUI class which consists of buttons and others
    public class MainAPP{
       SeePanel = new SeePanel();
      // Buttons declarations here and others
    public MainAPP(){
      // all listener registers here
    // Here i call the rotateCrossing() of the SeePanel class but it is not working as i want.
    // I would like to see the image rotating gradually till it stops but it doesn't.
    //This it what it does. After i click the button, i don't see it rotating. But when i minimize and maximize the main window,
    // i see the image  just rotate(flip) fast like that.
    public void actionPerformed(ActionEvent e){
        SeePanel.rotateCrossing();                 
        public static main(string[] str){
    }Please do help me to fix it.
    thanks

    kap wrote:
    1 down vote favoriteHuh?
    ..Please i have trimed down the code for easy reading. ..Perhaps I am just lazy, but I don't actually like reading code until I've seen it compile in my editor & run. That is why I will advise that for better help sooner, post an SSCCE. For SSCCEs that use images, either generate an image in the code, or hot-link to an image available on the internet. I offer some [images at my site|http://pscode.org/media/#image] that you can hot-link to.

  • Rotate Image - iOS CameraUI

    Hello!
    I am trying to do the follow steps using CameraUI in iOS:
    1. Take a photo
    2. Show photo in the screen
    3. Rotate this photo
    4. Save the rotated photo in the CameraRoll
    to do that i wrote the follow code:
    Class Camera
    import ……..;
    private var camera:CameraUI;
    private var roll:CameraRoll;
    private var mpLoader:Loader;
    private var mediaPromise:MediaPromise;
    private var bitmapData:BitmapData;
    private var loaderInfoData:LoaderInfo;
    private var dataSource:IDataInput;
    private var tempDir:File;
    private var file:File;
    private var mediaBytes:ByteArray;
    private var ld:Loader;   
    private var stream:FileStream;
    public function showCamera():void{  
         if (CameraUI.isSupported){                
              camera = new CameraUI();
              camera.addEventListener(MediaEvent.COMPLETE, onComplete);
              camera.addEventListener(Event.CANCEL,onCancel);
              mediaType = medType;
              camera.launch(MediaType.IMAGE);
    private function onCancel(event:Event):void{
         dispatchEvent(event);
    private function onComplete(event:MediaEvent):void{
         var cameraUI:CameraUI = event.target as CameraUI;
         cameraUI.removeEventListener(MediaEvent.COMPLETE, onComplete);
         cameraUI.removeEventListener(Event.CANCEL, onCameraUICanceled);
         mediaPromise = event.data;
         if(mediaPromise.isAsync){
              //Async systems(IOS)          
              dataSource = mediaPromise.open();
              var eventSource:IEventDispatcher = dataSource as IEventDispatcher;
              eventSource.addEventListener(Event.COMPLETE, onMediaLoaded);
         }else{
              //Sync systems(android)
              file = mediaPromise.file;
              dispatchEvent(event);
    private function onMediaLoaded(event:Event):void{
         mediaBytes = new ByteArray();
         dataSource.readBytes(mediaBytes);             
         tempDir = File.createTempDirectory();
         var now:Date = new Date();
         var filename:String;
         filename = now.fullYear + now.month + now.day+now.hours + now.minutes + now.seconds + ".JPG";
         file = tempDir.resolvePath(filename);
         //writing temporal file to display image
         stream = new FileStream();
         stream.open(file,FileMode.WRITE);
         stream.writeBytes(mediaBytes);
         stream.close();
         if(file.exists){
              //go to process to get BitmapData for Add to CameraRoll
              mpLoader = new Loader();
          mpLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onMediaLoadedBitmapData);
              mpLoader.loadBytes(mediaBytes);
    private function onMediaLoadedBitmapData(event:Event):void{
         var loaderInfo:LoaderInfo = LoaderInfo(event.target);
         bitmapData = new BitmapData(loaderInfo.width,loaderInfo.height,false,0xFFFFFF);
         bitmapData.draw(loaderInfo.loader);
         //Image rotate process
         var matrix:Matrix = new Matrix();
         matrix.translate(-bitmapData.width / 2, -bitmapData.height / 2);
         matrix.rotate(90 * (Math.PI / 180));
         matrix.translate(bitmapData.height / 2, bitmapData.width / 2);
         var matriximage:BitmapData = new BitmapData(bitmapData.height, bitmapData.width, false, 0x00000000);
         matriximage.draw(bitmapData, matrix);    
         mediaBytes = matriximage.getPixels(matriximage.rect);                             
         //I used the next code but doesn't work
         //var jpgencode:JPEGEncoder = new JPEGEncoder(85);
         //mediaBytes = jpgencode.encode(matriximage);
         bitmapData = matriximage;
         //Re-Writing image with rotate ByteArray
         stream.open(file,FileMode.WRITE);
         stream.writeBytes(mediaBytes);
         stream.close();
         //Add Rotate image to CameraRoll
         addingToCameraRoll();
    public function addingToCameraRoll():void{
         var result:String="";
         if(CameraRoll.supportsAddBitmapData){
              if(bitmapData!=null){
                    roll = new CameraRoll();
                    roll.addEventListener(Event.COMPLETE,onCompleteAddBitMapData);
                    roll.addBitmapData(bitmapData);
                    var me:MediaEvent = new MediaEvent(MediaEvent.COMPLETE);
                    dispatchEvent(me);
    When I run my app, at the time when the image is copied to CameraRoll prompts an error:
    Error #2044: Unhandled ErrorEvent:. text=Error #3004: Insufficient file space.
           at ....
    Debugging and doign some test I found that the size of ByteArray "mediaBytes.bytesAvailable" (1162439)  is shorter than "matriximage.getPixels(matriximage.rect)" (12582912),  the images that was saved in CameraRoll is in the correct way, but the second file (temporal file) is not saved, and I can use the file to show it in the screen.
    I want to know if exists another way to rotate and show and image in iOS or what I am doing wrong.

    I have the same issue

  • Rotating Image With Reflections

    A few years back I bought a manual for Director 6.0. In the
    back of the manual there was a demo disc showing some samples of
    other people's work. One of the samples was called Big Top. It was
    a totating logo in shinny gold, and as it rotated, you would see
    reflections of objects and light on the surface. At one Time I
    asked how it was done, and was told that an ap called RayDream
    Designer could do it. I was told that in that ap, you could draw a
    3D room, with the four walls, floor and ceiling, and when you
    placed an object in the center of the room and rotated it, you
    would end up with a rotating image with the reflection from the
    walls. I never tried it, and long ago RayDream Designer stopped
    being supported. Recently, I was told that the same thing could be
    done with Photoshop or Flash, but I have not figured out how it is
    done. What I want to do, is create a 3D image of a logo in gold,
    chrome, or somethign reflective, and have it rotate with the
    reflections as it rotates. I have seen similar thing on TV
    commercials, but I think I need a little help on figuring out how
    this is done.

    A few years back I bought a manual for Director 6.0. In the
    back of the manual there was a demo disc showing some samples of
    other people's work. One of the samples was called Big Top. It was
    a totating logo in shinny gold, and as it rotated, you would see
    reflections of objects and light on the surface. At one Time I
    asked how it was done, and was told that an ap called RayDream
    Designer could do it. I was told that in that ap, you could draw a
    3D room, with the four walls, floor and ceiling, and when you
    placed an object in the center of the room and rotated it, you
    would end up with a rotating image with the reflection from the
    walls. I never tried it, and long ago RayDream Designer stopped
    being supported. Recently, I was told that the same thing could be
    done with Photoshop or Flash, but I have not figured out how it is
    done. What I want to do, is create a 3D image of a logo in gold,
    chrome, or somethign reflective, and have it rotate with the
    reflections as it rotates. I have seen similar thing on TV
    commercials, but I think I need a little help on figuring out how
    this is done.

Maybe you are looking for

  • Getting a Family Members Apple Text Messages

    I was sharing an Apple ID with my husband (not sure why, because I have my own.)  It was never a problem until I upgrade to iOS6.  Now I'm seeing Apple Messages that others send to him on my phone.  I changed my iTunes and Store to use my own ID, but

  • Please help on installing windows 7 on late 2013 imac 27"!!!

    I am using imac 27" late 2013. I tried installing windows 7 64bit using boot camp assistant and it went well. I also download the latest bootcamp 5. However i cant install bootcamp on the new windows 7. Anyone have the same problem?

  • Logic of array and plotting functions?

    Hi, I started to build versatile acquisition programn with labview (with NI cards it seemed to be the best option) and it took quite an effort to adjust the way of thinking while shifting from other programming environments. I start to see the logic

  • How-to insert a database form in dreamweaver cc

    Hi im trying to insert o conect a database created in wamp server into a contact form in a webpage in dreamweaver cc, i don't know how to do it in this version of dreamweaver, i really apreciate if someone could help me

  • ITunes 6.0.3 Won't Open!

    I have just installed iTunes 6.0.3 and it won't open when I try to open it. I tried plugging my iPod in to see if that would open it but it wouldn't. It isn't a problem with privileges becuase I am my system administrator and it isn't firewall proble