Flash Pro's should be able to solve in seconds loading a movie - actionscript-2

I have this action script that pulls images from a xml file
> myPhoto = new XML();
> myPhoto.ignoreWhite = true;
> myPhoto.onLoad = function(success) {
> //portfolioTag = this.firstChild;
> numimages =
> this.firstChild.childNodes.length;
> spacing = 28; for (i=0; i<numimages;
> i++) { this.picHolder =
> this.firstChild.childNodes[i];
> this.thumbHolder =
> thumbnails.createEmptyMovieClip("thumbnail"+i,
> i); this.thumbHolder._x = i*spacing;
> this.thumbLoader =
> this.thumbHolder.createEmptyMovieClip("thumbnail_image",
> 0);
> this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
> this.thumbHolder.title =
> this.picHolder.attributes.title;
> this.thumbHolder.main =
> this.picHolder.attributes.main;
> this.thumbHolder.onRelease =
> function() { getURL(this.main,
> "_self"); loadMovie(this.main);
> main_txt.text = this.main; }; }
> }; myPhoto.load("languages.xml");
I want to load movies into the flash from the xml when someone clicks on one of the images. I suspect to make this possible I need to change this part of the actionscript
this.thumbHolder.onRelease =
> function() { getURL(this.main,
> "_self"); loadMovie(this.main);
> main_txt.text = this.main; }; }
> }; myPhoto.load("languages.xml");

You might want to remove getURL(...), since that will push you to another page. Also loadMovie(url, target) needs a target.

Related

If, if else, else doesn't work in cypress

I have the following code, but block with else if doesn't work,
how can I change this code, to make the if else block work?
cy.get('#cards-list').then((list) => {
const valueFormList = list.find(`a:contains('${nameForSite}')`)
const nextArrow = list.find(`li.pagination-next`)
if (valueFormList.length > 0 && nextArrow.length > 0){
cy.get(`a:contains('${nameForSite}')`).as('card')
} else if (valueFormList.length < 0 && nextArrow.length > 0) {
cy.get('li.pagination-next').click()
cy.wait(200)
cy.findCardOnFacebook(nameForSite)
} else {
cy.get('h4.learning-opportunities-title').should('contain', 'Learning')
}
})
The error is because of the condition valueFormList.length < 0. The length can never be less than 0. Either it can be zero or more than zero.
cy.get('#cards-list').then((list) => {
const valueFormList = list.find(`a:contains('${nameForSite}')`)
const nextArrow = list.find(`li.pagination-next`)
if (valueFormList.length == 0 && nextArrow.length > 0) {
cy.get('li.pagination-next').click()
cy.wait(200)
cy.findCardOnFacebook(nameForSite)
} else if (valueFormList.length > 0 && nextArrow.length > 0) {
cy.get(`a:contains('${nameForSite}')`).as('card')
} else {
cy.get('h4.learning-opportunities-title').should('contain', 'Learning')
}
})

Vehicle Spinner move faster when moving mouse faster

How can I speed up the rotation speed in the below script. Currently the movement is calculated like so:
handleMove($event) {
if (this.isMoving && this.isDragging) {
const positions = {
x: $event.pageX || $event.touches[0].pageX,
y: $event.pageY || $event.touches[0].pageY
}
this.changeFrame(positions);
this.lastX = positions.x;
this.lastY = positions.y;
}
},
changeFrame(positions) {
this.speedController += 1;
if ((this.speedController < this.speed)) {
return;
}
if (this.speedController > this.speed) {
this.speedController = 0;
}
if (positions.x > this.lastX) {
if (this.frame >= 0 && this.frame < this.images.length) {
this.frame += 1;
} else if (this.loop) {
this.frame = 1;
}
} else if (positions.x < this.lastX) {
if (this.frame >= 0 && this.frame - 1 > 0) {
this.frame -= 1;
} else if (this.loop) {
this.frame = this.images.length;
}
}
}
I have tried to change section where it increases the the frame number, to this.frame += positions.x - this.lastX however I then get the following error:
[Vue warn]: You may have an infinite update loop in a component render function.
What is the best way to do this? You can see the script running here.
Edit
I have updated the script, however it is really glitchy! Use the link for a live example.
changeFrame(positions) {
const diff = positions.x - this.startX;
let frameDelta = diff / this.speed;
this.frame += Math.round(frameDelta);
if (this.frame < 0) {
this.frame += this.images.length;
} else if (this.frame > this.images.length - 1) {
this.frame = this.frame % this.images.length;
}
}
Your logic is that as long as position.x > this.lastX that you increment this.frame by 1. If you want it to spin faster, then increment it by a larger number. The same goes for decrementing the number.
However, this speed depends on how often changeFrame() is fired, and that can be variable due to browser performance and etc. If you want the most accurate results, you should simply increment/decrement the frame based on how much the position has changed.
If you say, want to change the speed so that for every 10px of cursor movement you increment the frame by one, you can do this:
const diff = positions.x - this.lastX;
// Let's say we increment/decrement the frame for every 10px travelled
const rateOfSpin = 10;
// Number of frames of change, adjusted based on desired rate of spin
const frameDelta = diff / rateOfSpin;
this.frame += frameDelta;
// If we go below zero, then we start from the end
if (this.frame < 0) {
this.frame += this.images.length;
// Otherwise we simply get the modulus
} else if (this.frame > this.images.length) {
this.frame = this.frame % this.images.length;
}

Prestashop 1.7: product-prices.TPL: where is defined {$product.price_amount}?

I am looking at the file themes/my_theme/templates/catalog/_partials/product-prices.tpl. There, an attempt to show the real price with taxes is made: <span class="price-ttc">{Tools::displayPrice($product.price_amount*$prix_ttc)} TTC </span>.
However, I don't find the property named price_amount in web/controllers/front/ProductController.php:
public function getTemplateVarProduct()
{
$productSettings = $this->getProductPresentationSettings();
// Hook displayProductExtraContent
$extraContentFinder = new ProductExtraContentFinder();
$product = $this->objectPresenter->present($this->product);
$product['id_product'] = (int) $this->product->id;
$product['out_of_stock'] = (int) $this->product->out_of_stock;
$product['new'] = (int) $this->product->new;
$product['id_product_attribute'] = $this->getIdProductAttributeByRequestOrGroup();
$product['minimal_quantity'] = $this->getProductMinimalQuantity($product);
$product['quantity_wanted'] = $this->getRequiredQuantity($product);
$product['extraContent'] = $extraContentFinder->addParams(array('product' => $this->product))->present();
$product['ecotax'] = Tools::convertPrice((float) $product['ecotax'], $this->context->currency, true, $this->context);
$product_full = Product::getProductProperties($this->context->language->id, $product, $this->context);
$product_full = $this->addProductCustomizationData($product_full);
$product_full['show_quantities'] = (bool) (
Configuration::get('PS_DISPLAY_QTIES')
&& Configuration::get('PS_STOCK_MANAGEMENT')
&& $this->product->quantity > 0
&& $this->product->available_for_order
&& !Configuration::isCatalogMode()
);
$product_full['quantity_label'] = ($this->product->quantity > 1) ? $this->trans('Items', array(), 'Shop.Theme.Catalog') : $this->trans('Item', array(), 'Shop.Theme.Catalog');
$product_full['quantity_discounts'] = $this->quantity_discounts;
if ($product_full['unit_price_ratio'] > 0) {
$unitPrice = ($productSettings->include_taxes) ? $product_full['price'] : $product_full['price_tax_exc'];
$product_full['unit_price'] = $unitPrice / $product_full['unit_price_ratio'];
}
$group_reduction = GroupReduction::getValueForProduct($this->product->id, (int) Group::getCurrent()->id);
if ($group_reduction === false) {
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
}
$product_full['customer_group_discount'] = $group_reduction;
$product_full['title'] = $this->getProductPageTitle();
$presenter = $this->getProductPresenter();
return $presenter->present(
$productSettings,
$product_full,
$this->context->language
);
}
Could you please tell me where is it located?
PrestaShop 1.7 uses Presenters
Your property is defined here:
/src/Adapter/Presenter/Product/ProductLazyArray.php in addPriceInformation method

I am getting this error "Can't find variable: FBSDKApplicationDelegate"

Can't find variable: FBSDKApplicationDelegate,
app.js
> const application = require("tns-core-modules/application");
>
> if(application.ios){ `
>
> var AppDelegate = UIResponder.extend({
> applicationDidFinishLaunchingWithOptions :function (application,
> launchOptions) { var gglDelegate = false; try { var errorRef = new
> interop.Reference();
> GGLContext.sharedInstance().configureWithError(errorRef); var signIn =
> GIDSignIn.sharedInstance(); gglDelegate = true; } catch (error) {
> console.log(error); } var fcbDelegate =
> FBSDKApplicationDelegate.sharedInstance().applicationDidFinishLaunchingWithOptions(application,
> launchOptions); // facebook login delegate return gglDelegate ||
> fcbDelegate; }, applicationOpenURLSourceApplicationAnnotation :
> function (application, url, sourceApplication, annotation) { var
> fcbDelegate =
> FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application,
> url, sourceApplication, annotation); // facebook login delegate var
> gglDelegate =
> GIDSignIn.sharedInstance().handleURLSourceApplicationAnnotation(url,
> sourceApplication, annotation); // google login delegate return
> fcbDelegate || gglDelegate; }
>
> },{ name: "AppDelegate", protocols:[UIApplicationDelegate]
>
> }); application.ios.delegate = AppDelegate; } application.run({
> moduleName: "app-root" });
The js code given in https://github.com/mkloubert/nativescript-social-login#javascript . not working , i am working on nativescript( javascript ) without any framework like TS , angular or view.

How to make greasemonkey open lots of links, in new tabs, one by one?

There are some links which looks like above
> <td><a href="http://Lucifase.com/pages/2000.php?refid=2000"
> target="_blank">2000</a><br></td> <td><a
> href="http://Lucifase.com/pages/3000.php?refid=3000"
> target="_blank">3000</a><br></td> <td><a
> href="http://Lucifase.com/pages/4000.php?refid=4000"
> target="_blank">4000</a><br></td> <td><a
> href="http://Lucifase.com/pages/5000.php?refid=5000"
> target="_blank">5000</a><br></td> <td><a
> href="http://Lucifase.com/pages/6000.php?refid=6000"
> target="_blank">6000</a><br></td>
And I stop in first step.I can't open each of them by script trigger. Here is which I have so far:
setTimeout(function() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0,
false, false, false, false,
0, null);
var links = document.getElementsByTagName('a');
if(links.href.search('refid') >= 0)
links.dispatchEvent(evt);
}, 1000);
But it doesn't work,also don't know how to make them open in new tab one by one.
What do you mean one by one? It appears that "clicking" all of the links at once is okay?
With links, must of the time, just follow the href instead of trying to send a click event. The following code should open just the tabs you want:
var linksToOpen = document.querySelectorAll ("td > a[href*='refid']");
for (var J = 0, numLinks = linksToOpen.length; J < numLinks; ++J) {
window.open (linksToOpen[J].href, '_blank');
}
Update for OP clarification:
To open the links with a delay between each one is slightly more complicated. Code like this will do it:
var linksToOpen = document.querySelectorAll ("td > a[href*='refid']");
//--- linksToOpen is a NodeList, we want an array of links...
var linksArray = [];
for (var J = 0, numLinks = linksToOpen.length; J < numLinks; ++J) {
linksArray.push (linksToOpen[J].href);
}
openLinksOnDelay (linksArray);
function openLinksOnDelay (linkArray) {
//--- Pop the first link off the array...
var linkToOpen = linkArray.shift ();
if (linkToOpen)
window.open (linkToOpen, '_blank');
//--- Open the next of the remaining links after a delay.
if (linkArray.length) {
setTimeout ( function() {
openLinksOnDelay (linkArray);
},
1000 //--- 1 second. Use 60000 for 1 minute.
);
}
}
Does it need to be mouse clicks or can it open the links with this:
for(i=0;i<document.links.length;i++) {
if(document.links[i].target != "_blank"){
window.open(
document.links[i].href,
'_blank'
);
}
}