Play random predefined image set
Hello
I'm fairly new to AS3, so I need a little help from you guys. I want to randomize the results when I press a button, right now, I have this code. I have 5 Images. Each is defined on a frame where only this image is visible. So I'm randomising the frames when I click on the button. Each time it gives me a number of random frame and shows me the image on this image. Here is the code (doing this with a tutorial)
Stop();
random_btn.addEventListener (MouseEvent.Click, Choose);
function choose(event:MouseEvent):void {}
var pic_number: number = 6;
var randomFrame:Number = Math.ceil (Math.random () * pic_number);
trace (randomFrame);
gotoAndStop (randomFrame);
}
Now I want to make this more advanced, I want to animate in the image. for example I have 5 animations, the first animation's chassis 07:58, the second goes from 9 to 12, etc., I therefore had a set of images (2to8) (9to12) and not as in the previos where I received a frame. What is the best way to do it, then the button gives me each time a different animation, she animates the start, then stops. I hope you can help me, thx
:
Stop(); and put stops on each image where you want the timeline to stop
var frameA:Array = [1,11,12,13,14,15,16,17];
random_btn.addEventListener (MouseEvent.Click, Choose);
function choose(event:MouseEvent):void {}
var randomFrame:Number = frameA [Math.floor (Math.random () * frameA.length)];
trace (randomFrame);
gotoAndPlay (randomFrame);
}
Tags: Adobe Animate
Similar Questions
-
Can not play on Sony Smart set photos
TV is 2 years, maybe 3. 47 INCHES, WAS ALL ABOUT IT, WHEN YOU INSERT A USB DRIVER, IMAGES TAKE ON SCREEN, EVERYTHING IN ORDER, BUT, WHEN WE HIM REQUEST TO PLAY, JUST LIKE IMAGE CANNOT BE DISPLAYED. THE USB DRIVER, will WORK IN a TV LG, SAMSUNG AND. What gives?
There are a number of things to consider when trying to read files from a USB stick you plug not.
- File format should be supported (see the list here). Due to the variations in the implementation of USB, not all products with USB connectors can communicate with televisions have a USB port.
- Peripheral USB (USB key or external hard drive) must be formatted in FAT32 system.
- He don't play if a USB hub or USB extension cable is used.
- There are times that photos changed using a PC cannot be read.
- You can try a JPEG raw (with small size file).
- Try another USB flash drive
If my post answered your question, please mark it as "accept as a Solution.
-
How to import images set to a specific time length
How to import images set to a specific time length? I make a slide show and pictures come to 20 minutes long, when I want to be 4 seconds. How can I configure the import to a second image 4?
There is a setting preference for still life.
Mylenium
-
How thumb code scroller for images, set its different widths and heights uniformed?
I am pile trying to organize the images of variable width to be evently spacer of xml file in the thumb wheel.
I probably miss something in this code sigment:
function resizeMe(mc:DisplayObject,_maxH:Number,_maxW:Number=0,_constrainProportions:Boolean=true,_centerHor:Boolean=true,_centerVert:Boolean=true):void {}
maxH = maxH == 0? maxW: maxH;
MC. Width = maxW;
MC. Height = maxH;
If {(constrainProportions)
mc.scaleX < mc.scaleY? mc.scaleY = mc.scaleX: mc.scaleX = mc.scaleY;
}
If {(centerHor)
MC.x = (maxW - mc.width) / 2;
}
If {(centerVert)
MC.y = (maxH - mc.height) / 2;
}
}
Currently, my images appear to be resolved on a uniform width with any height would be proportional to the width defined in uniform. I also have equal distance between images.
How to make my images have an equal distance, in uniform in height and regardless of the width would be proportional to the height defined in uniform.
Here's the code in its entirety:
import com.greensock;
com.greensock.easing import. *;
//////////////////////////////////////
Load the xml
var xmlLoader:URLLoader = new URLLoader();
Parse XML
var xmlData:XML = new XML();
var xmlPath:String = "app_thmbs_imgs.xml";
xmlLoader.load (new URLRequest (xmlPath));
trace ("loading xml from:" + xmlPath);
xmlLoader.addEventListener (Event.COMPLETE, LoadXML);
function LoadXML(e:Event):void {}
trace ("loading xml complete");
xmlData = new XML (e.target.data);
trace (XMLDATA.image); Let's see each xml element of picture in Panel output with this xmlList
buildScroller (xmlData.image); rather than trace the xmlList, send it to our buildScroller function
}
Build a Scroller MovieClip to hold each Image
var scroller: MovieClip = new MovieClip();
this.addChild (scroller);
scroller.y = 30;
/////
Parse XML
build the scrolling of a xml file
function buildScroller(imageList:XMLList):void {}
trace ("' generation Scroller '");
for (var point: uint = 0; point < imageList.length (); ++ item) {}
var thisOne:MovieClip = new MovieClip();
thisOne.x = (140 + 20) * point;
thisOne.x = currentX; modified line to adjust variable inch widths
thisOne.itemNum = item;
thisOne.title is imageList [item] .attribute ("title");.
thisOne.link is imageList [item] .attribute ('url');.
thisOne.src is imageList [item] .attribute ("src");.
thisOne.alpha = 0;
trace (thisOne.itemNum, thisOne.title, thisOne.link, thisOne.src);
Loading and adding Images
container image
var thisThumb:MovieClip = new MovieClip();
Add images
var ldr:Loader = new Loader();
var url: String = imageList [item] .attribute ("src");
var urlReq:URLRequest = new URLRequest (url);
trace ("thumbnail loading" + item + "in Scroller:" + url);
assign events to charger headphones
ldr.contentLoaderInfo.addEventListener (Event.COMPLETE, completeHandler);
ldr.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, errorHandler);
LDR. Load (urlReq);
thisThumb.addChild (ldr);
thisOne.addChild (thisThumb);
create listeners for that inch
thisOne.buttonMode = true;
thisOne.addEventListener (MouseEvent.CLICK, clickScrollerItem);
thisOne.addEventListener (MouseEvent.MOUSE_OVER, overScrollerItem);
thisOne.addEventListener (MouseEvent.MOUSE_OUT, outScrollerItem);
Add article
scroller.addChild (thisOne);
}
trace ("termination of construction scroller");
}
function clickScrollerItem(e:MouseEvent):void {}
trace ("item clicked" + e.currentTarget.itemNum + "-visit url:" + e.currentTarget.link);
}
function overScrollerItem(e:MouseEvent):void {}
trace ("Over" + e.currentTarget.title);
}
function outScrollerItem(e:MouseEvent):void {}
trace ("out" + e.currentTarget.title);
}
function completeHandler(e:Event):void {}
trace ("thumbnail full" + e.target.loader.parent.parent.title)
TweenMax.to (e.target.loader.parent.parent,.5, {alpha: 1});
image size to scroll
resizeMe (e.target.loader.parent, 140, 105, true, true, false);
}
function errorHandler(e:IOErrorEvent):void {}
trace ("thumbnail error =" + e);
}
The resizing function
parameters
required: mc = the movieClip to resize
required: maxW = the size of the box to resize, or just the desired maximum width
Optional: maxH = if you want to resize area is not a square, the maximum height. by default must match maxW (so if you want to resize to 200 x 200, just send resizeMe (image, 200) or once 200 ;)
Optional: constrainProportions = boolean to determine if you want to limit the proportions or tilt the image. set to true by default.
Optional: centerHor = centers the displayObject in maxW region. set to true by default.
Optional: centerVert = centers the displayObject in maxH region. set to true by default.
function resizeMe(mc:DisplayObject,_maxH:Number,_maxW:Number=0,_constrainProportions:Boolean=true,_centerHor:Boolean=true,_centerVert:Boolean=true):void {}
maxH = maxH == 0? maxW: maxH;
MC. Width = maxW;
MC. Height = maxH;
If {(constrainProportions)
mc.scaleX < mc.scaleY? mc.scaleY = mc.scaleX: mc.scaleX = mc.scaleY;
}
If {(centerHor)
MC.x = (maxW - mc.width) / 2;
}
If {(centerVert)
MC.y = (maxH - mc.height) / 2;
}
}
You want to set the height of a specific value... it should be as simple as
MC. Height = a specific value
mc.scaleX = mc.scaleY; This will make the width proportional to the new height adjustment
but it must be done after the image is finished loading
as regards the addition with a uniform spacing goes, you must determine where the right edge of the last image and add the space betwwen to set the location of the one currently being added. If you add that these s mc to a container movieclip, then the width of the container must be data very useful to determine where is the right edge of the last mc.
-
Podcasts app stops playing randomly
Everyone knows the problem of the iSO native Podcast app stopping randomly during playback?
I have an iPhone with iOS 9.2.1 6. I listen to podcasts downloaded through the Apple iTunes Podcast store, using own Apple earbuds.
About 50% of the podcasts listened stops unexpectedly. They are not only suspended. I tried to see if it related to a specific action receiving a text or e-mail, but there is no model. I saw advice here to try to restart the phone. What I did, but it did not fix the problem.
Any help would be appreciated.
HI Adam, there.
If I understand your app Podcasts will stop just to randomly play your podcasts without reason. I would start by stop smoking Podcasts and applications settings:
1. press the Home button twice quickly. You will see small glimpses of your applications recently used.
2. slide to the left to find the application you want to close.
3. push upward on the overview of the application to close.When you have done that reboot the device and test again the question:
iOS: switch off and on (restart) and reset
If the problem persists, save your device in iTunes, then restore it like new and verify that it works.
How to clear your iOS device and then set up as a new device or restore from backupsIf this is the case, restore your backup either check it still works and just reinstalled software or circumvent the problem in the backup file itself.
Thank you for using communities of Apple Support.
-
Apple TV screensaver plays same aerial images repeatedly instead of rotate images
News aerial Images as my ATV-4 play like screensavers, but instead of turning the images he continues to play the same ones again and again of love. Sometimes it will rotate between two different aerial images and sometimes some times the same. Called Apple support and they had me restart the ATV, but always shows the same images.
From my understanding, the ATV has roughly 3-4 at a time. According to the frequency that you define new downloads, you will see the same 3-4 until the next download. That is, if you have defined for each day, you should get 3-4 new a day who write 3-4 yesterday. But if you set it for every month you will have the same 3-4 every month. My assumption is due to download the size and limits of the ISP. About 600 MB per download, it may be more some want to devote to "screen saver" rather than the music/movies...
-
I'm playing world of coffee when I go to get gifts for the ex, the lotto tickets, coffee cups that the images of the lottery tickets and cups do not exist in this case only in firefox, google chrome works correctly and the images are there, I think I hit accidentally block images somehow , but I don't know, I need to restore these images
You see one of the missing images in tools > Page Info > window Media?
Have you checked other possibilities mentioned in the two articles?
-
its system of closing in vista home prem 64 playing randomly
The sound, I want to talk about is the audio wav short system which plays when you login/shutdown. Especially when I open google chrome so far, but sometimes randomly from nowhere.
Only recent updates have been switching maps gfx.
SP2
Core2Quad 2.66
4 GBI did it with parts. feels like a software problem, but if the details of the additional equipment are needed let me know. Many thanks to anyone who has heard of / can help you.
Hello
1. do you have other problems of sound on the computer?Make sure that the speaker is not silent or minimized when the system is started either or of the judgment.
Windows Vista has a convenience store audio and audio to restore or to solve the sound problem. To run the troubleshooter, visit the following link.
http://support.Microsoft.com/GP/NO_SOUND
For more information, visit the following link:
Tips for solving common audio problems: http://windows.microsoft.com/en-US/windows-vista/Tips-for-fixing-common-sound-problemsIf no program no Microsoft is interrupted, you can follow all the steps to find what program is: http://support.microsoft.com/kb/929135
NOTE: Be sure to follow step 7 to start the computer as usual.
Post back with the results, so that we can help you further.
Kind regards
Syed
Answers from Microsoft supports the engineer. -
Windows Media Player 12 - Video DVD plays but the images are not displayed
I have a DVD that we created with Adobe Encore. It has a mixture of video and still images to a timeline. I play this back on a new computer Windows 7 with Windows Media Player 12. The DVD plays back fine until it reaches the fixed image on the timeline. At that time the reading shows just the last frame of the video to the video portion. The audio continues, but it does not show the image. We tried multiple image formats, and nothing seems to work (.jpg, .tiff, .psd). The video is very good reading but with CyberLink DVD player and on a standard TV/DVD player.
Any thoughts?
GuyHi Guywestermeyer,
Check to see if the following is useful.Method 1:
Run the troubleshooter in Windows Media Player Settings and check if that helps.
Method 2: You can try to download the required Codecs. Refer to this article for more information on Codecs.
http://Windows.Microsoft.com/en-us/Windows7/codecs-frequently-asked-questionsSee also:
Information on the types of media files that supports Windows Media PlayerHope this information helps. -
Design of a project in Captivate 9 and I have slides which have up to four images appear as audio talk about them on specific slides. My problem I have is when I single click on the play button on the timeline, images, and audio all play properly and in sync. When I select to get a glimpse of a slide or publish the file. Captivate times only the first picture on the slide, none fade in or disappearance of the first image and 2nd image doesn't appear at all. Or my other images will appear. Any suggestions or recommendations for my number is greatly appreciated.
Tami
When you use play Slide you do not have a real overview.
As I suspected; you have added 3 buttons, which are a break from the slide to 1.5secs. This means that only objects that have their chronology from before these points of suspension will not be visible until you click on these buttons. You have another click box, I do not know for what reason, which suspends the slide at its end.
Either move you the point of suspension to a location after the entry of the last image button, shortly after 40 seconds and you can get rid of that click on the box or going out the break FRO the buttons and keep the click box. Use the timing Panel to get rid of the break for the buttons if it is your choice.
-
Video: Audio plays well. Image if not.
I'm having trouble getting a video to play on ipads of team members.
It is coded as a h.264 MP4 and I'm it streaming from a common server. It plays fine on my ipad, but my two members of the team only audio and no picture. Ideas?
I think it had to do with two other ipads being most recent with the retina display. I re-encoded after reading another thread on the screens of the retina, and now everything is fine.
Here is the answer that was helpful for me to understand the problem:
"The reason why the videos were playing on older iPads but not on current iPad Air has to do with the way the videos been encoded. Who has not played on the air had been encoded with the order of the fields lower value first. When that was changed to "progressive", fine played videos on the whole.
All mobile devices have screens of progressive scan, so progressive is usually the right thing to do. I don't know any details why models previous iPad would play interlaced images and the Air is not, but I can make a guess... Apple has been quietly to denigrate a bunch of earlier codecs and QuickTime options. This is particularly visible in the Mavericks on the desktop. Now, for example, the QuickTime using Apple Animation codec files sit and convert to ProRes at the opening, because the Animation codec isn't in the QuickTime format more. ' Viewer from Adobe, iPad retina, video
-
External load VDO without repeating the same file while playing randomly
Hey! I almost did my programming Flash file. But I am so tired of making not to repeat the file VDO that it's playing.
I hope you guys will be the solution for me. *()*
It's my source code
////////////To Load any VDO/////////////// import flash.net.NetStream; import flash.net.NetConnection; import flash.media.Video; var video; var nc; var ns; nc = new NetConnection(); nc.connect(null); ns = new NetStream(nc); ns.client = this; video = new Video(550,400); addChild(video); video.attachNetStream(ns); /////////////////////////// /////////////Array for VDO Files///////////// var VdoStore:Array = new Array("westler.flv","TomAndJerry.flv","GetThere.flv"); /////////////////////////// /////////////Keyboard and Screen Show//////////////// import flash.events.KeyboardEvent; import flash.events.Event; stage.addEventListener(KeyboardEvent.KEY_DOWN,onDown); stage.addEventListener(KeyboardEvent.KEY_UP,onUP); function onDown(e:KeyboardEvent):void{ var SelectedVid = VdoStore[Math.floor(Math.random() * VdoStore.length)]; //var DontRepeat:Array = new Array(); << I tried create another array to keep the file which was played if (e.keyCode==49) { ns.play(SelectedVid); stage.removeEventListener(KeyboardEvent.KEY_DOWN,onDown); //onUP(null); } if (e.keyCode==69) { ns.play(SelectedVid); stage.removeEventListener(KeyboardEvent.KEY_DOWN,onDown); //onUP(null); } } function onUP(e:KeyboardEvent):void { if(e.keyCode==49) { stage.addEventListener(KeyboardEvent.KEY_DOWN,onDown); } if(e.keyCode==69) { stage.addEventListener(KeyboardEvent.KEY_DOWN,onDown); } }
And THST is the code that I removed all the things that I experimented on. Only code that works is shown above.
I don't need them all to be played before random new start. Just that he shouldn't play the same vdo who plays right now when I click on any button after.
For the record, I'll add more vdos, about 20 and more buttons keyboard click under the same numbers.
Anyone? * Pleaseeeeeeee > / / / <
One way would be to remove the video played to the table when it is played so that it can not yet be licked.
Another way, since you don't mind a repeat later would be to store the index of the video chosen when it is played in a variable that you compare the index selected. If the selection corresponds to the variable, then you run the selection processing again until you take successfully another video. To do this, it will be easier to have a separate function that performs the selection.
-
Play random symbols when you click on the button
First of all, I apologize for not be able to use answers that have already been presented in response to questions similar to this, but none of the positions I have pored over seem to cover what I'm after (unless it's a matter of my failure understand the concept... which may well be the case! Haha!)
Anyway, I have a dozen of symbols animated on stage and I would like a chance to play each time users click on a button.
Advice, or guidance to any Tuts out there, are very welcome.
Cheers in advance
Frannie x
Here's something a little more concise that can help or otherwise be of interest:
var childSymbols = sym.getChildSymbols ();
var r = Math.floor ((Math.random () * 4));
childSymbols [r] .play ();
Add this code to your click handler. Only minor changes are needed if the instances of the button and the symbol are not at the same level of symbol.
HTH,
Joe
-
I have a set rollover image to appear to the rest of the project which works fine if all of the training is done at the same time. The project is in adobe connect and the project of closing and then reinsert the project, it will take off where the user left off but this rollover image appears on the screen instead of the current slide. The user should click on in the Table of contents or a front/rear button to turnover to go. Is there a way I can fix it so the rollover image is not back to the project?
Have you tried to put the image rollover on Master slides in place?
-
Play random single element of the array?
Super rookie here in Flash.
Is there a basic AS3 code to have, when the SWF load, a simple reading of the video from a collection of videos in a table? And can the code also apply to the sounds without video?
I just discovered that the tutorial I used randomly does not work with audio - as he plays just all at once - you could 'see' a video - but you hear all.
So from what I read, I need us a table (which seems fairly simple), but I don't want to play all clips - I want it at random, select and read a. Don't know exactly how I put to the top of the video playback area (the video plays where I want, in the size I want).
Also, I have other pages that are simply audio - audio has some sort of player or something to it?
Ty
The part of the length of this code is the property of length, which is like any other property to any object in the sense that you use the Word as shown 'length' (not its value like you tried) and it will hold the value of this property.
In order to reduce the size of your file, do not import the files into your fla, simply load the selected where they are dynamically when the file is running. Listen to the video of his external location and your swf file will be happier for it. For the FLVPlayback to play the video, you must assign the source property.
var my_videos:Array = new Array ("cat1.flv", "cat2.flv"); actual file names
var randomIndex = Math.floor (Math.random () * my_videos.length);
yourFLVPlaybackName.source = my_videos [randomIndex];
You should look for the FLVPlayback component in the help documents and familiarize yourself with all that's properties, methods, and events. In fact, you should learn to do this for any object that you want to use in your designs. Each object class that you will use in a design those has three elements, properties, methods, and events, which not only define the object but also your key to make use of them. So whenever you're wondering how an object works, the first thing you should do is look in the help documents to see what properties, methods and events support it. I hope that repeat the words properties, methods, and events in this section will help to drive home to the point that the help documents are an excellent resource to find the information needed to make things work (properties, methods, events, and sometimes CONSTANTS)
Maybe you are looking for
-
10 IOS on iPhone 6, analog clock, how?
I've just updated to iOS 10 on my iPhone 6 and want the analog clock, what should I do?
-
Cannot connect my cell phone to my computer via bluetooth
Cannot connect my cell phone to my computer via bluetooth
-
How to connect my device to iTunes?
When I go to iTunes with my device (iPhone 6) plugged into the laptop it connect not synchronize automatically. I tried Edit > Preferences > devices and which did not help. I tried to go to my Windows 10 settings and nothing helped me. If you have an
-
Printer Laser Jet HP 1100 and Vista
Someone managed using a jet of HP1100A laser with the Vista operating system? I had to work for a short period, but then just stoped printing. I used an adapter cable to match the printer to a USB port. I then installed a card to the computer's paral
-
I want 16 GB Mac card replacement