Images loaded with a random number
Hi All,
I have made a flash movie as seen at
http://www.coffeemamma.com.au
and would
like to change the following:
I'd like to generate three random numbers from 1 to 5
inclusive but I want
to ensure that each number is different - e.g. 2, 4, 1 (not
2, 4, 2). I know
how to generate ONE random number, but I'm stuck on comparing
them to see
whether they are the same (and if they are, then generate new
numbers until
they are unique).
With the three numbers I would like to load images based on
those numbers -
e.g. '_image_2.jpg' then '_image_4.jpg' then '_image_1.jpg'.
This part is
fine IF I can generate the numbers.
I'd also like to have the images come to the front when they
are hovered
over with the mouse and then to go 'back' to their original
position when
the mouse moves away. This I'm completely stuck on.
I'd also like to be able to put the newly loaded images into
certain
positions (as per the example) rather than only loaded to
(0,0) coordinates.
I also want to be able to have the images masked as they come
in (as per the
example) in order to avoid white corners on the top images.
I also have a page as per
http://www.wasabi.org.au/wodonga.shtml
which has
some of the functions I want to use, but I can't seem to get
some of the
functions working in my new movie...
Many thanks,
Bruce
I recommend to read at least the first two "introduction articles" from sun's Java >Card homepage: http://developers.sun.com/techtopics/mobility/javacard/articles/
Thanks a lot ... really interesting. I learnt already alot with that !
I am sorry but the code you posted is J2SE-code, not JavaCard code. The JavaCard >environment is very restricted:
No Integer (most cards don't even support the simple "int") and no String class.Oops :) ... i knew something was wrong hi hi
This is my new code, it seems to work:
/* SEND_CHALLENGE */
private void sendChallenge(APDU apdu){
byte[] apduBuffer = apdu.getBuffer();
RandomData random = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
random.setSeed(randomArray,(short)0,(short)32);
random.generateData(randomArray,(short)0, (short)32);
Util.arrayCopy(randomArray,(short)0,apduBuffer,(short)0,(short)32);
apdu.setOutgoingAndSend((short)0, (short)32);
}Thanks a lot
I'am going to be back soon for some more questions i think !
Similar Messages
-
Interface frozen with images loaded with Loader()
Hi all,
I am trying to create a web app that allows the user to load an image from a local folder and process it with some image processing. I was able to do that with FileReference and Loader.
I am using an asynchronous shader to process the image and it seems that when the image is loaded locally the interface is locked out for a second or so before showing the result. However, if the image is embedded this does not happen and the image is updated instantly with the result.
I don't really understand why an image loaded with a loader has this lag and an embadded image does not... Can anyone help?
Thanks.Everything was already done
100 fullduplex autoneg to false :
# for i in `ndd /dev/hme \? | grep "read and write" | awk '{print $1}' ` ; do
echo $
ndd /dev/hme ${i}
done
ipg1
8
ipg2
4
use_int_xcvr
0
pace_size
0
adv_autoneg_cap
0
adv_100T4_cap
0
adv_100fdx_cap
1
adv_100hdx_cap
0
adv_10fdx_cap
0
adv_10hdx_cap
0
instance
0
lance_mode
1
ipg0
16
$ netstat -k hme0
hme0:
ipackets 172970 ierrors 77 opackets 106192 oerrors 0 collisions 0
defer 0 framing 36 crc 41 sqe 0 code_violations 0 len_errors 0
ifspeed 100000000 buff 0 oflo 0 uflo 0 missed 0 tx_late_collisions 0
retry_error 0 first_collisions 0 nocarrier 0 nocanput 0
allocbfail 0 runt 0 jabber 0 babble 0 tmd_error 0 tx_late_error 0
rx_late_error 0 slv_parity_error 0 tx_parity_error 0 rx_parity_error 0
slv_error_ack 0 tx_error_ack 0 rx_error_ack 0 tx_tag_error 0
rx_tag_error 0 eop_error 0 no_tmds 0 no_tbufs 0 no_rbufs 0
rx_late_collisions 0 rbytes 199140046 obytes 6676272 multircv 231 multixmt 0
brdcstrcv 1057 brdcstxmt 42 norcvbuf 0 noxmtbuf 0 newfree 0
ipackets64 172970 opackets64 106192 rbytes64 199140046 obytes64 6676272 align_errors 36
fcs_errors 41 sqe_errors 0 defer_xmts 0 ex_collisions 0
macxmt_errors 0 carrier_errors 0 toolong_errors 0 macrcv_errors 0
link_duplex 0 inits 5 rxinits 0 txinits 0 dmarh_inits 0
dmaxh_inits 0 link_down_cnt 0 phy_failures 0 xcvr_vendor 24657
asic_rev 193 link_up 1
So what do you have any idea, about the problem?
The router is 100 Full Duplex w/o autoneg
the errors arrived only on the virtual interface hme0:1, and never on hme0
Fred, -
Solaris boot images fail with bad magic number
hi guys, have had Solaris on boxes for allmost 10 years. I have never installed sol10, and I have a problem
1. I download the zip file, then use winrar to unzip them..
2. burt the image with nero 7
when my SunBlade 1000 comes up I do the Stop-A, and from the Ok promt
I do boot cdrom
this fails with "bad magic number" I have redown loaded it and reburnt it with nero reinstalled
and also changed out the DVD on SunBlade
3 I found a copy of Solaris 8 and the I got back a 'bitch' where is Solaris 9 so, most likely the drive is OK
HELP
Cris HarrisonHello Cris,
unfortunately I don't understand your last sentence !
I found a copy of Solaris 8 and the I got back a '*****' where is Solaris 9 so, most likely the drive is OK
If this was a Solaris 8 (7/01 or later) DVD that did successfully boot, your DVD drive firmware (assuming that this is the Sun Toshiba SD-M1401) is up-to-date. If the DVD drive has firmware 1007, an update to 1009 is required to boot from DVD. otherwise you won't be able to boot from DVD (boot from CD works and a DVD can be automounted/mounted).
Partial output of probe-scsi
Before update:
Unit 0 Removable Read Only device TOSHIBA DVD-ROM SD-M14011007
After update:
Unit 0 Removable Read Only device TOSHIBA DVD-ROM SD-M14011009
[*Patch 111649-04 - Toshiba DVD 1401 firmware update*|http://sunsolve.sun.com/search/advsearch.do?collection=PATCH&type=collections&queryKey5=111649&toDocument=yes]
when my SunBlade 1000 comes up I do the Stop-A, and from the Ok promt ...
Instead of trying to directly boot, disable auto-boot and retry after a clean power-on.
Break with Stop-A
setenv auto-boot? false
reset-all
boot cdrom
Michael -
Applying filter to images loaded with movieClipLoader
Hello,
I am building a product gallery and have a number of rather
large bitmap images that I am loading with movieClipLoader. I need
to apply drop shadow filters to them when they are loaded. I have
tried several methods of going about this without success. One
method was putting the loaded images into a movie clip with
createEmptyMovieClip, and then applying the filter dynamically, but
I couldn't seem to get it to work- the filter never appeared. I
then tried applying the filter to the bitmap itself with
bitMapData, but because I was not loading the bitmaps using
bitMapData itself (I think) I wasn't able to get that method to
work either.
Does anyone have a suggestion or a recommendation for me?
Thanks very much for any advice.Were you doing it after the onLoadInit event in the
MovieClipLoader's listener?
Try doing it that way if you haven't. One option I use for
dynamic image loading is to create and empty holder clip - use that
for placement and create another empty clip inside that one that I
use as the loading target... I think this should work if you set
the filter at the level of the first 'empty' clip. I had to use
this approach a number of times because I was using a tweening
engine based on movieclip prototype extensions (old hat I know) and
loading new images kicked out the extended functionality from the
clip the images are loaded into. That doesn't happen to the clip's
parent... hence I think it might work also for what you want to do.
Another thing to watch for is that you can't do bitmapData
copies of images from a different domain unless you have
crossdomain policy support - you can set it up so this works. I'm
not sure if this affects filters though.
-GWD -
Rotating image loaded with CameraRoll
I'm having trouble working out how to rotate an image loaded using CameraRoll on an AIR for iOS app.
This code below works fine (displayImage() is called when CameraRolls media event returns completed, and imageArea is the scrollPane where the image is shown.
function displayImage():void
var image:Bitmap = Bitmap(imageLoader.content);
imageArea.source = image;
The image loads just fine untill I try to rotate it:
function readMediaData():void
var image:Bitmap = Bitmap(imageLoader.content);
var imX:int = image.width;
var imY:int = image.height;
if (imX>imY)
image.rotation = 90;
imageArea.source = image;
With the second version the image seems to load because the scroll bars expand to the size of the image I choose, but I don't see anything on the stage.
What am I doing wrong?
Any suggestions would be really appreciated.I added the new width back to images x position but no joy; no matter what x & y I set the image to, it cannot be seen. The scroll bars expand exactly the right amount for the 'invisible' image, regardless of it's x & y positions as well (you'd think if the image was out of the scrollPane the bars wouldn't adjust like that. I'm not doing something right.
I'm stumped on this but I'll keep trying things. Thanks for your help and the lead, I appreciate it and it may be part of the problem, but there seems to be a different problem as well. -
How to export image sequence with a specific number
Hello
I'm looking how, like in after, I can export an image sequence with a starting specific number. I spend hours to rename images with Renamer, boring, stupid!
Thank you for helping
AlexUse Bridge. You can do them all at once with Batch Rename.
-
Image loaded with Loader doesn't render
I have created a web service that pulls images (gif,jpg) from
the database and base64 it for sending across the wire. The flex
application then decodes and renders the image. The Image is not
being scaled correctly. IT will not adhere to the dimensions of the
ImageBox but rather stays at the original fixed size. If I embed
the image into the application everything works correctly. But if
the image is decoded then sizing goes out the window.
The image overflows the Image box and takes up the full size
of the image. Zoom, rotation, etc. do nothing to the image.
Any help is appreciated...
Example Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="onLoad(event);">
<mx:Script>
<![CDATA[
import mx.utils.Base64Decoder;
public function onLoad(event:Event):void {
// Decode image - Base64 gif image (500 x 776)
var base64:String = "R0lGOD..."; // Get base64 from web
service call
var decoder:Base64Decoder = new Base64Decoder();
decoder.decode(base64);
// Load image into container
var loader:Loader = new Loader();
loader.loadBytes(decoder.flush());
image2.addChild(loader);
]]>
</mx:Script>
<mx:HBox id="mainBox">
<!-- Should render a 100 x 100 box but instead the image
is full size -->
<mx:Image id="image2" width="100" height="100" />
</mx:HBox>
</mx:Application>Hi Dmitri,
Thank you for the prompt reply, your question about the jpeg content was a helpful pointer.
I solved the problem, it had nothing to do with flex, it was all on the java side. The image was obtained from converting a TIFF to a JPEG, the conversion was failing and the flex loader was receiveing a tiff and it did not know how to display it.
The java problem was kind of interesting, I'll post it here as an FYI in case anybody cares :
On my server the first writer returned by ImageIO was an instance of JPEGImageWriter and on the other servers was CLibJPEGImageWriter. And it happens that only JPEGImageWrite can write the type of TIFF that we are having.
The fix was to iterate through all the writers and pick the instace of JPEGImageWrite, instead of the first one found.
Lumi -
I am loading a JPEG image from the server, using the Loader->loadBytes() and that works when the app is deployed under my local Tomcat server. When I deploy it on other servers the image is not displayed, instead of the image I see II*
On the server side I have java, Spring, BlazeDs and I use RemoteObject on the client.
The code that loads the image looks like below:
private function imageLoadResultHandler(event:ResultEvent):void {
var result:ArrayCollection = event.result as ArrayCollection
var bytes : ByteArray = result.getItemAt(0) as ByteArray;
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loaderFaultHandler);
_loader.loadBytes(bytes);
private function loaderCompleteHandler(event:Event):void {
var loaderInfo:LoaderInfo = event.currentTarget as LoaderInfo;
var img:Image = new Image();
img.source = loaderInfo.content;
myPanel.addChild(img);
<mx:RemoteObject id="ro" destination="imageLoadService">
<mx:method name="loadImage" result="imageLoadResultHandler(event)" fault="faultHandler(event)" />
</mx:RemoteObject>
Any help with this problem is much appreciated.
Thank you,
Lumi VelicanuHi Dmitri,
Thank you for the prompt reply, your question about the jpeg content was a helpful pointer.
I solved the problem, it had nothing to do with flex, it was all on the java side. The image was obtained from converting a TIFF to a JPEG, the conversion was failing and the flex loader was receiveing a tiff and it did not know how to display it.
The java problem was kind of interesting, I'll post it here as an FYI in case anybody cares :
On my server the first writer returned by ImageIO was an instance of JPEGImageWriter and on the other servers was CLibJPEGImageWriter. And it happens that only JPEGImageWrite can write the type of TIFF that we are having.
The fix was to iterate through all the writers and pick the instace of JPEGImageWrite, instead of the first one found.
Lumi -
Dynamic image load with MovieClipLoader
I'm trying to load five images from five URLs. If I use the
documentation exactly as is, it works fine. Problem is, I don't
want to createEmptyMovieClip, I want to use an existing one that's
tucked inside a movie instance. Also, the images coming in are of
unknown size, but have a standard 4:3 size ratio. I'd also like to
scale them down to 180x120 after they arrive. Any help would be
greatly appreciated.
The code below only loads one image (which isn't working). I
will eventually need it to load five different images.Dynamic text that doesn't have embedded fonts won't respond
to tweening, alpha, etc. So you need to embed the font(s). There
are a couple of ways to do this depending upon what you are doing.
But most likely you can just select the text field and click the
font button on the properties panel and select embed. Also I would
recommend that you use _visible=false instead of alpha for this
effect.
I'm not sure what the second go-round is. Can you explain
that a bit better? You should be able to use the same loader, so
I'm not quite sure what is going on. Again, look for some helpful
places to put some traces and see if you can figure out what is
going on. Remember that generally Flash does what we tell it, not
what we want! So if you can find the places where you are telling
it to do things you can figure out what is happening.
Also I'm not clear on what is going on with the variables and
text. Generally I would recommend against using the variable
property of text fields. That is a leftover from the Flash 5 days
when you couldn't work directly with dynamic text fields. Instead
give the fields instance names and then assign the text with the
text property.
myTextField.text="some value in here";
myTextField2.text=someStringVariable; -
How to extract the number of the image which looks like a number
Now,I can generate a image which contains a random number,but I can not extract the number of the image.Any one can help me?
[url http://forum.java.sun.com/thread.jspa?threadID=779212&messageID=4433641#4433641]Crosspost.
-
Plot xy graph using random number generator
How do i plot xy graph dynamically every 5 seconds with a random number generator?
X axis : Time
Y Axis : Random number generatorI've done tis so far. im able to plot dynamically every 1 second.
but the problem i am facing is The X axis display every 1 second.
i want it to be fixed 24 hours time format, and the data will gradually plots the data on y axis against x axis every one second, without changing the scale of the x axis (24hour time format) -
Random NUMBER generator help..
Hi all,
i'm having issues with my random number generator i'm trying to fill my array with random numbers but i keep getting it filled with zeros.... can any one tell me what i'm doing wrong i can;t figure it out..
for (int i =0; i < 100; i++){
int x=(int) (Math.random());
data[i] = x;
}From the API "Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0."
So casting the value to int is always going to result in a zero value.
You need to multiply by a value that is one larger than the value you want to be your maximum. For example:
int x = (int)(Math.random() * 100);
should create a random number from 0 to 99 -
Generate Random Number in a Numberic Field
Hello,
I am wondering if there is a way to Generate a random number in a numeric Field or any other type?
I am currently using LiveCycle Designer ES 8.2
thanks,
-VargsThanks for the post, I was researching further into what I wanted to do and found this post
http://www.acrobatusers.com/forums/aucb … ?pid=60135
What I want to do with this random number is generate it every time someone opens a new form. This form will be saved on a persons computer and worked on. So I don't want the number to change every time the file is open, only when the form doesn't have a unique number already in it.
I believe the answer is the following but I am not sure if it will do the task I want to perform. Here is the following code
Quote from the post by user Jonom:
"Here's a script I've used on the Initialize event of a form. It checks to see if it already has a value and if so doesn't generate a new number in case people save the form and reopen it:
The number is unique to the second, so two people would have to open the form at the same second to get the same value..."
Code:
if (this.rawValue == null) {
var d = new Date();
//divide result by 1000 to get seconds and round off
this.rawValue = parseInt(d / 1000);
else {
this.rawValue = rawValue;
end quote
How can I put in this code into a numeric field. I made a numeric field in Livecycle Designer ES 8.2
and tried to add in code but was not sure which event to put it in or where exactly it should be placed.
Thanks,
-Vargs -
I'm creating a horse racing game and I'm having a problem with my random number generator inside my threads.
I'm creating four threads and then inside each of them I'm using:
sleep(rand.nextInt(5) * 300);
Which I thought would make each horse thread sleep for a different amount. Instead, my first horse thread sleeps for a random amount, then my next THREE threads sleep for the exact same amount!
Is my random (class random) object not being seeded properly or something?
What could be causing this?Ok, here is a snipped version of my code:
public class HorseThread extends Thread {
private Random rand;
public void run() {
rand = new Random();
draw();
private void draw() {
// Grab the graphics object out of our JPanel
Graphics g = panel.getGraphics();
try {
for (int x=0; x < 500; x+=25) {
// Erase our racing lane
g.setColor(Color.WHITE);
g.fillRect(startX, startY, 500, 75);
// Draw our horse
g.drawImage(horsePicture, curX + x, curY, 75, 75, null);
// Sleep a random amount
int sleepamount = rand.nextInt(5) * 500;
System.out.println("Horse [" + horseNum + "] sleeping for [" + Integer.toString(sleepamount) + "] milliseconds.");
sleep(sleepamount);
} // end for
} catch (InterruptedException e) {
e.printStackTrace();
} // end try
} // end draw()
} // end HorseThread() -
Loading Images/Having images load at the center of a JFrame with random col
Hey Guys,
I was wondering how could i go about loading images two at a time for instance have two circle images load at the center of a J Frame connected to each other and also each time the J Frame is executed the circles are different colors. Ive posted this question before and have posted it on another forum but i have not gotten any help. I looked into using media tracker and the Random command but i am still not if these are the proper solution to my problem. Id appreciate any help if this post doesn't make sense let me know i will try and clarify better. Thanks in advanceAh alright then so what i have to far is i have an image load to my J Frame/J Panel and after it loads it starts to fall like a tetris block and i am able to move it left and right. When the image loads it loads to the default coordinates of 0,0 the left hand top corner. What i want to do it when i run my application the image loads at the center of the J Frame/J Panel but also have another block connected to it when it loads. So basically i have loaded four separate different images and want them to load to my J Frame/ J Panel two at a time side by side like tetris and puyo puyo smashed together here is my code sorry its hard for me to explain it for some reason hope this makes more sense.
import javax.swing.*;
import java.awt.*;
public class DemoTest extends JPanel {
public DemoTest() {
add(new BlockPanel());
public static void main(String[] args) { {
JFrame frame = new JFrame("Tetris");
frame.setContentPane(new BlockPanel());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200,500);
frame.setResizable(false);
frame.setVisible(true);
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class BlockAnimation extends JPanel {
public static final int numDroppingBlocks=2;
private static final int MAX_X = 200;
private static final int MAX_Y = 430;
private static final int DELTA_Y = 2;
private static final int TIMER_DELAY = 20;
// Declare name's for the Image object.
Image image[];
Timer pptimer;
boolean right,left;
int X = 0;
int x = 32;
int y;
public BlockAnimation() {
super();
//Load an image file into the Image object. This file has to be in the same folder
image = new Image[4];
image[0] = Toolkit.getDefaultToolkit().getImage("block_yellow.png");
image[1] = Toolkit.getDefaultToolkit().getImage("block_blue.png");
image[2] = Toolkit.getDefaultToolkit().getImage("block_green.png");
image[3] = Toolkit.getDefaultToolkit().getImage("block_red.png");
//image5 = Toolkit.getDefaultToolkit().getImage("DeathNote1.jpg");
setFocusable(true);
BlockMove block_move = new BlockMove(); // Make a new video game KeyListener
addKeyListener(block_move);
//setBackground(Color.BLACK);
pptimer = new Timer(TIMER_DELAY, new TimerAction());
pptimer.start();
public void setAnimation(boolean OnandOff) {
if (OnandOff) {
pptimer.start();
} else {
pptimer.stop();
public void paintComponent(Graphics g) {
super.paintComponent(g);
// draw the "stop" line for the animation
g.setColor(Color.black);
g.drawLine(0, MAX_Y, getWidth(), MAX_Y);
// Draw our Image object.
g.drawImage(image[0],X,y,this);
if(right) // Move the block to the right
X++;
if(left) // Move the block to the left
X--;
repaint();
private class BlockMove implements KeyListener {
public void keyTyped(KeyEvent e){}
public void keyReleased(KeyEvent e)
if(e.getKeyCode() == e.VK_RIGHT)
right = false;
if(e.getKeyCode() == e.VK_LEFT)
left = false;
public void keyPressed(KeyEvent e)
if(e.getKeyCode() == e.VK_RIGHT)
right = true;
if(e.getKeyCode() == e.VK_LEFT)
left = true;
class TimerAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
y += DELTA_Y;
if (y + x >= MAX_Y) {
setAnimation(false);
}//end class
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class BlockPanel extends JPanel {
BlockAnimation pa;
BlockPanel() {
pa = new BlockAnimation();
JButton startButton = new JButton("Start");
JButton stopButton = new JButton("Stop");
startButton.addActionListener(new Start());
stopButton.addActionListener(new Stop());
JPanel button = new JPanel();
button.setLayout(new FlowLayout());
button.add(startButton);
button.add(stopButton);
this.setLayout(new BorderLayout());
this.add(button, BorderLayout.SOUTH);
this.add(pa,BorderLayout.CENTER);
class Start implements ActionListener {
public void actionPerformed(ActionEvent e) {
pa.setAnimation(true);
class Stop implements ActionListener {
public void actionPerformed(ActionEvent e) {
pa.setAnimation(false);
}//endclass Edited by: Riz01 on Sep 14, 2009 2:34 PM
Maybe you are looking for
-
Reg: Parameters to add SAP Standard REport
HI all, I want to add extra parameters to sap standard report. how to add it. regards JK rao
-
How can I get iWorks 09 for OS 10.7
I've had to reformat my hard drive and re-download Lion 10.7.5 and now I can't get my iWorks 09 to work on the new system. I tried dragging it over from a back up I had but it won't work. Any suggestions?
-
How to check whether a file in AL11 is unicode or non-unicode
Hi All, I have a file in AL11. Now before using open dataset, i need to check whether it is unicode or not. By doing this we will know what encoding format needs to be used with open dataset statement. Do we have any way by which we can programatical
-
Configure return type: There was an error while invoking the operation
This error only occurs when I pass parameters to Configure return type dialog As a follow on from http://forums.adobe.com/message/2663481 I am getting this in the log. !ENTRY com.adobe.flexbuilder.DCDService 4 1 2010-06-15 11:45:29.323 !MESSAGE Pleas
-
Create multiple looping videos on one DVD
My client wishes to have a DVD with multiple video selections on the menu and the option to have those videos loop when they are selected to play, so they will play endlessly until they choose another video. Evidently this is going to a trade show of