Loader + Math.Random: why is NombrAl not load random images

Why this code does NOT load a random image, despite the random number of tracing?

package {}

import flash.display.Loader;

import flash.display.Sprite;

import flash.events. *;

import flash.net.URLRequest;

import flash.display.MovieClip;

SerializableAttribute public class LoaderExampleTwo extends Sprite {}

public var randomNumber:Number = new Number();

private var url: String = "D:/flash cs5.5/flash_help_examples/images/"+randomNumber+".jpg";

public void LoaderExampleTwo() {}

NombrAl = Math.ceil (Math.random () * 2);

trace (randomNumber);

var loader: Loader = new Loader();

configureListeners (loader.contentLoaderInfo);

loader.addEventListener (MouseEvent.CLICK, clickHandler);

var request: URLRequest = new URLRequest (url);

Loader.Load (request);

addChild (loader);

}

private void configureListeners(dispatcher:IEventDispatcher):void {}

dispatcher.addEventListener (Event.COMPLETE, completeHandler);

dispatcher.addEventListener (HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

dispatcher.addEventListener (Event.INIT, initHandler);

dispatcher.addEventListener (IOErrorEvent.IO_ERROR, ioErrorHandler);

dispatcher.addEventListener (Event.OPEN, openHandler);

dispatcher.addEventListener (ProgressEvent.PROGRESS, progressHandler);

dispatcher.addEventListener (Event.UNLOAD, unLoadHandler);

}

private void completeHandler(event:Event):void {}

trace ("completeHandler:" + event);

}

private void httpStatusHandler(event:HTTPStatusEvent):void {}

trace ("httpStatusHandler:" + event);

}

private void initHandler(event:Event):void {}

trace ("initHandler:" + event);

}

private void ioErrorHandler(event:IOErrorEvent):void {}

trace ("ioErrorHandler:" + event);

}

private void openHandler(event:Event):void {}

trace ("openHandler:" + event);

}

private void progressHandler(event:ProgressEvent):void {}

trace ("progressHandler: bytesLoaded =" + event.bytesLoaded + "bytesTotal =" + event.bytesTotal);

}

private void unLoadHandler(event:Event):void {}

trace ("unLoadHandler:" + event);

}

private void clickHandler(event:MouseEvent):void {}

trace ("clickHandler:" + event);

var loader: Loader = Loader (event.target);

Loader.Unload ();

}

}

}

Try:

package {}

import flash.display.Loader;

import flash.display.Sprite;

import flash.events. *;

import flash.net.URLRequest;

import flash.display.MovieClip;

SerializableAttribute public class LoaderExampleTwo extends Sprite {}

public var randomNumber:Number = new Number();

private var url: String

public void LoaderExampleTwo() {}

NombrAl = Math.ceil (Math.random () * 2);

trace (randomNumber);

URL = "D:/flash cs5.5/flash_help_examples/images/"+randomNumber+".jpg";

var loader: Loader = new Loader();

configureListeners (loader.contentLoaderInfo);

loader.addEventListener (MouseEvent.CLICK, clickHandler);

var request: URLRequest = new URLRequest (url);

Loader.Load (request);

addChild (loader);

}

private void configureListeners(dispatcher:IEventDispatcher):void {}

dispatcher.addEventListener (Event.COMPLETE, completeHandler);

dispatcher.addEventListener (HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

dispatcher.addEventListener (Event.INIT, initHandler);

dispatcher.addEventListener (IOErrorEvent.IO_ERROR, ioErrorHandler);

dispatcher.addEventListener (Event.OPEN, openHandler);

dispatcher.addEventListener (ProgressEvent.PROGRESS, progressHandler);

dispatcher.addEventListener (Event.UNLOAD, unLoadHandler);

}

private void completeHandler(event:Event):void {}

trace ("completeHandler:" + event);

}

private void httpStatusHandler(event:HTTPStatusEvent):void {}

trace ("httpStatusHandler:" + event);

}

private void initHandler(event:Event):void {}

trace ("initHandler:" + event);

}

private void ioErrorHandler(event:IOErrorEvent):void {}

trace ("ioErrorHandler:" + event);

}

private void openHandler(event:Event):void {}

trace ("openHandler:" + event);

}

private void progressHandler(event:ProgressEvent):void {}

trace ("progressHandler: bytesLoaded =" + event.bytesLoaded + "bytesTotal =" + event.bytesTotal);

}

private void unLoadHandler(event:Event):void {}

trace ("unLoadHandler:" + event);

}

private void clickHandler(event:MouseEvent):void {}

trace ("clickHandler:" + event);

var loader: Loader = Loader (event.target);

Loader.Unload ();

}

}

}

Tags: Adobe Animate

Similar Questions

  • Why can I not see the image in my account until I saw it?

    When I go into my pictures folder and I click on the folder with images of a certain date, the pictures do not show up until you click on it. When I click on it, I don't know even what image will appear. It's almost as if she has not yet loaded, but it does not load never wait another hour. Thank you!

    Open your my pictures location, click on organize in the upper left corner, click on folder and search options, click the view tab and uncheck the top option, always display icons and never thumbnails, select apply and then search for and check the show the hidden folders, folders and readers and click on apply and save.

    Return to your location of my pictures, change the display of the page on the top of the right side next to the question mark symbol, there is another symbol with a menu drop-down symbol, click it and select the medium or large icons options specified.

    If you have mcafee look in this announcement.

    http://service.McAfee.com/faqdocument.aspx?ID=TS101228

    There is another parameter to another location that you can change if the results above in no joy.

    Control Panel, look for and click on system,

    At the top left click on advanced system settings,

    On the performance section click the settings button.

    Search and select Show thumbnails and icons, apply and OK.

  • Why FrameMaker can not find an image when I change of location of the work?

    I have several books located in a system directory that contains multiple images.  Some images are therefore repeated in books, I have a place (another directory of system) where I import as required in each book.  Asked me to move these books of the directory system to my local hardrive.   I have copied all books, files, etc., the image exactly as they were in the new location on my hardrive in the system directory.  When I open the books in the new location on my hardrive, FrameMaker is unable to locate these images and I get an error screen, and the missing file dialog box.   When I import images I always select copy in the document - I wonder why FrameMaker is unable to find the image even if the directory structure has been copied exactly and also because I copied the image - I does refer to them?    I've attached a screenshot of the missing file error I get.missing file screen.png

    > I copied all the books, etc., the image exactly files as they were in the new location of the directory of system...

    Open them to the old location (source) and the re - save to the new location. FM update paths when you do this.

    What platform are you on?

    Are missing imports in the same directory?

    UNIX FM is bad on learning new ways. FM of Windows seem to learn.

    But if by import paths vary, the platform will not matter much.

  • Why can I not see the Images that I just uploaded?

    Hi all! I recently installed Lightroom 3 on another computer and am unable to see the images that are imported.  Any suggestions?  Currently I am them see as gray boxes with no displayable picture.  They do not display a broken image or missing link.  Any reason why this is happenning?

    You can see all the images in this catalogue on the new machine? If you can not see my second point.

    HAL

  • Why didn't - not Adobe Stock image that appears on the web site?

    Adobe Stock image does not appear on the website when downloaded. It appears on the computer local and other machines on the same network. Any information would be greatly appreciated.

    Yep, that's what I get... very nice job on the site, by the way.

    As I say, try refreshing your browser.

  • Why can I not select the image clicked in the Timeline?

    Can someone give me a heads up as to why I wouldn't be able to click on the image clicked in the timeline in order to y to insert an image? I click, but nothing happens.

    Right-click and choose Insert keyframe

  • Why can I not see text/images on incoming PDF files

    @I using Windows 7, 64-bit operating system. Until recently, whenever I received a PDF, text or image file, I always saw the content in my Adobe Reader X 1. I decided to buy Acrobat X Standard to use for my graphics projects. Now Acrobat is still running when I click on an incoming PDF file and get the gray boxes instead of the content of the document. I can't see or read the content of the PDF. Is there a way to fix this problem?

    Thank you.

    Joyce Cruzat, [email protected]

    Hi Joyce,

    Please try this:

    1. Choose Edition > Preferences in Acrobat.
    2. Click on the category to the page.
    3. Make sure that display large Images is selected in the content section of the Page and the Information.
    4. Click OK.

    Who did the trick?

    Best,
    Sara

  • Why can I not see my images in Photoshop?

    I bought a new computer and installed creative cloud and my applications Photoshop and Lightroom. After installing, everything seems to work properly. The next day, I get a black picture, but my diapers are there. It is my second computer on that my apps are installed. My old computer has 32-bit, new 64-bit computer. What Miss me?

    Your graphics driver is inadequate. You need to install a compatible version and set it up properly. otehrwise, you can disable OpenGL drawing under preferences--> Performance--> hardware acceleration. Change drawing modes the Advanced button uder it could also help already.

    Mylenium

  • Do not see my images in the Windows 7 preview pane

    WHY CAN I NOT SEE MY IMAGES IN THE PREVIEW PANE WITHOUT HAVING TO RIGHT CLICK AND THEN SELECT PREVIEW OR JUST OPEN THE FILE? IS THERE A SETTING WHERE I CAN JUST HOVER CURSOR OVER THE ICON AND I CAN GET A PREVIEW OF THE PHOTOS? I'VE SEEN THIS DONE ON OTHER PEOPLES COMPS RUNNING WIN7

    * original title - PANE PREVIEW (PHOTOS) HELP!   PLEASE.*

    You can't right click, you have to click once to highlight the file you want to preview.

    However, you must have installed preview Manager program.  Windows can preview most of the images (jpg, bmp, gif), but others, like the photoshop files, need another program installed.
  • Random BSOD and I do not know why.__Unable to load the image \SystemRoot\system32\ntoskrnl.exe, 0n2 error Win32

    I don't know why this is happening, but I'm getting random BSOD now and then. I tried to point out my system to see if it generates a BSOD, but multitasking 3d and photoshop programs and what's not stress, then when I least expect, BANG! BSOD.
    The last of them, that I had now was in the middle of the night with almost no programs running. The system had worked for some time (one or two days), but nothing was he pointing out at the same time.

    What I think happened was: our microwave shorted out and caused a fuse to blow. But it was on another grid in our House (I hope I make myself clear, because I'm not used to talk about stuff like this in English!) so it should not affect my computer. But at the same time my microwave said "Thank you for everything!" my computer would BSOD. The thing is that my modem, my switch, my router and my NAS is connected to the electric network and my short circuted of switch. And my computer is connected to the switch cable.
    This effect possible that excess tension (or something) has short circuted my switch and 'jumped' power to the switch and on the cable and sending there is a shock to my computer? Or am I just paranoid? Laughing out loud

    I know that the controllers are pushed to the limit of the memory and therefor tolerate very little when it comes to electricity. I ran MemTest4.00 14 passes but I came with nothing. But memtest that tests memory, not the controllers, right? I am watching a fried motherboard?

    I did a windb, but I don't understand what he says. Could someone please translate this for me and give me your opinion?
    In addition, when you run windb, it's tell me am I wrong symbols. -What this means, and where can I get the symbols he wants? And what symbols?

    Microsoft (R) Windows debug 6.12.0002.633 AMD64 Version
    Copyright (c) Microsoft Corporation. All rights reserved.

    Loading dump file [C:\Windows\Minidump\Mini042910-01.dmp]
    The mini kernel dump file: only registers and the trace of the stack are available

    Symbol search path is: * invalid *.
    ****************************************************************************
    * Loading of the symbol may be unreliable without a symbol search path.           *
    * Use .symfix to get the debugger to choose a symbol path.                   *
    * After adjusting your path to symbols, use .reload to refresh the locations of symbols. *
    ****************************************************************************
    Executable search path is:
    *********************************************************************
    * Symbols cannot be loaded because the path is not initialized. *
    *                                                                   *
    * The symbol path can be defined: *.
    * using the _NT_SYMBOL_PATH environment variable.                 *
    * with the help of the there when you start the debugger argument. *.
    * using the .sympath and .sympath + *.
    *********************************************************************
    Cannot load the image \SystemRoot\system32\ntoskrnl.exe, 0n2 error Win32
    WARNING: Unable to verify timestamp for ntoskrnl.exe
    ERROR: Module load completed but symbols can be loaded for ntoskrnl.exe
    Windows Server 2008/Windows Vista Kernel Version 6002 (Service Pack2) MP (4 procs) free x 64
    Product: WinNt, suite: TerminalServer SingleUserTS
    Computer name:
    Kernel base = 0xfffff800 '02c4c000 PsLoadedModuleList = 0xfffff800' 02e10dd0
    The debugging session: 23:43:16.368 Thursday, April 29, 2010 (UTC + 02:00)
    System Uptime: 3 days 5:21:50.657
    *********************************************************************
    * Symbols cannot be loaded because the path is not initialized. *
    *                                                                   *
    * The symbol path can be defined: *.

    * using the _NT_SYMBOL_PATH environment variable.                 *
    * with the help of the there when you start the debugger argument. *.
    * using the .sympath and .sympath + *.

    *********************************************************************
    Cannot load the image \SystemRoot\system32\ntoskrnl.exe, 0n2 error Win32
    WARNING: Unable to verify timestamp for ntoskrnl.exe
    ERROR: Module load completed but symbols can be loaded for ntoskrnl.exe
    Loading the kernel symbols
    ...............................................................
    ................................................................
    ................................................
    Loading user symbols
    Loading unloaded module list
    ......
    *******************************************************************************
    *                                                                             *
    * Bugcheck analysis *.
    *                                                                             *
    *******************************************************************************

    Use! analyze - v to obtain detailed debugging information.

    Bugcheck A, {fffffa7fffffffea, 2, 0, fffff80002c5a95c}

    The kernel symbols are FALSE. Correct symbols to do the analysis.

    *************************************************************************
    ***                                                                   ***
    ***                                                                   ***
    Your debugger is not using the appropriate symbols *.
    ***                                                                   ***
    In order for this command works correctly, your symbol path *.
    should point to .pdb files have the type information complete.      ***
    ***                                                                   ***
    Some (such as the public OS symbols) .pdb files are not *.
    contain the required information.  The contact group that *.
    you provided with these symbols, if you need this command for *.
    work.                                                          ***
    ***                                                                   ***
    Type referenced: nt! _KPRCB *.
    ***                                                                   ***
    *************************************************************************
    *************************************************************************
    ***                                                                   ***
    ***                                                                   ***
    Your debugger is not using the appropriate symbols *.
    ***                                                                   ***
    In order for this command works correctly, your symbol path *.
    should point to .pdb files have the type information complete.      ***
    ***                                                                   ***
    Some (such as the public OS symbols) .pdb files are not *.
    contain the required information.  The contact group that *.
    you provided with these symbols, if you need this command for *.
    work.                                                          ***
    ***                                                                   ***
    Type referenced: nt! _KPRCB *.
    ***                                                                   ***
    *************************************************************************
    *************************************************************************
    ***                                                                   ***
    ***                                                                   ***
    Your debugger is not using the appropriate symbols *.
    ***                                                                   ***
    In order for this command works correctly, your symbol path *.
    should point to .pdb files have the type information complete.      ***
    ***                                                                   ***
    Some (such as the public OS symbols) .pdb files are not *.
    contain the required information.  The contact group that *.
    you provided with these symbols, if you need this command for *.
    work.                                                          ***
    ***                                                                   ***
    Type referenced: nt! _KPRCB *.
    ***                                                                   ***
    *************************************************************************
    Probably caused by: ntoskrnl.exe (nt + e95c)

    Follow-up: MachineOwner
    ---------

    0: kd >! analyze - v
    *******************************************************************************
    *                                                                             *
    * Bugcheck analysis *.
    *                                                                             *
    *******************************************************************************

    IRQL_NOT_LESS_OR_EQUAL (a)
    An attempt was made to access an address pageable (or completely invalid) to a
    application interrupt level (IRQL) that is too high.  It is usually
    caused by drivers using a wrong address.
    If a kernel debugger is available, download the stack trace.
    Arguments:
    Arg1: fffffa7fffffffea, memory referenced
    Arg2: 0000000000000002, IRQL
    Arg3: 0000000000000000, bit field:
    bit 0: value 0 = read operation, 1 = write operation
    bit 3: value 0 = not an enforcement operation, 1 = performance operation (only on chips that support this level of State)
    Arg4: fffff80002c5a95c, address memory

    Debugging information:
    ------------------

    The kernel symbols are FALSE. Correct symbols to do the analysis.

    *************************************************************************
    ***                                                                   ***
    ***                                                                   ***
    Your debugger is not using the appropriate symbols *.
    ***                                                                   ***
    In order for this command works correctly, your symbol path *.
    should point to .pdb files have the type information complete.      ***
    ***                                                                   ***
    Some (such as the public OS symbols) .pdb files are not *.
    contain the required information.  The contact group that *.
    you provided with these symbols, if you need this command for *.
    work.                                                          ***
    ***                                                                   ***
    Type referenced: nt! _KPRCB *.
    ***                                                                   ***
    *************************************************************************
    *************************************************************************
    ***                                                                   ***
    ***                                                                   ***
    Your debugger is not using the appropriate symbols *.
    ***                                                                   ***
    In order for this command works correctly, your symbol path *.
    should point to .pdb files have the type information complete.      ***
    ***                                                                   ***
    Some (such as the public OS symbols) .pdb files are not *.
    contain the required information.  The contact group that *.
    you provided with these symbols, if you need this command for *.
    work.                                                          ***
    ***                                                                   ***
    Type referenced: nt! _KPRCB *.
    ***                                                                   ***
    *************************************************************************
    *************************************************************************
    ***                                                                   ***
    ***                                                                   ***
    Your debugger is not using the appropriate symbols *.
    ***                                                                   ***
    In order for this command works correctly, your symbol path *.
    should point to .pdb files have the type information complete.      ***
    ***                                                                   ***
    Some (such as the public OS symbols) .pdb files are not *.
    contain the required information.  The contact group that *.
    you provided with these symbols, if you need this command for *.
    work.                                                          ***
    ***                                                                   ***
    Type referenced: nt! _KPRCB *.
    ***                                                                   ***
    *************************************************************************

    ADDITIONAL_DEBUG_TEXT:
    Use '! findthebuild' command to search for the generation of target information.
    If the build information is available, run '! findthebuild s; .reload ' to set the symbol path and of loading symbols.

    MODULE_NAME: nt

    FAULTING_MODULE: fffff80002c4c000 nt

    DEBUG_FLR_IMAGE_TIMESTAMP: 4b7d238f

    READ_ADDRESS: could not get nt! MmSpecialPoolStart
    Unable to get nt! MmSpecialPoolEnd
    Unable to get nt! MmPoolCodeStart
    Unable to get nt! MmPoolCodeEnd
    fffffa7fffffffea

    CURRENT_IRQL: 0

    FAULTING_IP:
    NT + e95c
    fffff800'02c5a95c?              ???

    CUSTOMER_CRASH_COUNT: 1

    DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT

    BUGCHECK_STR: 0XA

    LAST_CONTROL_TRANSFER: from fffff80002ca626e to fffff80002ca64d0

    STACK_TEXT:
    fffffa60 '01bde688 fffff800' 02ca626e: 00000000' 0000000 a fffffa7f ' ffffffea 00000000'00000002 00000000'00000000: nt + 0x5a4d0
    fffffa60 '01bde690 00000000' 0000000-a: fffffa7f 'ffffffea 00000000'00000002 00000000'00000000 fffff800' 02c5a95c: nt + 0x5a26e
    fffffa60 '01bde698 fffffa7f' ffffffea: 00000000'00000002 00000000'00000000 fffff800 '02c5a95c fffffa60' 04dbf8b0: 0xa
    fffffa60 '01bde6a0 00000000' 00000002: 00000000 00000000' fffff800 '02c5a95c fffffa60' 04dbf8b0 00000000' 00000000: 0xfffffa7f'ffffffea
    fffffa60'01bde6a8 00000000' 00000000: fffff800 '02c5a95c fffffa60' 04dbf8b0 00000000'00000000 00000000'00000000: 0 x 2

    STACK_COMMAND: .bugcheck; Ko

    FOLLOWUP_IP:
    NT + e95c
    fffff800'02c5a95c?              ???

    SYMBOL_NAME: nt + e95c

    FOLLOWUP_NAME: MachineOwner

    Nom_image: ntoskrnl.exe

    BUCKET_ID: WRONG_SYMBOLS

    Follow-up: MachineOwner
    ---------

    I'm grateful for any help I can get in that case.

    My system is: AMD 9950BE CPU, motherboard ASUS Crosshair II Formula, 4 x 2 giga OCZ 1066 mhz memory, Vista Ultimate 64 bit, ASUS 295GTX GPU

    Postal salvation,

    I think you're in luck. It chances are you are one of those rare cases where the BSOD may not be hardware related. In addition, it is actually pretty rare to have so many errors after a sfc... Wow. I think that alone has helped reduce the risk of an another BSOD and was good insurance against other problems.

    Do you have a chance to check the hard drive? Now, I would like to check the hard drive to see if there may be potential damage to the hard drive as well to help explain this number of errors (return to the material again).

    Here's how to new:

    http://Windows.Microsoft.com/en-us/Windows-Vista/check-your-hard-disk-for-errors

    I think that advice on the anti-virus scanning are also actually still relevant today. I have a scan of one of the two groups below as soon as you can and let us know the result if you can.

    virus/malware programs:

    Symantec:

    Works in Safe Mode and free:

    _ http://security.symantec.com/sscv6/WelcomePage.asp

    Trend Micro

    _ http://housecall.trendmicro.com/

    Ad-ware/spyware:

    Ad-aware

    http://www.lavasoftusa.com/

    Spybot Search and Destroy

    http://www.safer-networking.org/

    * It is an excellent versatile tool as it will both spyware and malware and has also a small footprint.

    See you soon,.

    Steve <> Microsoft Partner

  • Why Safary does not load the content of pages?

    Why Safary does not load the content of pages? I mean, when I hover over the places where should be the content, he is always showing the "redirect to: [email protected]/" lower left. My Safari is 9.5 and worked fine until Safe Fimder Virus get inside my computer. Mozilla Firefox is a bit slower. If someone could give me an idea on how to deal with it, I would be happy.

    Sorry if my English is not good, I am a Brazilian who is still learning English

    Your English is very good!

    Redirects are usually due to adware or malware.

    Download the run MalwareBytes.

    It of free and takes only a minute or two. Which should remove all adware and malicious software on your Mac.

  • Why can I not hear my 6plus iPhone calls after loading the Apple Watch? If I don't answer the iPhone instead of the Apple Watch for incoming calls?

    Why can I not hear my 6plus iPhone calls after loading the Apple Watch? If I don't answer the iPhone instead of the Apple Watch for incoming calls?

    Hello

    It can help to cancel your iPhone in a Bluetooth headset pairing, if it is currently associated with it.

    -On your iPhone, go to: settings > Bluetooth > tap the info "i" beside your headset > tap Forget this device.

  • Using random image loader, please

    Hi all
    I'm looking by using a random image loader, to load external images files by using the following code:

    pic_arr = [' dhi/1', ' dhi/2', ' dhi/3', ' dhi/4', ' dhi/5'];

    onLoad = function() {}

    ranNum = Math.floor (Math.random () * pic_arr.length);

    randomLoaderMc.loadMovie (pic_arr [ranNum] + '.jpg');

    };

    Did anyone know how I can do this, so it will never load the same image twice in a row?

    Thanks in advance
    Rich

    first create the table

    var pic_arr = new Array ("dhi/1", "dhi/2", "dhi/3", "dhi/4", "dhi/5", "6/dhi");

    function shuffle (a) {}

    var len is. Length-1;

    for (i = len; I > = 0; i--) {}

    var percent = Math.floor (Math.random () *(i+1));

    var t = [i];

    a [i] = a [p];

    a [p] = t;

    }

    return a;

    }

    Then alternate the benefits

    picArray = shuffle (picArray);

  • Loading an image works on Z10, but not on the Q5

    I use FilePicker to load an image from the library by using the following code

    Container {
            ...
    
            ImageView {
                id: imgView
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
                scalingMethod: ScalingMethod.AspectFit
                maxHeight: 250
                minHeight: 100
                bottomMargin: 30.0
    
            }
    
        }
        Container {
            verticalAlignment: VerticalAlignment.Bottom
            horizontalAlignment: HorizontalAlignment.Fill
            bottomPadding: 30.0
            leftPadding: 30
            rightPadding: 30
    
            Button {
                id: btnSelectImg
                topPadding: 25
                horizontalAlignment: HorizontalAlignment.Fill
                text: qsTr("Select Image") + Retranslate.onLocaleOrLanguageChanged
                onClicked: {
                    console.log("FilePicker")
                    picker.open()
                }
    
                attachedObjects: [
                    FilePicker { //image picker
                        id: picker
                        property string selectedFile
                        type: FileType.Picture
                        title: qsTr("Select Image") + Retranslate.onLocaleOrLanguageChanged
                        onFileSelected: {
                            imgView.imageSource = "file://" + selectedFiles[0];
                        }
    
                    }
                ]
            }
        }
    }
    

    Copy the following code to display the image correctly on Z10, but not on Q5 however both running the same version.

    No idea what could be the problem?

    It turns out that the problem is exactly as described by dbigham, ImageView can handle images up to a certain size depedning on the device.

    I added a C++ code to resize the image before feeding it to QML

    QML code:

    ImageView {
                id: imgView
                attachedObjects: [
                    ImageTracker {
                        id: imgViewTracker
    
                        onStateChanged: {
                            if (state == ResourceState.Loaded)
                            {
                                imgView.image = imgViewTracker.image
                                console.log("Shared image loaded correctly!")
                            }
                            else if (state == ResourceState.ErrorMemory)
                            {
                                console.log("Shared image load: Error Memory!")
                            }
                            else if (state == ResourceState.ErrorInvalidFormat || state == ResourceState.ErrorNotFound) {
                                console.log("Shared image load: " + state + "!")
                            }
                        }
                    },
                    FilePicker { //image picker
                        id: picker
                        property string selectedFile
                        type: FileType.Picture
                        title: qsTr("Select Image") + Retranslate.onLocaleOrLanguageChanged
                        onFileSelected: {
                            _app.loadImage(selectedFiles[0],300,200)
                            imgViewTracker.image = _app.image;
                        }
    
                    }
                ]
    
            }
    

    C++ code:

    void ApplicationUI::loadImage(QString strImageFileName, int width, int height)
     {
         QImage image;
    
         image.load(strImageFileName);
    
         image = image.scaled(width, height, Qt::KeepAspectRatioByExpanding);
    
         QImage swappedImage = image.rgbSwapped();
         if(swappedImage.format() != QImage::Format_RGB32) {
             swappedImage = swappedImage.convertToFormat(QImage::Format_RGB32);
         }
         const bb::ImageData imageData = bb::ImageData::fromPixels(swappedImage.bits(), bb::PixelFormat::RGBX, swappedImage.width(), swappedImage.height(), swappedImage.bytesPerLine());
    
         m_image = bb::cascades::Image(imageData);
         emit imageChanged();
     }
    
    QVariant ApplicationUI::image() const
     {
         return QVariant::fromValue(m_image);
     }
    

    C++ header:

    class ApplicationUI : public QObject
    {
    ...
    
    Q_PROPERTY(QVariant image READ image NOTIFY imageChanged)
    
    public:
    ...
    
    Q_INVOKABLE void loadImage(QString strImageFileName, int width, int height);
    
    signals:
    ...
    
    void imageChanged();
    
    private:
    ...
        QVariant image() const;
        bb::cascades::Image m_image;
    
  • Math.Random () does not work in BB

    Salvation;

    I just want to ask if the BB API, can give the possibility to generate a number of random if yes how can I do; generally in java J2SE: I CAN DO THIS:

    choice = (int) (Math.Random () * 3 + 1);

    "to generate a random number ' 3 nomber.

    I try to do whit BB I import java.lang.Math;

    and when I try to put Math.Random (), it does not work

    can anyone give me the solution?

    in fact I want to have a HEX number, I think I have the Random one after I'll transforms in HEXA.

    Thank you very much

    Here is exactly what you need to get a random number

    first import

    import java.util.Random
    

    then

    //Random number generator
        Random dice = new Random();
        int num = 0;
        for (int counter=1; counter<=1000; counter++){
            num = dice.nextInt(1000); //it will generate numbers up to 1000
        }
    

    You are welcome!

Maybe you are looking for

  • International date and time

    Last week, I was in the United States and took a lot of pictures.  Now that I'm back in Australia, Photos has automatically adjusted the time and date of the pictures to what was the time in Australia, not the time it was when I took the pictures.  I

  • PrivilegedHelperTools, LaunchAgents and LaunchDaemons

    Should I delete all the PrivilegedHelperTools, LaunchAgents and LaunchDaemons? Or are there who are not a threat and necessary? As beginning with com.adobe, com.apple and com.google? Thanks in advance.

  • Satellite L70-B-150 - how do I disable the integrated graphics card

    Hi everyone (sorry for my English) I bought Satellite L70-B-150, it has two graphics cards: integrated intel hd 4600 + amd radeon r9 m265x,. How to disable BIOS (or uefi or otherwise), the graphics card intel?Of course, I know I can disable win8 equi

  • Sims 3 is VERY slow

    Hi, I just installed a game "The Sims 3" in my Windows Vista computer. However, it loads very slowly and may take up to 10 minutes sometimes. Sometimes it hangs for a long time while I play. Is that what I can do about it? Please help, thanks.

  • Record blackBerry Smartphones (sms) text messages

    My apologies if this has been requested several times before but easier to ask than a search for her Can you save text messages (sms) in the folder 'saved '? And if you can how do you do it, because I don't see an option anywhere to "Save"! Thank you