Copy link to clipboard
Copied
Hi All,
First of all, I apologize if my subject line is misleading I wasn't sure how to write it out.
Basically I'm wondering how can I use a sring to replace one uploaded image with a preloaded one? We have a custom card builder that allows the end user the choice of uploading their own image, or using one of our preloaded card faces. If the end user selects the preloaded version, we must then send a "hi res" version to the printer.
That hi res version is a completely different image file that I would call, replace the low res version and send to the printer. Here is the ActionScript (3) we are using ...
<code>
function getPatterns():void {
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_10_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_11_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_12_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_13_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_14_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_15_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_16_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_17_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_18_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_19_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_20_thumb.png"});
step2b.tlPattern.addItem({label:"", source:"clipart/_pat_21_thumb.png"});
}
//===== Apply the currently selected pattern background
function clearBackground():void {
clearUpload();
clearPattern();
}
function clearUpload():void {
// Remove any uploaded image.
while (gcPreview.mcUpload.numChildren > 0) {
gcPreview.mcUpload.removeChildAt(0);
}
gcPreview.mcUpload.rotation = 0;
gcPreview.mcUpload.scaleX = 1;
gcPreview.mcUpload.scaleY = 1;
gcPreview.mcUpload.x = 0;
gcPreview.mcUpload.y = 0;
}
function clearPattern():void {
// Remove the old image
while (gcPreview.mcPattern.numChildren > 0) {
gcPreview.mcPattern.removeChildAt(0);
}
}
// CARD BUILDER CARD FACE INTERFACE CONTROL - below
function setPattern(e:Event):void {
// Change the background pattern from the gallery.
if (step2b.tlPattern.selectedItem) {
var ldr:Loader = new Loader(); //Declare the loader
ldr.load(new URLRequest(step2b.tlPattern.selectedItem.source.substring(0, step2b.tlPattern.selectedItem.source.length - 10)+".png")); //Load the template image
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void {
clearBackground();
gcPreview.mcPattern.addChild(ldr); // Apply it to the stage.
showStep("3"); // Go to the last step.
ldr.removeEventListener(Event.COMPLETE, onComplete);
}
} else {
// Remove the old image
clearPattern();
}
}
</code>
We would need the new card face "clipart/_pat_10_print.png" Called up. IF I haven;t supplied enough of the code pleaselet me know and we can work that out from there.
Thank you all, and I'm hoping you're having a great holiday season!!!
use:
step2b.tlPattern.selectedItem.source.split("thumb").join("print")
Copy link to clipboard
Copied
you could use:
step2b.tlPattern.selectedItem.label.split("thumb").join("print")
Copy link to clipboard
Copied
Hi kglad,
thank you for your fast reply.
I tried that, and when the end user goes to select the card face it doesn't allow the selection.
Copy link to clipboard
Copied
i'm not sure what that has to do with my suggestion.
but i see an error in your code - you're nesting two anonymous functions setPattern and onComplete. unnest them.
i'm not sure if those nested functions are related to whatever you mean by not being able to select the card fact either because it's not clear what a card face is and what you mean by that statement.
Copy link to clipboard
Copied
Hi kglad,
Sorry I didn't explain myself better, I was running out the door.
i've tried similar ideas to your suggestion, but it seems that everytime I change that line of code ...
<code>
ldr.load(new URLRequest(step2b.tlPattern.selectedItem.source.substring(0, step2b.tlPattern.selectedItem.source.length - 10)+".png"));
</code ...
It seems the card face selection no longer works.
Now card faces, what I mean by that is, the custom card builder I'm working on allows an end user to build a "customized" gift card for themselves or for a friend. So when I say pre built card faces, imagine a credit card with some sort of pattern on it. That's what I mean by card face.
I will try unnesting those functions and retry your suggestion.
Again I'm sorry I did not spend more time explaining myself.
Copy link to clipboard
Copied
use:
step2b.tlPattern.selectedItem.source.split("thumb").join("print")
Copy link to clipboard
Copied
Hi kglad,
Thank you. I cleaned up those functions and used this latest code mod and everything seems to be working "as expected"!!!
Have a safe and happy holiday season!!!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now