Problem with slide block puzzle
Hello:
I am doing a project that solve slide-block puzzles. My program take two common line arguments. One is a file specifying the initial configuration while the other specify goal configuration. My idea is to use an arrayList<block > to represent a configuration with each element being a block, for each block, I stores all possible configurations after moving the block in a Hashset and Stack. I check if the goal has been reached after each move, if not, go moving next one. If the configuration has been seen before, which indicates a dead end, I pop the stack to backtrack the most recent the branch and take another path.
Unfortunately, the algorithm I came up does not work.
Can anyone propose a psudocode for me?
Also, my program should print out all moves directly towards the goal but I can not figure out how to only print out the moves directly towards the goal and avoid printing those leading to dead end.
You can see specification http://nifty.stanford.edu/2007/clancy-slidingblocks/proj3.html.
I will be really really appreciated.
Well, that was harder than I thought!
Anyway, the algorithm can be quite simple: a BFS finds a solution pretty fast. Here's some pseudo code:
public class Solver {
private Set<Integer> alreadyFormedTrays; // A set of already formed trays
private List<Block> goalList; // The final goal(s)
private boolean foundSolution = false; // A flag flipped to true once we find a solution
private Tray startTray; // The initial tray
public Solver(String[] tray, String[] goals) {
alreadyFormedTrays = new HashSet<Integer>();
goalList = new ArrayList<Block>();
buildTray(tray);
buildGoals(goals);
private void buildGoals(String[] goalsData) {
// Fill the 'goalList'.
private void buildTray(String[] trayData) {
// Create the first tray: 'startTray'.
private boolean goalsReached(Tray aTray) {
// Check wether we have reached our goal(s).
public void solve() {
alreadyFormedTrays.add(startTray.hashCode());
System.out.println("START=\n"+startTray);
solve(startTray);
private void solve(Tray aTray) {
IF we found a solution, stop looping END IF
IF 'aTray' reached our goal(s)
foundSolution <- true
print the path 'aTray' has taken
stop looping
END IF
'nextTrays' <- all next trays that can be formed from 'aTray'
FOR every Tray 'T' in 'nextTrays' DO
'hash' <- a hash of 'T'
IF 'hash' is not yet present in 'alreadyFormedTrays'
add 'hash' in 'alreadyFormedTrays'
make a recursively call with 'T' as a parameter
ENDIF
ENDFOR
public static void main(String[] args) {
String[] trayFile = {
"5 4",
"2 1 0 0",
"2 1 0 3",
"2 1 2 0",
"2 1 2 3",
"2 2 1 1",
"1 2 3 1",
"1 1 4 0",
"1 1 4 1",
"1 1 4 2",
"1 1 4 3"
String[] goalFile = {
"2 2 3 1"
Solver s = new Solver(trayFile, goalFile);
s.solve();
}As I said: the algorithm isn't that hard, the tricky part comes in finding all possible Trays from a given Tray X and making copies based on X.
Here are some UML diagrams of the classes I used:
| |
| + Tray |
|______________________________________|
| |
| ROWS: int |
| COLUMNS: int |
| - freeSpaces: byte[][] |
| blocks: List<Block> |
| path: List<Atom[]> |
|______________________________________|
| |
| + Tray(r: int, c: int): << constr >> |
| + Tray(tray: Tray): << constr >> |
| + addBlock(b: Block): boolean |
| + generateNextTrays(): List<Tray> |
| + removeBlock(b: Block): void |
|______________________________________|
| |
| + Block |
|__________________________________________________________________________________________|
| |
| HEIGHT: int |
| WIDTH: int |
| name: char |
| atoms: List<Atom> |
|__________________________________________________________________________________________|
| |
| + Block(n: char, height: int, width: int, startRow: int, startColumn: int): << constr >> |
| + Block(b: Block): << constr >> |
| - buildAtoms(startRow: int, startColumn: int): void |
| + getUpperLeft(): Atom |
| + move(m: Move): void |
|__________________________________________________________________________________________|
| |
| + Atom |
|______________________________________|
| |
| row: int |
| column: int |
|______________________________________|
| |
| + Atom(r: int, c: int): << constr >> |
| + Atom(a: Atom): << constr >> |
| + move(m: Move): void |
|______________________________________|I removed the equals(...), hashCode() and toString() methods for clarity, you should implement them, of course.
The Move class you see in there is an enum, and looks like this:
public enum Move {
UP (-1, 0),
RIGHT ( 0, 1),
DOWN ( 1, 0),
LEFT ( 0, -1);
final int deltaRow, deltaColumn;
private Move(int dr, int dc) {
deltaRow = dr;
deltaColumn = dc;
}If you have any questions about the methods/variables in the class diagrams, feel free to post back.
Good luck.
Similar Messages
-
Problems with file block settings
We manage file block settings via group policy. I have run into problems with the file block settings not working as advertised.
I've run into a couple of issues:
First, in Excel 2010 I would like to open Web Page and XML files in protected view rather than blocking entirely. Our "Set Default File Block Behavior" in the GPO is set to "Blocked Files are not opened." According to the
documentation, the settings for individual file types should be able to override this behavior but this is not the case in my testing. If I set "Web pages and Excel 2003 XML spreadsheets" to "Allow editing and Open in Protected View"
the files are still blocked and the Trust Center list the file as Do not open, not the GPO setting of open in protected view. I have verified via GPresults that the GPO applied successfully, rebooted the PC, etc. The "Set Default File Block
Behavior" is NOT overridden by individual file type settings.
According to the "plan file block settings" technet article:
The “Set default file block behavior” setting specifies how blocked files open (for example: does not open, opens in protected view, or opens in protected view but can be edited). If you enable this setting, the default file block behavior you specify applies
to any file format that users block in the Trust Center UI. It also applies to a specific file format only if you both enable its file format setting (for more information about individual file format settings, see the tables in this article) and select the
Open/Save blocked, use open policy option. Otherwise, if you configure an individual file format setting, it overrides the
Set default file block behavior setting configuration for that file type.
Second, even if I do change the set default file block behavior to open in protected view, I still cannot open XML spreadsheets. The trust center says that the file format is set to open in protected view but when I attempt to open a file it behaves
as if the setting was still set to block entirely.
The only thing that works is setting it to "do not block" which is not where I'd like to go - I would for security reasons like these types of files to open in protected view but there doesn't seem to be any way to do this contrary to the Technet
documentation.Hi,
I had opened a case at Microsoft in 2012 about the «Open/Save Block, use open policy» parameter about HTM/HMTL files... Here is the answer I got from the support.
Hope it will help
Thank you for contacting Microsoft regarding your recent Office 2010 Hotfix request (SR 112022071246968) in reference to File Block settings on web pages. We have conducted a thorough investigation into this matter
and while we recognize the impact the issue is having on your business, we cannot accept this Hotfix request because it is acting as designed.<u5:p></u5:p>
Office will block any files that are explicitly set in the File Block UI by an Administrator when there is no built in validator. The Office File Validation scans and validates certain kinds of files and will
only display those applicable files in Protected View. We could provide a safe experience in Protected View for HTM, but it wouldn't be a useful experience. Linked content of the web page is not available (images, stylesheets, javascript, etc), so the
user would effectively see plain text. This is not the experience we want in Protected View, and it would encourage users to leave Protected View, putting their machine at risk. So HTM/HTML files are blocked.<u5:p></u5:p>
<u5:p></u5:p> -
Problem with DECODE block in WHERE clause
Hi,
I'm facing problem with DECODE statement. I just simulated my problem in the simple way as follows. If I execute this following query, I should get "hello", but I'm not getting anything (ZERO rows returned).
SELECT 'hello' FROM DUAL
WHERE 'sample1' in (DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',
2, '''sample4'', ''sample5'', ''sample6'''
I think some problem is there in my WHERE clause.
But When I'm exeucting the following query as a seperate query, then I'm getting the value of DECODE block properly, but didn;t understnad why its not returning the same way when I'm putting the same DECODE statement in WHERE clause.
SELECT DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',
2, '''sample4'', ''sample5'', ''sample6'''
FROM DUAL;
Please help me to get out of this problem. Thank you so much in advance.
Thanks,
Ramji.The value returned by SELECT DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',2, '''sample4'', ''sample5'', ''sample6''') FROM DUAL;
'sample1', 'sample2', 'sample3' is a single string. Consider it x.
SELECT 'hello' FROM DUAL WHERE 'sample1' in ( DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',2, '''sample4'', ''sample5'', ''sample6'''));
is like SELECT 'hello' FROM DUAL WHERE 'sample1' in ('x');
or
SELECT 'hello' FROM DUAL WHERE 'sample1' in ('''sample1'', ''sample2'', ''sample3''') and not
SELECT 'hello' FROM DUAL WHERE 'sample1' in ('sample1', 'sample2', 'sample3');
For this same reason SELECT 'hello' FROM DUAL WHERE 'sample1' in (select '''sample1'', ''sample2'', ''sample3''' from dual);
also does'nt work.
Please use INSTR to find whether 'sample1' exists in the string 'sample1', 'sample2', 'sample3'. -
Hi, Gurus.
i have a strange problem with blocks (parallel processing).
My Wf contain of:
1. Dialog step, where user choose actors.
2. parallel block for actors, the first step in the block - no-dialog step for getting instance of actor object.
When I test this WF, and choose more than 5 actors, the parallel processing not working,
all non-dialog task for each actor are in READY state, and not processing.
But when I delete dialog step and set actors manually, its working fine, and when I chosee less than 5 actors, it's working.
I check mapping, everything ok. Thank you for advise.
Regards,
Oleg.Thank you for your reply.
I have no rule in this Workflow, the processor of first dialog step is wf_initiator.
This step base on standard method - WF_TASK.DISPATCH.
Initiator chooses actor's (in my case it's org. units) and the table seem's like:
O 01000000
O 02000000
O 03000000
Then, I try to make paralllel steps for each line of this table. In WF Log, I see that parallel blocks is created,
but the first step in this blocks (it's no-dialog step to generate instance of orgunit object), is in ready state (the line (object key) is transfer to this step, and the instance is not generated). As I said, when I delete the step with agent chose, and fill this table manually, its working fine... -
Problems with Slide Navigator while skipping slides
When I was running my show, I had to skipped my slides twice. For example, when I am at slide 3, I pressed "+" and went to a slide 7; then I had to press "+" again to go to slide 9. When I am going to slide 9, slide 3 would actually appear for a split second then slide 9 would appear. All these slides has "build" in it. When I tried this with slides without "build", there are no problems. Anyone else experienced this?
Well, you have to look in different places for transitions.
Slides can have them but you have to specifically configure them.
Objects have them by default (Fade in and fade out)
The project itself is usually configured with a "Fade in on first slide" and a "Fade out on last slide".
Click Edit > Preferences > Project > Start and End
Cheers... Rick
Helpful and Handy Links
Begin learning Captivate 5 moments from now! $29.95
Captivate Wish Form/Bug Reporting Form
Adobe Certified Captivate Training
SorcererStone Blog
Captivate eBooks -
Problems with Slide Video, when returning to a slide
Hello all!
I have a weird problem with my Captivate presenation, I wonder if anyone could help me...
I have Captivate training course that I've made (output to Flash to run on a SCORM-compliant system). It has a table of contents which points to different "lesson" screens with videos.
All videos are of type "slide video", they will be launched from the LMS running the course.
When I click on the slide to play the video the first time, it plays just fine. But if I go back to it later, it acts erratically (plays from middle of video, starts looping weirdly, etc).
Has anyone else seen this? Wanted to know what I could do to fix.
Thanks!
DanielTo better illustrate, I've created a simple project with a menu slide and a slide video slide - a really over-simplified version of what I'm trying to do, but still has the same problem. The project is online to download at:
http://ge.tt/8TqfXEA?c
If anyone has time, here is how to recreate the difficulty I'm experiencing:
Run the project (either preview or export SWF, either way is fine)
From the first slide (menu), click on the button, which will go to the next slide and play the video
After the video finishes, click on the "Return to Menu" button
Once back at the menu, click the button to play the next slide & video again. You'll notice that playback is erratic (starts later in the video, also begins weirdly looping).
Please let me know how I can rectify - it's a really big problem. If I'm doing something stupid, please let me know (although I don't think I am - it's a really minimal project setup).
Thanks again for any help anyone can provide!!! -
Problem with ForEach block in BPM
Hi,
I have a scenario as follows:
Collecting Idocs and send them separately via file channel (Does not make so much sense but I want to get used using the forEach Block)
Loop (as long as "control" != false)
Fork
1. branch: Wait step 1 minute and container operation assign "control" = false (if no more idoc is received, loop stops after 1 minute)
2. branch: receive step with correlation, container operation with append to multiline message, container operation assign "control" = true
Mapping
multiline message to single line message (same interface)
ForEach Block
Send Step with single line message
My problem:
x idocs get collected by the BPM and my file channel posts x idocs to the directory but it is always the same idoc and not x different ones.
Any idea on that?
Regards.
Oliver.Yes, that's the blog I used.
I have used the same interface for Send/Receive Steps, the Multi-Line Element and the Current Line Element. I restricted the Current Line Element to the block. Any other definition would not show up in the dropdown list, anyway.
These are my settings for the Block:
Step Name: Block1
Description: [Blank]
Mode: ForEach
MultiLine Element: Idoc_Multi
CurrentLine: Idoc_Local
End Condition, Exceptions and Local Correlations: [Blank]
Here are the settings for the Send Step:
Step Name: Send1
Description: [Blank]
Mode: Asynchronous
Create New transaction: [Not marked]
Message: Idoc
Ack: None
Receiver from: Send Context
All others: [Blank]
I don't see any error?
Regards.
Oliver. -
Hi everibody
I am nephiew with labview and i am trying to use "to variant" block.
In the atteachment there is a picture of my VI.
Where am i wrong?!
Best regards
Giovanni
Attachments:
variant.png 39 KBYou are right but the problem is more complex.
This is only a short vi.
I am communicating with a PLC and to do that i have used a .NET library.
The problem is that the library gives me some data from the plc in a To string variable. See the atteachment.
Trhough the variable datatype i select the corrisponding case. In the case of boolean is not a metter. In the case of an int16 i don't know how i can do. I would like to make a different thing for all type of variables...
is it clear?!
in the atteachment there is the vi and two screenshot of it.
Attachments:
variant2.png 14 KB
variant.png 11 KB
Untitled 2.vi 33 KB -
Hello All,
I have a sql query which i am trying to put it in plsql block.It throws me an error saying i cannot have group function as my two select strings gives me more than one row. How to tackle this??
declare
uuid varchar;
stat_date date;
begin
select 'I'||Lower(docfamily_uuid) into uuid, max(status_date) into stat_date from document_status where status_code=303 or status_code=305 group by docfamily_uuid;
end;
ThanksIn addition to being mal-formed it is likely your problem stems from the fact that your query is returning more than one row. Now perhaps you are expecting only one row and your GROUP BY might be getting in the way. Try changing your GROUP BY to include the LOWER function that is in your SELECT statement. But realize that this in itself will not guarentee one row returning from the SELECT statement.
WITH document_status AS
SELECT 'xxx' docfamily_uuid, sysdate status_date, 303 status_code from dual
UNION ALL
SELECT 'XXX' docfamily_uuid, sysdate status_date, 303 status_code from dual
SELECT 'I'||Lower(docfamily_uuid), max(status_date)
FROM document_status
WHERE status_code=303 or status_code=305
GROUP BY docfamily_uuid;
Ixxx 05-FEB-09
Ixxx 05-FEB-09
WITH document_status AS
SELECT 'xxx' docfamily_uuid, sysdate status_date, 303 status_code from dual
UNION ALL
SELECT 'XXX' docfamily_uuid, sysdate status_date, 303 status_code from dual
SELECT 'I'||Lower(docfamily_uuid), max(status_date)
FROM document_status
WHERE status_code=303 or status_code=305
GROUP BY LOWER(docfamily_uuid);
Ixxx 05-FEB-09Greg -
In Photoshop elements 9 I encounter the problem, that when I save a slide show with an attached audio file as a PDF file, the music simply is not saved in the PDF file. When saved as a WMV file, there are no problems and the music is there, when I open the saved file. Has anybody a solution - I do not underdstand whay it does not work, as it works without problems when using my stone-age CS2 version.
Hi Mihael,
Try the below steps to resolve the issue:
1) Choose Slide Size - Very Small(640x480), while saving the slideshow as PDF File.
2) Click on OK.
3) Choose the destination to save the PDF.
4) Open the saved PDF file and it would ask to allow the disabled feature below the Acrobat toolbar.
5) Choose "Trust this document always".
Revert back for further concerns. -
Hi, I'm using some action script code for a slide. The problem is that when a smaller image is loaded, the big one stays behind for one slide more. Maybe this happens with all slides but is only visible when a smaller one is loaded... What could be done? The code is:
// import tweener
import caurina.transitions.Tweener;
// delay between slides
const TIMER_DELAY:int = 5000;
// fade time between slides
const FADE_TIME:Number = 1;
// flag for knowing if slideshow is playing
var bolPlaying:Boolean = true;
// reference to the current slider container
var currentContainer:Sprite;
// index of the current slide
var intCurrentSlide:int = -1;
// total slides
var intSlideCount:int;
// timer for switching slides
var slideTimer:Timer;
// slides holder
var sprContainer1:Sprite;
var sprContainer2:Sprite;
// slides loader
var slideLoader:Loader;
// current slide link
var strLink:String = "";
// current slide link target
var strTarget:String = "";
// url to slideshow xml
var strXMLPath:String = "slideshow-data.xml";
// slideshow xml loader
var xmlLoader:URLLoader;
// slideshow xml
var xmlSlideshow:XML;
function initSlideshow():void {
// hide buttons, labels and link
mcInfo.visible = false;
btnLink.visible = false;
// create new urlloader for xml file
xmlLoader = new URLLoader();
// add listener for complete event
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
// load xml file
xmlLoader.load(new URLRequest(strXMLPath));
// create new timer with delay from constant
slideTimer = new Timer(TIMER_DELAY);
// add event listener for timer event
slideTimer.addEventListener(TimerEvent.TIMER, nextSlide);
// create 2 container sprite which will hold the slides and
// add them to the masked movieclip
sprContainer1 = new Sprite();
sprContainer2 = new Sprite();
mcSlideHolder.addChild(sprContainer1);
mcSlideHolder.addChild(sprContainer2);
// keep a reference of the container which is currently
// in the front
currentContainer = sprContainer2;
// add event listeners for buttons
btnLink.addEventListener(MouseEvent.CLICK, goToWebsite);
mcInfo.btnNext.addEventListener(MouseEvent.CLICK, nextSlide);
mcInfo.btnPrevious.addEventListener(MouseEvent.CLICK, previousSlide);
function onXMLLoadComplete(e:Event):void {
// show buttons, labels and link
mcInfo.visible = true;
btnLink.visible = true;
// create new xml with the received data
xmlSlideshow = new XML(e.target.data);
// get total slide count
intSlideCount = xmlSlideshow..image.length();
// switch the first slide without a delay
switchSlide(0);
function fadeSlideIn(e:Event):void {
// add loaded slide from slide loader to the
// current container
addSlideContent();
// fade the current container in and start the slide timer
// when the tween is finished
Tweener.addTween(currentContainer, {alpha:1, time:FADE_TIME, onComplete:onSlideFadeIn});
function onSlideFadeIn():void {
// check, if the slideshow is currently playing
// if so, start the timer again
if(bolPlaying && !slideTimer.running)
slideTimer.start();
function switchSlide(intSlide:int):void {
// check if the last slide is still fading in
if(!Tweener.isTweening(currentContainer)) {
// check, if the timer is running (needed for the
// very first switch of the slide)
if(slideTimer.running)
slideTimer.stop();
// change slide index
intCurrentSlide = intSlide;
// check which container is currently in the front and
// assign currentContainer to the one that's in the back with
// the old slide
if(currentContainer == sprContainer2)
currentContainer = sprContainer1;
else
currentContainer = sprContainer2;
// hide the old slide
currentContainer.alpha = 0;
// bring the old slide to the front
mcSlideHolder.swapChildren(sprContainer2, sprContainer1);
// delete loaded content
clearLoader();
// create a new loader for the slide
slideLoader = new Loader();
// add event listener when slide is loaded
slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeSlideIn);
// load the next slide
slideLoader.load(new URLRequest(xmlSlideshow..image[intCurrentSlide].@src));
// show description of the next slide
mcInfo.lbl_description.text = xmlSlideshow..image[intCurrentSlide].@title;
// set link and link target variable of the slide
strLink = xmlSlideshow..image[intCurrentSlide].@link;
strTarget = xmlSlideshow..image[intCurrentSlide].@target;
mcInfo.mcDescription.lbl_description.htmlText = xmlSlideshow..image[intCurrentSlide].@desc;
// show current slide and total slides
mcInfo.lbl_count.text = (intCurrentSlide + 1);
function goToWebsite(e:MouseEvent):void {
// check if the strLink is not empty and open the link in the
// defined target window
if(strLink != "" && strLink != null) {
navigateToURL(new URLRequest(strLink), strTarget);
function nextSlide(e:Event = null):void {
// check, if there are any slides left, if so, increment slide
// index
if(intCurrentSlide + 1 < intSlideCount)
switchSlide(intCurrentSlide + 1);
// if not, start slideshow from beginning
else
switchSlide(0);
function previousSlide(e:Event = null):void {
// check, if there are any slides left, if so, decrement slide
// index
if(intCurrentSlide - 1 >= 0)
switchSlide(intCurrentSlide - 1);
// if not, start slideshow from the last slide
else
switchSlide(intSlideCount - 1);
function clearLoader():void {
try {
// get loader info object
var li:LoaderInfo = slideLoader.contentLoaderInfo;
// check if content is bitmap and delete it
if(li.childAllowsParent && li.content is Bitmap){
(li.content as Bitmap).bitmapData.dispose();
} catch(e:*) {}
function addSlideContent():void {
// empty current slide and delete previous bitmap
while(currentContainer.numChildren){Bitmap(currentContainer.getChildAt(0)).bitmapData.dis pose(); currentContainer.removeChildAt(0);}
// create a new bitmap with the slider content, clone it and add it to the slider container
var bitMp:Bitmap = new Bitmap(Bitmap(slideLoader.contentLoaderInfo.content).bitmapData.clone());
currentContainer.addChild(bitMp);
// init slideshow
initSlideshow();you should check the memory usage with that code. it looks like that's not well-written code.
but to do what you want:
// import tweener
import caurina.transitions.Tweener;
import flash.display.Sprite;
// delay between slides
const TIMER_DELAY:int = 5000;
// fade time between slides
const FADE_TIME:Number = 1;
// flag for knowing if slideshow is playing
var bolPlaying:Boolean = true;
// reference to the current slider container
var currentContainer:Sprite;
// index of the current slide
var previousContainer:Sprite;
var intCurrentSlide:int = -1;
// total slides
var intSlideCount:int;
// timer for switching slides
var slideTimer:Timer;
// slides holder
var sprContainer1:Sprite;
var sprContainer2:Sprite;
// slides loader
var slideLoader:Loader;
// current slide link
var strLink:String = "";
// current slide link target
var strTarget:String = "";
// url to slideshow xml
var strXMLPath:String = "slideshow-data.xml";
// slideshow xml loader
var xmlLoader:URLLoader;
// slideshow xml
var xmlSlideshow:XML;
function initSlideshow():void {
// hide buttons, labels and link
mcInfo.visible = false;
btnLink.visible = false;
// create new urlloader for xml file
xmlLoader = new URLLoader();
// add listener for complete event
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
// load xml file
xmlLoader.load(new URLRequest(strXMLPath));
// create new timer with delay from constant
slideTimer = new Timer(TIMER_DELAY);
// add event listener for timer event
slideTimer.addEventListener(TimerEvent.TIMER, nextSlide);
// create 2 container sprite which will hold the slides and
// add them to the masked movieclip
sprContainer1 = new Sprite();
sprContainer2 = new Sprite();
mcSlideHolder.addChild(sprContainer1);
mcSlideHolder.addChild(sprContainer2);
// keep a reference of the container which is currently
// in the front
currentContainer = sprContainer2;
// add event listeners for buttons
btnLink.addEventListener(MouseEvent.CLICK, goToWebsite);
mcInfo.btnNext.addEventListener(MouseEvent.CLICK, nextSlide);
mcInfo.btnPrevious.addEventListener(MouseEvent.CLICK, previousSlide);
function onXMLLoadComplete(e:Event):void {
// show buttons, labels and link
mcInfo.visible = true;
btnLink.visible = true;
// create new xml with the received data
xmlSlideshow = new XML(e.target.data);
// get total slide count
intSlideCount = xmlSlideshow..image.length();
// switch the first slide without a delay
switchSlide(0);
function fadeSlideIn(e:Event):void {
// add loaded slide from slide loader to the
// current container
addSlideContent();
fadeSlideOut();
// fade the current container in and start the slide timer
// when the tween is finished
Tweener.addTween(currentContainer, {alpha:1, time:FADE_TIME, onComplete:onSlideFadeIn});
function fadeSlideOut(e:Event):void {
Tweener.addTween(previousContainer, {alpha:0, time:FADE_TIME});
function onSlideFadeIn():void {
// check, if the slideshow is currently playing
// if so, start the timer again
if(bolPlaying && !slideTimer.running)
slideTimer.start();
function switchSlide(intSlide:int):void {
// check if the last slide is still fading in
if(!Tweener.isTweening(currentContainer)) {
// check, if the timer is running (needed for the
// very first switch of the slide)
if(slideTimer.running)
slideTimer.stop();
// change slide index
intCurrentSlide = intSlide;
// check which container is currently in the front and
// assign currentContainer to the one that's in the back with
// the old slide
previousContainer = currentContainer;
if(currentContainer == sprContainer2)
currentContainer = sprContainer1;
else
currentContainer = sprContainer2;
// hide the old slide
currentContainer.alpha = 0;
// bring the old slide to the front
mcSlideHolder.swapChildren(sprContainer2, sprContainer1);
// delete loaded content
clearLoader();
// create a new loader for the slide
slideLoader = new Loader();
// add event listener when slide is loaded
slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeSlideIn);
// load the next slide
slideLoader.load(new URLRequest(xmlSlideshow..image[intCurrentSlide].@src));
// show description of the next slide
mcInfo.lbl_description.text = xmlSlideshow..image[intCurrentSlide].@title;
// set link and link target variable of the slide
strLink = xmlSlideshow..image[intCurrentSlide].@link;
strTarget = xmlSlideshow..image[intCurrentSlide].@target;
mcInfo.mcDescription.lbl_description.htmlText = xmlSlideshow..image[intCurrentSlide].@desc;
// show current slide and total slides
mcInfo.lbl_count.text = (intCurrentSlide + 1);
function goToWebsite(e:MouseEvent):void {
// check if the strLink is not empty and open the link in the
// defined target window
if(strLink != "" && strLink != null) {
navigateToURL(new URLRequest(strLink), strTarget);
function nextSlide(e:Event = null):void {
// check, if there are any slides left, if so, increment slide
// index
if(intCurrentSlide + 1 < intSlideCount)
switchSlide(intCurrentSlide + 1);
// if not, start slideshow from beginning
else
switchSlide(0);
function previousSlide(e:Event = null):void {
// check, if there are any slides left, if so, decrement slide
// index
if(intCurrentSlide - 1 >= 0)
switchSlide(intCurrentSlide - 1);
// if not, start slideshow from the last slide
else
switchSlide(intSlideCount - 1);
function clearLoader():void {
try {
// get loader info object
var li:LoaderInfo = slideLoader.contentLoaderInfo;
// check if content is bitmap and delete it
if(li.childAllowsParent && li.content is Bitmap){
(li.content as Bitmap).bitmapData.dispose();
} catch(e:*) {}
function addSlideContent():void {
// empty current slide and delete previous bitmap
while(currentContainer.numChildren){Bitmap(currentContainer.getChildAt(0)).bitmapData.dis pose(); currentContainer.removeChildAt(0);}
// create a new bitmap with the slider content, clone it and add it to the slider container
var bitMp:Bitmap = new Bitmap(Bitmap(slideLoader.contentLoaderInfo.content).bitmapData.clone());
currentContainer.addChild(bitMp);
// init slideshow
initSlideshow(); -
Action Script Newbie has problem with Slide Show Pro
Hi,
here is a demo page -
http://www.libertypromotions.com/asptest/newsite/cars/product_page.htm.
The flash gallery in the top left is my problem child. I am
using Slide Show pro to display my images but I want to add some
external buttons that will switch albums when you click them (all
images are in there own album, giving me the Grid effect when you
click see all) I have asked for help on how to do this on their
forums, but they are useless (so far) so I came here. Below is the
code SSP provides for external Next/Previous buttons that switch
images inside albums.
I am hoping someone here knows SSP well enough to help me
with this.
Thanks in advance.cowenstx,
Javascript is VERY different from Java. Your code example is Javascript, a scripting language invented by Netscape. Do a web search for "javascript images" for lots of good pointers. -
Repaint() - problems with queueing/blocking
hello,
im writing a game as an applet using awt, but i cant get the repaint() method to execute where i would want it to.
import java.applet.* ;
import java.awt.* ;
import java.awt.event.* ; //depreciated
import java.util.* ;
public class matches_applet extends Applet
implements ActionListener , MouseListener , ItemListener {
// var declarations
// init
// reinit for starting new game
// waiter for simulating "thinking"
public void move( int srcX , int srcY , int destX , int destY ) {
//check if vaild move...
// mode : 1 = single player , 2 = mulitplayer
// player: 1 = human , 2 = human/computer
if (mode == 1 && player == 1 ) {
waiter() ; //simulate computer player "thinking"
//add move to list of done moves...
System.out.println("repaint attempt");
try {
Thread.currentThread().sleep(2000);
field.repaint();
Thread.currentThread().sleep(2000);
} catch ( Exception e ) {}
System.out.println("repaint succsessful");
if (mode == 1 && player == -1 ) {
//send human move to ai...
//receive ai move
//write ai move to vars fromX , fromY , toX , toY
move( fromX , fromY , toX , toY ) ;
// listeners
// move invoked from mouseClicked( MouseEvent mouse ){}
public class CentrePanel extends Canvas {
@Override
public void paint( Graphics g ) {
System.out.println("repaint in");
// paint stuff
System.out.println("repaint out");
}now when i attempt to move a pawn, my console prints :
repaint attempt
repaint succsessful
repaint attempt
repaint succsessful
repaint in
repaint out
for the part inside the move.
insted it should print ( correct me if im wrong ) :
repaint attempt
repaint in
repaint out
repaint succsessful
repaint attempt
repaint in
repaint out
repaint succsessful
i know that the
if (mode == 1 && player == -1 ) {...}is blocking the queue, but i dont know how to get it not to.
thx for any answers in advance,
westernmagic
Edited by: westernmagic on Feb 1, 2009 5:36 AMPete_Kirkham wrote:
An alternative approach is to bypass the event queue and call paint directly with the components Graphics object whilst in the loop.
Pete[http://forums-beta.sun.com/thread.jspa?messageID=2065345]
thanks Pete.
@ admin/mod : feel free to close.
Edited by: westernmagic on Feb 1, 2009 1:26 PM -
Problem with CVI blocking UART Callback
Hi,
I have been using LabWindows CVI 9.0 since a few years now and I have seen a problem that didn't blocked me until now.
My LabWindows Software freezes, the code is no longer executed, when I hold a click on the interface, on a string for example.
The problem is that I use a device that emits data continuously on a COM port. When I decide to drag the software window or simply hold a left click on the interace the software stop acquiring data from the COM callback and my software misses data.
Do you have a solution for this problem ?
Thank youHI Penou,
In fact it is a good idea using multiple Threads to avoid this kind of behavior.
Maybe you are using ProcessSystemEvents to handle events, on the same main thread.
If it is the case, when ProcessSystemEvents handles an event that starts a tracking loop, such as the user pulling down a menu, ProcessSystemEvents does not return until the tracking loop completes. In the case of pulling down a menu, the tracking loop does not complete until the user dismisses the menu.
You have several inforrmations about ProcessSystemEvents here.
Regards,
Rémi D.
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
>> Les rencontres techniques de NI - Mesures et acquisition de données : de la théorie à la mise en ... -
Dear All,
I am doing a BDC for a particular transaction. The BDC program defaults some values. The problem is , at a particular screen the coding blocks screen was popping up..I did n't code this coding block screen..I want to supress that coding block screen. Client does n't wants the coding blocks screen.. Can some one help me to supress these coding blocks...
Thanks in advance,
King.BDC behave differently in background, so where ever coding block page comes out just key-in enter, you cannot surpress this value.
Ex: BDC_OKCODE "=ENTE"
It will solve your problem.
Reward points if useful.
Regards,
SaiRam
Maybe you are looking for
-
Reclaiming space in a database...
Hi Would like to request your views on a scenario. I have exported a database [Oracle version 9i or 10g] (using original exp) with rows=N. Now though there is no data but it still will occupy the same space because of the extent thing. Now I want to
-
i had problem for my itunes wifi sync, in general setting itunes wifi sync, i got 2 folder name 1st one is one i want sync for app, movie,music and tones, somehow i got second one folder i dont want is photos only when plug into it only sync for phot
-
JMS Adapter configuration failed in creating table that handles OEMS JM
Step 2 from Chapter 8 of E15763-01, Oracle Application Integration Architecture - Foundation Pack 2.5: Integration Developer's Guide Configuring of JMS Adapters Create the table that handles the OEMS JMS destination (queue). Queues use a queue table
-
Windows 8.1 enterprise hanging on envy 15 j130tx
My 3 day old hp envy j130 tx (4gb ram ,750gb hdd,intel core i5 2.5ghz,nvidia 740m GPU) lags and is slow it also buffers when playing media its running on windows 8.1(enterprise) i updated to the latest drivers pack solution and no change was seen ple
-
Desktop items only appearing in finder
I recently upgraded the hardrive on a Macbook 2008. All was fine after inital boot up. I was attempting to recover lost files and somehow all of the desktop items disappeared. They are only appearing in Finder and I can't drag them to the des